From 3c5d1fa695f30c955df10371df04d3582ccaed6e Mon Sep 17 00:00:00 2001 From: Dmitry Borisov Date: Thu, 19 Dec 2024 18:28:54 +0300 Subject: [PATCH] CORE-798 Linter added to the module --- .github/workflows/linter.yml | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..a9d2018 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,72 @@ +name: "Terraform Checks" +defaults: + run: + shell: bash +on: + pull_request: + +jobs: + # Performs linting and format checks and suggests fixes on PR + terraform-linter: + name: Terraform Linter + runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + matrix: + terraform_version: [1.5.6, 1.10.1] # Actual and latest versions used + fail-fast: false + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: true + + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "${{ matrix.terraform_version }}" + + - name: Terraform init + run: terraform init + + - name: Tflint Report Output + uses: reviewdog/action-tflint@v1.23.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tflint_version: "v0.49.0" # Version set due to this https://github.com/reviewdog/action-tflint/issues/83 + reporter: github-pr-review + fail_on_error: "true" + filter_mode: "added" + flags: "--module" # This option should work until tflint v0.5.1. + + # Performs linting and format checks and suggests fixes on PR + terraform-formatter: + name: Terraform Formatter + runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + matrix: + terraform_version: [1.5.6, 1.10.1] # Actual and latest versions used + fail-fast: false + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: true + + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "${{ matrix.terraform_version }}" + + - name: Terraform init + run: terraform init + + # This step applies format suggestions locally which would be used by a suggester + - name: Terraform Format suggestions + run: terraform fmt + + - uses: reviewdog/action-suggester@v1.18.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tool_name: "terraform" + fail_on_error: "true" + filter_mode: "added"