From e25535049c7d96f101e67685aabcadf923497ca6 Mon Sep 17 00:00:00 2001 From: Samuel Wibrow <15628653+swibrow@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:41:08 +0200 Subject: [PATCH] feat!: remove concurrency groups and adjust tests (#131) --- .github/pull_request_template.md | 2 +- .github/workflows/_test-tf.yaml | 17 ++++++++++++++--- .github/workflows/aws-secrets-copy.yaml | 3 --- .github/workflows/tf-apply.yaml | 8 +++----- .github/workflows/tf-cleanup.yaml | 3 --- .github/workflows/tf-destroy.yaml | 1 + .github/workflows/tf-feature.yaml | 5 +---- .github/workflows/tf-plan.yaml | 8 +++----- tests/terraform/s3/main.tf | 5 ++++- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2542af63..38fb86fc 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,5 +15,5 @@ - [ ] I have executed `pre-commit run -a` on my pull request -- [ ] I have executed `gen_docs_run` on my pull request +- [ ] I have executed `make gen_docs_run` on my pull request diff --git a/.github/workflows/_test-tf.yaml b/.github/workflows/_test-tf.yaml index 662ab7d7..cd8399c4 100644 --- a/.github/workflows/_test-tf.yaml +++ b/.github/workflows/_test-tf.yaml @@ -29,13 +29,11 @@ jobs: run: echo "${{ fromJson(needs.test_tf_feature.outputs.tf_outputs).random_pet }}" test_tf_plan: - needs: test_tf_feature uses: ./.github/workflows/tf-plan.yaml with: environment: sandbox test_tf_apply: - needs: test_tf_plan uses: ./.github/workflows/tf-apply.yaml with: environment: sandbox @@ -48,6 +46,19 @@ jobs: environment: sandbox tf_workspace: test/slash/replacement + test_tf_plan_no_environment: + uses: ./.github/workflows/tf-plan.yaml + with: + aws_account_id: 911453050078 + aws_region: eu-central-1 + aws_role_name: cicd-iac + tf_dir: tests/terraform/s3 + tf_backend_configs: | + bucket=tf-state-911453050078 + key=sandbox1.tfstate + workspace_key_prefix=github-workflows + tf_var_files: tests/terraform/s3/environment/sandbox.tfvars + test_upload_artifact: runs-on: ubuntu-latest steps: @@ -69,7 +80,7 @@ jobs: file_path="artifact-sample.txt" test_tf_artifact_all: - needs: test_tf_artifact + needs: test_upload_artifact uses: ./.github/workflows/tf-plan.yaml with: environment: sandbox diff --git a/.github/workflows/aws-secrets-copy.yaml b/.github/workflows/aws-secrets-copy.yaml index 741d11c4..32c77407 100644 --- a/.github/workflows/aws-secrets-copy.yaml +++ b/.github/workflows/aws-secrets-copy.yaml @@ -40,9 +40,6 @@ jobs: id-token: write contents: read pull-requests: write - concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.destination_aws_oidc_role_arn }}-${{ inputs.destination_secret_name}} - cancel-in-progress: true steps: - name: Configure Source AWS credentials uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4 diff --git a/.github/workflows/tf-apply.yaml b/.github/workflows/tf-apply.yaml index 3fee3278..5bc9f694 100644 --- a/.github/workflows/tf-apply.yaml +++ b/.github/workflows/tf-apply.yaml @@ -56,12 +56,10 @@ jobs: contents: read id-token: write pull-requests: write - concurrency: - group: ${{ github.workflow }}-${{ inputs.environment }} - cancel-in-progress: false runs-on: ubuntu-latest environment: ${{ inputs.environment }} env: + ENVIRONMENT: ${{ inputs.environment }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TF_DIR: ${{ inputs.tf_dir || vars.tf_dir || '.' }} TF_BACKEND_CONFIGS: ${{ inputs.tf_backend_configs || vars.tf_backend_configs }} @@ -103,7 +101,7 @@ jobs: eval "${{ inputs.tf_pre_run }}" fi with: - label: ${{ inputs.environment }} + label: ${{ env.ENVIRONMENT }} path: ${{ env.TF_DIR}} backend_config: ${{ env.TF_BACKEND_CONFIGS }} backend_config_file: ${{ env.TF_BACKEND_CONFIG_FILES }} @@ -115,6 +113,6 @@ jobs: if: steps.tf_apply.outputs != '' uses: tx-pts-dai/action-summary@v0.0.2 with: - summary_header: "Terraform Outputs" + summary_header: "Terraform Outputs | ${{ env.ENVIRONMENT}}" string: ${{ toJson(steps.tf_apply.outputs) }} data_type: "json" diff --git a/.github/workflows/tf-cleanup.yaml b/.github/workflows/tf-cleanup.yaml index cff729c2..7dced1b7 100644 --- a/.github/workflows/tf-cleanup.yaml +++ b/.github/workflows/tf-cleanup.yaml @@ -47,9 +47,6 @@ jobs: contents: read id-token: write pull-requests: write - concurrency: - group: ${{ github.workflow }}-${{ inputs.environment }} - cancel-in-progress: false runs-on: ubuntu-latest environment: ${{ inputs.environment }} env: diff --git a/.github/workflows/tf-destroy.yaml b/.github/workflows/tf-destroy.yaml index 4ba70e2a..36b8da60 100644 --- a/.github/workflows/tf-destroy.yaml +++ b/.github/workflows/tf-destroy.yaml @@ -44,6 +44,7 @@ jobs: runs-on: ubuntu-latest environment: ${{ inputs.environment || null }} env: + ENVIRONMENT: ${{ inputs.environment }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TF_DIR: ${{ inputs.tf_dir || vars.tf_dir || '.' }} TF_BACKEND_CONFIGS: ${{ inputs.tf_backend_configs || vars.tf_backend_configs }} diff --git a/.github/workflows/tf-feature.yaml b/.github/workflows/tf-feature.yaml index 6d9cf45b..2bee9197 100644 --- a/.github/workflows/tf-feature.yaml +++ b/.github/workflows/tf-feature.yaml @@ -56,9 +56,6 @@ jobs: contents: read id-token: write pull-requests: write - concurrency: - group: ${{ github.workflow }}-${{ inputs.environment }} - cancel-in-progress: false runs-on: ubuntu-latest environment: ${{ inputs.environment }} env: @@ -130,6 +127,6 @@ jobs: if: steps.tf_apply.outputs != '' uses: tx-pts-dai/action-summary@v0.0.2 with: - summary_header: "Terraform Outputs" + summary_header: "Terraform Outputs | ${{ env.ENVIRONMENT}}" string: ${{ toJson(steps.tf_apply.outputs) }} data_type: "json" diff --git a/.github/workflows/tf-plan.yaml b/.github/workflows/tf-plan.yaml index bb911b80..cd703849 100644 --- a/.github/workflows/tf-plan.yaml +++ b/.github/workflows/tf-plan.yaml @@ -56,12 +56,10 @@ jobs: contents: read id-token: write pull-requests: write - concurrency: - group: ${{ github.workflow }}-${{ inputs.environment }} - cancel-in-progress: false runs-on: ubuntu-latest environment: ${{ inputs.environment }} env: + ENVIRONMENT: ${{ inputs.environment }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TF_DIR: ${{ inputs.tf_dir || vars.tf_dir || '.' }} TF_BACKEND_CONFIGS: ${{ inputs.tf_backend_configs || vars.tf_backend_configs }} @@ -117,7 +115,7 @@ jobs: eval "${{ inputs.tf_pre_run }}" fi with: - label: ${{ inputs.environment}} + label: ${{ env.ENVIRONMENT }} add_github_comment: ${{ inputs.gh_comment }} path: ${{ env.TF_DIR}} backend_config: ${{ env.TF_BACKEND_CONFIGS }} @@ -129,6 +127,6 @@ jobs: if: github.event_name == 'pull_request' uses: tx-pts-dai/action-summary@v0.0.2 with: - summary_header: "Terraform Plan" + summary_header: "Terraform Plan | ${{ env.ENVIRONMENT}} " path: ${{ steps.plan.outputs.text_plan_path }} data_type: "terraform" diff --git a/tests/terraform/s3/main.tf b/tests/terraform/s3/main.tf index ac9afd88..9162dc9e 100644 --- a/tests/terraform/s3/main.tf +++ b/tests/terraform/s3/main.tf @@ -1,5 +1,8 @@ terraform { - backend "s3" {} + backend "s3" { + dynamodb_table = "terraform-lock" + region = "eu-central-1" + } } resource "random_pet" "this" {