-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Updates migration tests to run separately and use last released version of provider for plan checks #1565
Changes from 9 commits
30dbcd7
5747e2e
4dd4e1a
316afdf
b8a83f9
89333ab
08c1f51
857de3e
11cf6fe
599b74b
b3a07f7
0ea6a6a
4b1e27a
a5fb8fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: 'Migration Tests' | ||
|
||
on: | ||
workflow_dispatch: {} # workflow can be run manually | ||
workflow_call: # workflow runs after code-health | ||
inputs: | ||
parent-event-name: | ||
required: true | ||
type: string | ||
pull_request: # you can run a specic job in your PR using GitHub labels | ||
maastha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
types: [ labeled ] | ||
|
||
jobs: | ||
change-detection: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
repository-projects: read | ||
outputs: | ||
project: ${{ steps.filter.outputs.project }} | ||
config: ${{ steps.filter.outputs.config }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || inputs.parent-event-name == 'release' }} | ||
- uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
filters: | | ||
project: | ||
- 'mongodbatlas/fw_data_source_mongodbatlas_project_ip_access_list*.go' | ||
- 'mongodbatlas/fw_resource_mongodbatlas_project_ip_access_list*.go' | ||
config: | ||
- 'mongodbatlas/fw_data_source_mongodbatlas_alert_configuration*.go' | ||
- 'mongodbatlas/fw_data_source_mongodbatlas_database_user*.go' | ||
- 'mongodbatlas/fw_data_source_mongodbatlas_atlas_user*.go' | ||
- 'mongodbatlas/fw_resource_mongodbatlas_alert_configuration*.go' | ||
- 'mongodbatlas/fw_resource_mongodbatlas_database_user*.go' | ||
|
||
project: | ||
needs: [ change-detection ] | ||
if: ${{ needs.change-detection.outputs.project == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc-migration' || github.event.label.name == 'run-testacc-project-migration' || inputs.parent-event-name == 'release' }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i know we have this in other gh actions but I wonder if we could make this easier or have some functions or something There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we could start fixing this file and then a follow-up to change the others? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lantoli I couldn't find a way to make this reusable or use a function, is there any example or reference you could share? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about the best way, but for instance what about creating a variable in the workflow and use the variable? something like: on: ... env: job... and use: if: ${{ env.hasToTrigger }} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or use it for the common part and then: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this doesn't hold a static value, rather holds a condition, i don't believe this is possible to do via a variable as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i suppose it's possible while you use variables that are know before starting execution There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed, see comment #1565 (comment) |
||
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: | ||
go-version-file: 'go.mod' | ||
- name: Migration Tests | ||
env: | ||
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY_CLOUD_DEV }} | ||
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_PROJECT_OWNER_ID: ${{ vars.MONGODB_ATLAS_PROJECT_OWNER_ID }} | ||
MONGODB_ATLAS_API_KEYS_IDS: ${{ vars.MONGODB_ATLAS_API_KEYS_IDS }} | ||
MONGODB_ATLAS_TEAMS_IDS: ${{ vars.MONGODB_ATLAS_TEAMS_IDS }} | ||
SKIP_TEST_EXTERNAL_CREDENTIALS: ${{ vars.SKIP_TEST_EXTERNAL_CREDENTIALS }} | ||
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }} | ||
TF_LOG: ${{ vars.LOG_LEVEL }} | ||
TF_ACC: 1 | ||
PARALLEL_GO_TEST: 20 | ||
CI: true | ||
TEST_REGEX: "^TestAccMigrationProject" | ||
run: make testacc | ||
|
||
config: | ||
needs: [ change-detection ] | ||
if: ${{ needs.change-detection.outputs.config == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc-migration' || github.event.label.name == 'run-testacc-config-migration' || inputs.parent-event-name == 'release' }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
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: | ||
go-version-file: 'go.mod' | ||
- name: Migration Tests | ||
env: | ||
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY_CLOUD_DEV_NETWORK }} | ||
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY_CLOUD_DEV_NETWORK }} | ||
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV_NETWORK }} | ||
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }} | ||
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ vars.MONGODB_ATLAS_PROJECT_OWNER_ID }} | ||
SKIP_TEST_EXTERNAL_CREDENTIALS: ${{ vars.SKIP_TEST_EXTERNAL_CREDENTIALS }} | ||
MONGODB_ATLAS_USERNAME_CLOUD_DEV: ${{ vars.MONGODB_ATLAS_USERNAME_CLOUD_DEV }} | ||
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}} | ||
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }} | ||
TF_LOG: ${{ vars.LOG_LEVEL }} | ||
TF_ACC: 1 | ||
PARALLEL_GO_TEST: 20 | ||
CI: true | ||
TEST_REGEX: "^TestAccMigrationConfig" | ||
run: make testacc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally, thanks! :-)