From 62fef6acd0e58e8a34fa5823f0f7b25086b00dd0 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 22 Nov 2021 10:03:14 -0500 Subject: [PATCH 1/3] fix: update CI/CD process to enable auto-release workflow --- .chglog/CHANGELOG.tpl.md | 111 ------------------ .chglog/config.yml | 10 -- .github/workflows/pre-commit.yml | 103 +++++++--------- .github/workflows/release.yml | 32 +++++ .pre-commit-config.yaml | 2 +- .releaserc.json | 36 ++++++ CHANGELOG.md | 9 -- Makefile | 7 -- examples/complete-vpc/README.md | 6 +- examples/ipv6/README.md | 2 +- examples/issues/README.md | 6 +- examples/manage-default-vpc/README.md | 2 +- examples/network-acls/README.md | 2 +- examples/outpost/README.md | 2 +- examples/secondary-cidr-blocks/README.md | 2 +- examples/simple-vpc/README.md | 2 +- examples/vpc-flow-logs/README.md | 8 +- .../README.md | 2 +- 18 files changed, 127 insertions(+), 217 deletions(-) delete mode 100644 .chglog/CHANGELOG.tpl.md delete mode 100644 .chglog/config.yml create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc.json delete mode 100644 Makefile diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md deleted file mode 100644 index 687d70232..000000000 --- a/.chglog/CHANGELOG.tpl.md +++ /dev/null @@ -1,111 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. - -{{ if .Versions -}} - -## [Unreleased] -{{ if .Unreleased.CommitGroups -}} -{{ range .Unreleased.CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ else }} -{{ range .Unreleased.Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ end -}} - -{{ range .Versions }} - -## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }} -{{ if .CommitGroups -}} -{{ range .CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ else }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} - -{{- if .NoteGroups -}} -{{ range .NoteGroups -}} -### {{ .Title }} -{{ range .Notes }} -{{ .Body }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} - -{{- if .Versions }} -[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD -{{ range .Versions -}} -{{ if .Tag.Previous -}} -[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }} -{{ end -}} -{{ end -}} -{{ end -}} diff --git a/.chglog/config.yml b/.chglog/config.yml deleted file mode 100644 index 5c3fa357c..000000000 --- a/.chglog/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -style: github -template: CHANGELOG.tpl.md -info: - title: CHANGELOG - repository_url: https://github.com/terraform-aws-modules/terraform-aws-vpc -options: - header: - pattern: "^(.*)$" - pattern_maps: - - Subject diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f5d5d776a..b8f1b8a5a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -2,98 +2,77 @@ name: Pre-Commit on: pull_request: - push: branches: + - main - master +env: + TERRAFORM_DOCS_VERSION: v0.16.0 + jobs: - # Min Terraform version(s) - getDirectories: - name: Get root directories + collectInputs: + name: Collect workflow inputs runs-on: ubuntu-latest + outputs: + directories: ${{ steps.dirs.outputs.directories }} steps: - name: Checkout uses: actions/checkout@v2 - - name: Install Python - uses: actions/setup-python@v2 - - name: Build matrix - id: matrix - run: | - DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))") - echo "::set-output name=directories::$DIRS" - outputs: - directories: ${{ steps.matrix.outputs.directories }} + + - name: Get root directories + id: dirs + uses: clowdhaus/terraform-composite-actions/directories@v1.3.0 preCommitMinVersions: - name: Min TF validate - needs: getDirectories + name: Min TF pre-commit + needs: collectInputs runs-on: ubuntu-latest strategy: matrix: - directory: ${{ fromJson(needs.getDirectories.outputs.directories) }} + directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} steps: - name: Checkout uses: actions/checkout@v2 - - name: Install Python - uses: actions/setup-python@v2 + - name: Terraform min/max versions id: minMax - uses: clowdhaus/terraform-min-max@v1.0.2 + uses: clowdhaus/terraform-min-max@v1.0.3 with: directory: ${{ matrix.directory }} - - name: Install Terraform v${{ steps.minMax.outputs.minVersion }} - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: ${{ steps.minMax.outputs.minVersion }} - - name: Install pre-commit dependencies - run: pip install pre-commit - - name: Execute pre-commit + + - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} # Run only validate pre-commit check on min version supported if: ${{ matrix.directory != '.' }} - run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/* - - name: Execute pre-commit + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 + with: + terraform-version: ${{ steps.minMax.outputs.minVersion }} + args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' + + - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} # Run only validate pre-commit check on min version supported if: ${{ matrix.directory == '.' }} - run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf) + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 + with: + terraform-version: ${{ steps.minMax.outputs.minVersion }} + args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' - # Max Terraform version - getBaseVersion: - name: Module max TF version + preCommitMaxVersion: + name: Max TF pre-commit runs-on: ubuntu-latest + needs: collectInputs steps: - name: Checkout uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Terraform min/max versions id: minMax - uses: clowdhaus/terraform-min-max@v1.0.2 - outputs: - minVersion: ${{ steps.minMax.outputs.minVersion }} - maxVersion: ${{ steps.minMax.outputs.maxVersion }} + uses: clowdhaus/terraform-min-max@v1.0.3 - preCommitMaxVersion: - name: Max TF pre-commit - runs-on: ubuntu-latest - needs: getBaseVersion - strategy: - fail-fast: false - matrix: - version: - - ${{ needs.getBaseVersion.outputs.maxVersion }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Python - uses: actions/setup-python@v2 - - name: Install Terraform v${{ matrix.version }} - uses: hashicorp/setup-terraform@v1 + - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 with: - terraform_version: ${{ matrix.version }} - - name: Install pre-commit dependencies - run: | - pip install pre-commit - curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/ - curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/ - - name: Execute pre-commit - # Run all pre-commit checks on max version supported - if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }} - run: pre-commit run --color=always --show-diff-on-failure --all-files + terraform-version: ${{ steps.minMax.outputs.maxVersion }} + terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..141937d86 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: + - main + - master + paths: + - '**/*.py' + - '**/*.tf' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Release + uses: cycjimmy/semantic-release-action@v2 + with: + semantic_version: 18.0.0 + extra_plugins: | + @semantic-release/changelog@6.0.0 + @semantic-release/git@10.0.0 + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3a1295d4..bcee530b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.51.0 + rev: v1.58.0 hooks: - id: terraform_fmt - id: terraform_validate diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 000000000..6e39031cf --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,36 @@ +{ + "branches": [ + "main", + "master" + ], + "ci": false, + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/github", + { + "successComment": + "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", + "labels": false, + "releasedLabels": false + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ], + "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index f747f9823..d8423e8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,3 @@ -# Change Log - -All notable changes to this project will be documented in this file. - - -## [Unreleased] - - - ## [v3.11.0] - 2021-11-04 diff --git a/Makefile b/Makefile deleted file mode 100644 index 558dac5a6..000000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: changelog release - -changelog: - git-chglog -o CHANGELOG.md --next-tag `semtag final -s minor -o` - -release: - semtag final -s minor diff --git a/examples/complete-vpc/README.md b/examples/complete-vpc/README.md index 83e222272..25ee27547 100644 --- a/examples/complete-vpc/README.md +++ b/examples/complete-vpc/README.md @@ -34,9 +34,9 @@ Note that this example may create resources which can cost money (AWS Elastic IP | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | -| [vpc\_endpoints](#module\_vpc\_endpoints) | ../../modules/vpc-endpoints | | -| [vpc\_endpoints\_nocreate](#module\_vpc\_endpoints\_nocreate) | ../../modules/vpc-endpoints | | +| [vpc](#module\_vpc) | ../../ | n/a | +| [vpc\_endpoints](#module\_vpc\_endpoints) | ../../modules/vpc-endpoints | n/a | +| [vpc\_endpoints\_nocreate](#module\_vpc\_endpoints\_nocreate) | ../../modules/vpc-endpoints | n/a | ## Resources diff --git a/examples/ipv6/README.md b/examples/ipv6/README.md index 101c3a554..578ba037f 100644 --- a/examples/ipv6/README.md +++ b/examples/ipv6/README.md @@ -30,7 +30,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../.. | | +| [vpc](#module\_vpc) | ../.. | n/a | ## Resources diff --git a/examples/issues/README.md b/examples/issues/README.md index 4a976e114..b689ca62e 100644 --- a/examples/issues/README.md +++ b/examples/issues/README.md @@ -35,9 +35,9 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc\_issue\_108](#module\_vpc\_issue\_108) | ../../ | | -| [vpc\_issue\_44](#module\_vpc\_issue\_44) | ../../ | | -| [vpc\_issue\_46](#module\_vpc\_issue\_46) | ../../ | | +| [vpc\_issue\_108](#module\_vpc\_issue\_108) | ../../ | n/a | +| [vpc\_issue\_44](#module\_vpc\_issue\_44) | ../../ | n/a | +| [vpc\_issue\_46](#module\_vpc\_issue\_46) | ../../ | n/a | ## Resources diff --git a/examples/manage-default-vpc/README.md b/examples/manage-default-vpc/README.md index a40caad59..41946bc38 100644 --- a/examples/manage-default-vpc/README.md +++ b/examples/manage-default-vpc/README.md @@ -32,7 +32,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources diff --git a/examples/network-acls/README.md b/examples/network-acls/README.md index b6cee0c30..26fbc1b04 100644 --- a/examples/network-acls/README.md +++ b/examples/network-acls/README.md @@ -34,7 +34,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources diff --git a/examples/outpost/README.md b/examples/outpost/README.md index be30e8211..1e43115d0 100644 --- a/examples/outpost/README.md +++ b/examples/outpost/README.md @@ -36,7 +36,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources diff --git a/examples/secondary-cidr-blocks/README.md b/examples/secondary-cidr-blocks/README.md index 08764e25c..29c70c2e2 100644 --- a/examples/secondary-cidr-blocks/README.md +++ b/examples/secondary-cidr-blocks/README.md @@ -32,7 +32,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources diff --git a/examples/simple-vpc/README.md b/examples/simple-vpc/README.md index 03494351c..7e87d1c36 100644 --- a/examples/simple-vpc/README.md +++ b/examples/simple-vpc/README.md @@ -36,7 +36,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources diff --git a/examples/vpc-flow-logs/README.md b/examples/vpc-flow-logs/README.md index 4dba2069b..503ccfc1f 100644 --- a/examples/vpc-flow-logs/README.md +++ b/examples/vpc-flow-logs/README.md @@ -39,10 +39,10 @@ Note that this example may create resources which can cost money (AWS Elastic IP | Name | Source | Version | |------|--------|---------| | [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 1.0 | -| [vpc\_with\_flow\_logs\_cloudwatch\_logs](#module\_vpc\_with\_flow\_logs\_cloudwatch\_logs) | ../../ | | -| [vpc\_with\_flow\_logs\_cloudwatch\_logs\_default](#module\_vpc\_with\_flow\_logs\_cloudwatch\_logs\_default) | ../../ | | -| [vpc\_with\_flow\_logs\_s3\_bucket](#module\_vpc\_with\_flow\_logs\_s3\_bucket) | ../../ | | -| [vpc\_with\_flow\_logs\_s3\_bucket\_parquet](#module\_vpc\_with\_flow\_logs\_s3\_bucket\_parquet) | ../../ | | +| [vpc\_with\_flow\_logs\_cloudwatch\_logs](#module\_vpc\_with\_flow\_logs\_cloudwatch\_logs) | ../../ | n/a | +| [vpc\_with\_flow\_logs\_cloudwatch\_logs\_default](#module\_vpc\_with\_flow\_logs\_cloudwatch\_logs\_default) | ../../ | n/a | +| [vpc\_with\_flow\_logs\_s3\_bucket](#module\_vpc\_with\_flow\_logs\_s3\_bucket) | ../../ | n/a | +| [vpc\_with\_flow\_logs\_s3\_bucket\_parquet](#module\_vpc\_with\_flow\_logs\_s3\_bucket\_parquet) | ../../ | n/a | ## Resources diff --git a/examples/vpc-separate-private-route-tables/README.md b/examples/vpc-separate-private-route-tables/README.md index d25bcb04d..1f85170c3 100644 --- a/examples/vpc-separate-private-route-tables/README.md +++ b/examples/vpc-separate-private-route-tables/README.md @@ -32,7 +32,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [vpc](#module\_vpc) | ../../ | | +| [vpc](#module\_vpc) | ../../ | n/a | ## Resources From 1335ae038af7f923442961418fa21e8907b00b6d Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 22 Nov 2021 10:10:14 -0500 Subject: [PATCH 2/3] fix: ensure pre-commit uses https --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcee530b4..ed391bc9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - - repo: git://github.com/antonbabenko/pre-commit-terraform + - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.58.0 hooks: - id: terraform_fmt @@ -20,7 +20,7 @@ repos: - '--args=--only=terraform_required_providers' - '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_workspace_remote' - - repo: git://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 hooks: - id: check-merge-conflict From 5bd88a215eeb3b21fd905e262037276db84334dd Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 22 Nov 2021 10:44:47 -0500 Subject: [PATCH 3/3] fix: correct pre-commit hook for terraform-docs --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed391bc9f..b0e03fc88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,8 @@ repos: - id: terraform_fmt - id: terraform_validate - id: terraform_docs + args: + - '--args=--lockfile=false' - id: terraform_tflint args: - '--args=--only=terraform_deprecated_interpolation'