diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..aa77632 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,84 @@ +name: Preview + +on: + pull_request: + +concurrency: + group: terraform-google-cloud-router + cancel-in-progress: false + +jobs: + pre-commit: + runs-on: ubuntu-latest + name: Static Analysis + steps: + - name: Checkout + # for security reasons we pin commit ids and not tags. + # actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + fetch-depth: 0 + + - name: Setup asdf + # asdf-vm/actions/plugins-add@v3.0.2 + uses: asdf-vm/actions/plugins-add@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + + - name: Install tools via asdf + run: asdf install + + - name: Set up Golang + # actions/setup-go@v5.0.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + with: + go-version: 1.22.0 + + - name: Set up Terradoc + # for security reasons we pin commit ids and not tags. + # mineiros-io/terradoc@main -> af1a7b3ae3635958adf5ee2f40e0c3e70fd0803a + run: go install github.com/mineiros-io/terradoc/cmd/terradoc@af1a7b3ae3635958adf5ee2f40e0c3e70fd0803a + env: + GOPROXY: direct + + - name: Cache plugin dir + # for security reasons we pin commit ids and not tags. + # actions/cache@v4.0.0 -> 13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + with: + path: ~/.tflint.d/plugins + key: tflint-${{ hashFiles('.tflint.hcl') }} + + - name: Init TFLint + run: tflint --init + env: + # https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting + GITHUB_TOKEN: ${{ github.token }} + + - name: Setup and run pre-commit + # for security reasons we pin commit ids and not tags. + # pre-commit/action@v3.0.1 -> 2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd + uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd + + unit-tests: + # needs: pre-commit + runs-on: ubuntu-latest + name: Unit Tests + steps: + - name: Checkout + # for security reasons we pin commit ids and not tags. + # actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + fetch-depth: 0 + + - name: Setup asdf + # asdf-vm/actions/plugins-add@v3.0.2 + uses: asdf-vm/actions/plugins-add@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + + - name: Install tools via asdf + run: asdf install + + - name: Set up Golang + # actions/setup-go@v5.0.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + with: + go-version: 1.22.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0373d91 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: + group: terraform-google-cloud-router + cancel-in-progress: false + +jobs: + pre-commit: + runs-on: ubuntu-latest + name: Static Analysis + steps: + - name: Checkout + # for security reasons we pin commit ids and not tags. + # actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + fetch-depth: 0 + + - name: Setup asdf + # asdf-vm/actions/plugins-add@v3.0.2 + uses: asdf-vm/actions/plugins-add@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + + - name: Install tools via asdf + run: asdf install + + - name: Set up Golang + # actions/setup-go@v5.0.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + with: + go-version: 1.22.0 + + - name: Set up Terradoc + # for security reasons we pin commit ids and not tags. + # mineiros-io/terradoc@main -> af1a7b3ae3635958adf5ee2f40e0c3e70fd0803a + run: go install github.com/mineiros-io/terradoc/cmd/terradoc@af1a7b3ae3635958adf5ee2f40e0c3e70fd0803a + env: + GOPROXY: direct + + - name: Cache plugin dir + # for security reasons we pin commit ids and not tags. + # actions/cache@v4.0.0 -> 13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + with: + path: ~/.tflint.d/plugins + key: tflint-${{ hashFiles('.tflint.hcl') }} + + - name: Init TFLint + run: tflint --init + env: + # https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting + GITHUB_TOKEN: ${{ github.token }} + + - name: Setup and run pre-commit + # for security reasons we pin commit ids and not tags. + # pre-commit/action@v3.0.1 -> 2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd + uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd + + release: + needs: + - pre-commit + permissions: + contents: write + issues: write + runs-on: ubuntu-latest + steps: + - name: Checkout + # actions/checkout@v3.0.2 + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + fetch-depth: 0 + + - name: Semantic Release + # codfish/semantic-release-action@v3.1.0 + uses: codfish/semantic-release-action@07170c8b1613177f0f3aa4d2224e2e0933cd732c + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + plugins: | + ['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github'] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 95991c3..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Tests - -on: - push: - branches: - - main - pull_request: - -concurrency: - group: terraform-google-cloud-router - cancel-in-progress: false - -jobs: - pre-commit: - runs-on: ubuntu-latest - name: Static Analysis - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Run pre-commit - run: make test/pre-commit diff --git a/.gitignore b/.gitignore index 26fc003..89dd2ca 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,3 @@ vendor crash.log .terraform.lock.hcl -.tool-versions diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5608636..509b85c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,18 @@ repos: - repo: https://github.com/mineiros-io/pre-commit-hooks - rev: v0.3.0 + rev: v0.5.1 hooks: + - id: phony-targets + - id: terradoc-validate + - id: terradoc-fmt + - id: terradoc-generate + - id: terramate-generate - id: terraform-fmt - id: terraform-validate exclude: ^examples|.terraform/ - id: tflint - - id: golangci-lint - - id: phony-targets + - repo: https://github.com/adrienverge/yamllint + rev: v1.29.0 + hooks: + - id: yamllint + args: ['-s'] diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..fc76843 --- /dev/null +++ b/.releaserc @@ -0,0 +1,13 @@ +{ + "branches": [ + "main" + ], + "plugins": [ + ["@semantic-release/npm", { + "npmPublish": false + }], + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github" + ] +} diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..b06d074 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,18 @@ +rule "terraform_unused_declarations" { + enabled = false +} + +rule "terraform_required_providers" { + enabled = false +} + +plugin "terraform" { + enabled = true + preset = "recommended" +} + +plugin "google" { + enabled = true + version = "0.26.0" + source = "github.com/terraform-linters/tflint-ruleset-google" +} diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..d1e0722 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,4 @@ +terraform 1.5.7 +terramate 0.4.5 +tflint 0.48.0 +pre-commit 3.4.0 diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..082b548 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,5 @@ +extends: default +rules: + line-length: disable + document-start: disable + truthy: disable diff --git a/README.md b/README.md index 32b8f4f..2c7155f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A [Terraform] module for [Google Cloud Platform (GCP)][gcp]. **_This module supports Terraform version 1 -and is compatible with the Terraform Google Provider version 4._** +and is compatible with the Terraform Google Provider version 4._** and 5._** This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, diff --git a/README.tfdoc.hcl b/README.tfdoc.hcl index ef0a5d7..e6b2acb 100644 --- a/README.tfdoc.hcl +++ b/README.tfdoc.hcl @@ -40,7 +40,7 @@ section { A [Terraform] module for [Google Cloud Platform (GCP)][gcp]. **_This module supports Terraform version 1 - and is compatible with the Terraform Google Provider version 4._** + and is compatible with the Terraform Google Provider version 4._** and 5._** This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, diff --git a/versions.tf b/versions.tf index 422d525..c37cb64 100644 --- a/versions.tf +++ b/versions.tf @@ -8,7 +8,7 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = ">= 3.50, < 5.0" + version = ">= 3.50, < 6" } } }