Skip to content

Commit

Permalink
feat: Runs Migration tests for different provider versions (#1691)
Browse files Browse the repository at this point in the history
* run migration tests first, passing '' for default TF version

* provider_version param

* reduce migration test name so it fits better in GH UI

* adjust job name for latest version

* use provider version if not empty

* fix variable use

* remove unneeded steps

* add tf version 1.1.6

* change logic to get provider version

* reorder MONGODB_ATLAS_LAST_VERSION

* read input provide version only in one place

This reverts commit 25ce77e.
  • Loading branch information
lantoli authored Dec 1, 2023
1 parent e910b23 commit 31ffd15
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
63 changes: 31 additions & 32 deletions .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ on:
description: 'Terraform version to use, empty for latest'
type: string
required: false
provider_version:
description: 'MongoDB Atlas Provider 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
provider_version:
description: 'MongoDB Atlas Provider 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 ]

Expand All @@ -25,6 +33,21 @@ env:
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}

jobs:
get-provider-version:
runs-on: ubuntu-latest
outputs:
provider_version: ${{ inputs.provider_version || steps.get_last_release.outputs.last_provider_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Release
id: get_last_release
shell: bash
run: |
LAST_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/terraform-provider-mongodbatlas/releases/latest | jq -r '.tag_name | ltrimstr("v")')
echo "Last release: $LAST_RELEASE"
echo "last_provider_version=$LAST_RELEASE" >> $GITHUB_OUTPUT
change-detection:
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -57,19 +80,12 @@ jobs:
- 'internal/service/advancedcluster/*.go'
project:
needs: [ change-detection ]
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.project == 'true' || github.event.label.name == 'run-testacc-project'|| needs.change-detection.outputs.shouldTriggerResourceTest == 'true'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Release
id: get_last_release
run: |
LAST_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/terraform-provider-mongodbatlas/releases/latest | jq -r '.tag_name | ltrimstr("v")')
echo "Last release: $LAST_RELEASE"
echo "MONGODB_ATLAS_LAST_VERSION=$LAST_RELEASE" >> $GITHUB_ENV
shell: bash
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand All @@ -86,23 +102,17 @@ jobs:
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ vars.MONGODB_ATLAS_PROJECT_OWNER_ID }}
MONGODB_ATLAS_TEAMS_IDS: ${{ vars.MONGODB_ATLAS_TEAMS_IDS }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationProject"
run: make testacc

config:
needs: [ change-detection ]
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.config == 'true' || github.event.label.name == 'run-testacc-config'|| needs.change-detection.outputs.shouldTriggerResourceTest == 'true'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Release
id: get_last_release
run: |
LAST_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/terraform-provider-mongodbatlas/releases/latest | jq -r '.tag_name | ltrimstr("v")')
echo "Last release: $LAST_RELEASE"
echo "MONGODB_ATLAS_LAST_VERSION=$LAST_RELEASE" >> $GITHUB_ENV
shell: bash
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand All @@ -122,23 +132,17 @@ jobs:
AZURE_ATLAS_APP_ID: ${{vars.AZURE_ATLAS_APP_ID}}
AZURE_SERVICE_PRINCIPAL_ID: ${{vars.AZURE_SERVICE_PRINCIPAL_ID}}
AZURE_TENANT_ID: ${{vars.AZURE_TENANT_ID}}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationConfig"
run: make testacc

backup_online_archive:
needs: [ change-detection ]
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.backup_online_archive == 'true' || github.event.label.name == 'run-testacc-backup-online-archive'|| needs.change-detection.outputs.shouldTriggerResourceTest == 'true'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Release
id: get_last_release
run: |
LAST_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/terraform-provider-mongodbatlas/releases/latest | jq -r '.tag_name | ltrimstr("v")')
echo "Last release: $LAST_RELEASE"
echo "MONGODB_ATLAS_LAST_VERSION=$LAST_RELEASE" >> $GITHUB_ENV
shell: bash
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand All @@ -154,23 +158,17 @@ jobs:
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV }}
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ vars.MONGODB_ATLAS_PROJECT_OWNER_ID }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationBackup"
run: make testacc

advanced_cluster:
needs: [ change-detection ]
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.advanced_cluster == 'true' || github.event.label.name == 'run-testacc-advanced-cluster'|| needs.change-detection.outputs.shouldTriggerResourceTest == 'true'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Release
id: get_last_release
run: |
LAST_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/terraform-provider-mongodbatlas/releases/latest | jq -r '.tag_name | ltrimstr("v")')
echo "Last release: $LAST_RELEASE"
echo "MONGODB_ATLAS_LAST_VERSION=$LAST_RELEASE" >> $GITHUB_ENV
shell: bash
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand All @@ -185,5 +183,6 @@ jobs:
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY_CLOUD_DEV }}
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV }}
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationAdvancedCluster"
run: make testacc
26 changes: 13 additions & 13 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ on:
- cron: "0 2 * * *" # workflow runs every day at 02:00 AM

jobs:
acc-tests:

mig-tests:
strategy:
max-parallel: 1
fail-fast: false
matrix:
terraform_version: ['${{ vars.TF_VERSION_LATEST }}', '1.0.8']
name: acc-tests-${{ matrix.terraform_version }}
terraform_version: ['', '1.1.6', '1.0.8'] # '' for latest version
provider_version: ['', '1.11.1'] # '' for latest version
name: mig-tests-${{ matrix.terraform_version || 'latest' }}-${{ matrix.provider_version || 'latest' }}
secrets: inherit
permissions:
contents: write
pull-requests: read
repository-projects: read
uses: ./.github/workflows/acceptance-tests.yml
uses: ./.github/workflows/migration-tests.yml
with:
terraform_version: ${{ matrix.terraform_version }}
provider_version: ${{ matrix.provider_version }}

migration-tests:
needs: acc-tests
acc-tests:
needs: mig-tests
if: ${{ !cancelled() }} # run acc tests even if mig tests fail
strategy:
max-parallel: 1
fail-fast: false
matrix:
terraform_version: ['${{ vars.TF_VERSION_LATEST }}', '1.0.8']
name: migration-tests-${{ matrix.terraform_version }}
terraform_version: ['', '1.1.6', '1.0.8'] # '' for latest version
name: acc-tests-${{ matrix.terraform_version || 'latest' }}
secrets: inherit
uses: ./.github/workflows/migration-tests.yml
uses: ./.github/workflows/acceptance-tests.yml
with:
terraform_version: ${{ matrix.terraform_version }}

0 comments on commit 31ffd15

Please sign in to comment.