From 866d5b01f7a37e325f68823bf1f93c6597d68f89 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:45:32 +0100 Subject: [PATCH] feat: Runs Acceptance and Migration tests for different Terraform CLI versions (#1688) * only Test Suite is scheduled * run acc and migration tests for different TF CLI versions * fix matrix values * update release instructions * remove permissions section --- .github/workflows/acceptance-tests.yml | 12 ++++++-- .github/workflows/code-health.yml | 8 ----- .github/workflows/migration-tests.yml | 14 ++++++--- .github/workflows/test-suite.yml | 41 +++++++++++++++++++------- RELEASING.md | 2 +- 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index b43b602077..46f89303cc 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -5,12 +5,17 @@ on: inputs: terraform_version: description: 'Terraform version to use, empty for latest' + type: string + required: false + workflow_call: # workflow runs after Test Suite or code-health + inputs: + terraform_version: + description: 'Terraform version to use, empty for latest' + type: string required: false - workflow_call: # workflow runs after code-health pull_request: # you can run a specic job in your PR using GitHub labels types: [ labeled ] - schedule: - - cron: "0 4 * * *" # workflow runs every day at 04:00 AM + env: terraform_version: ${{ inputs.terraform_version || vars.TF_VERSION_LATEST }} # CI: true # GH does this automatically @@ -18,6 +23,7 @@ env: SKIP_TEST_EXTERNAL_CREDENTIALS: true TF_LOG: ${{ vars.LOG_LEVEL }} ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }} + jobs: change-detection: runs-on: ubuntu-latest diff --git a/.github/workflows/code-health.yml b/.github/workflows/code-health.yml index a90258d069..ac628d8fc7 100644 --- a/.github/workflows/code-health.yml +++ b/.github/workflows/code-health.yml @@ -91,17 +91,9 @@ jobs: call-acceptance-tests-workflow: needs: [build, lint, shellcheck, unit-test, website-lint] secrets: inherit - permissions: - contents: write - pull-requests: read - repository-projects: read uses: ./.github/workflows/acceptance-tests.yml call-migration-tests-workflow: needs: [build, lint, shellcheck, unit-test, website-lint] secrets: inherit - permissions: - contents: write - pull-requests: read - repository-projects: read uses: ./.github/workflows/migration-tests.yml diff --git a/.github/workflows/migration-tests.yml b/.github/workflows/migration-tests.yml index 8facbf105d..200e31bd31 100644 --- a/.github/workflows/migration-tests.yml +++ b/.github/workflows/migration-tests.yml @@ -5,12 +5,17 @@ on: inputs: terraform_version: description: 'Terraform version to use, empty for latest' + type: string required: false - workflow_call: # workflow runs after code-health - pull_request: + workflow_call: # workflow runs after Test Suite or code-health + inputs: + terraform_version: + description: 'Terraform version to use, empty for latest' + type: string + required: false + pull_request: # you can run a specic job in your PR using GitHub labels types: [ labeled ] - schedule: - - cron: "0 4 * * *" # workflow runs every day at 04:00 AM + env: terraform_version: ${{ inputs.terraform_version || vars.TF_VERSION_LATEST }} # CI: true # GH does this automatically @@ -18,6 +23,7 @@ env: SKIP_TEST_EXTERNAL_CREDENTIALS: true TF_LOG: ${{ vars.LOG_LEVEL }} ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }} + jobs: change-detection: runs-on: ubuntu-latest diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 00512ed1f3..0d0ac47ec3 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -2,14 +2,35 @@ name: 'Test Suite' on: workflow_dispatch: + schedule: + - cron: "0 2 * * *" # workflow runs every day at 02:00 AM + +jobs: + acc-tests: + strategy: + max-parallel: 1 + fail-fast: false + matrix: + terraform_version: ['${{ vars.TF_VERSION_LATEST }}', '1.0.8'] + name: acc-tests-${{ matrix.terraform_version }} + secrets: inherit + permissions: + contents: write + pull-requests: read + repository-projects: read + uses: ./.github/workflows/acceptance-tests.yml + with: + terraform_version: ${{ matrix.terraform_version }} -jobs: - example: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' + migration-tests: + needs: acc-tests + strategy: + max-parallel: 1 + fail-fast: false + matrix: + terraform_version: ['${{ vars.TF_VERSION_LATEST }}', '1.0.8'] + name: migration-tests-${{ matrix.terraform_version }} + secrets: inherit + uses: ./.github/workflows/migration-tests.yml + with: + terraform_version: ${{ matrix.terraform_version }} diff --git a/RELEASING.md b/RELEASING.md index eb49d79506..e0b63437ef 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -7,7 +7,7 @@ ## Steps ### Make sure that the acceptance tests are successful -Check [workflows/acceptance-tests.yml](https://github.com/mongodb/terraform-provider-mongodbatlas/actions/workflows/acceptance-tests.yml) and see if the latest run of the Acceptance Test action is successful (it runs every day at 4 AM Dublin Time). If tests are failing, you should investigate the failure before proceeding with the next steps. +Check [workflows/test-suite.yml](https://github.com/mongodb/terraform-provider-mongodbatlas/actions/workflows/test-suite.yml) and see if the latest run of the Test Suite action is successful (it runs every day at 2 AM Dublin Time). If tests are failing, you should investigate the failure before proceeding with the next steps. ### Pre-release the provider We pre-release the provider to make for testing purpose. **A Pre-release is not published to the Hashicorp Terraform Registry**.