Skip to content

Commit

Permalink
feat: Runs Acceptance and Migration tests for different Terraform CLI…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
lantoli authored Nov 30, 2023
1 parent 2273d6b commit 866d5b0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 26 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ 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
TF_ACC: 1
SKIP_TEST_EXTERNAL_CREDENTIALS: true
TF_LOG: ${{ vars.LOG_LEVEL }}
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}

jobs:
change-detection:
runs-on: ubuntu-latest
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/code-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

14 changes: 10 additions & 4 deletions .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ 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
TF_ACC: 1
SKIP_TEST_EXTERNAL_CREDENTIALS: true
TF_LOG: ${{ vars.LOG_LEVEL }}
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}

jobs:
change-detection:
runs-on: ubuntu-latest
Expand Down
41 changes: 31 additions & 10 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
Expand Down

0 comments on commit 866d5b0

Please sign in to comment.