Skip to content

Test Suite

Test Suite #757

Workflow file for this run

name: 'Test Suite'
# Runs acceptance and migrations tests with a set of terraform versions and provider versions (used for migration tests).
# This worflow is scheduled daily and runs against dev every day except for Sunday when we run against QA.
# It can also be run manually.
# The 1st day of the month we run terraform-compatibility-matrix.yml and therefore, we skip the test-suite (see shedule->cron below).
on:
workflow_dispatch:
inputs:
terraform_matrix:
description: 'Terraform version matrix (JSON array)'
default: '["1.13.x","1.12.x","1.11.x","1.10.x","1.9.x","1.8.x","1.7.x","1.6.x"]'
provider_matrix:
description: 'Previous MongoDB Atlas Provider version matrix for migration tests (JSON array)'
default: '[""]' # "" for latest version
send_notification:
description: 'Send the Slack notification if any of the tests fail.'
type: boolean
default: false
use_sa:
description: "Run tests using Service Account instead of API Keys"
type: boolean
required: false
workflow_call:
inputs:
terraform_matrix:
description: 'Terraform version matrix (JSON array)'
type: string
provider_matrix:
description: 'Previous MongoDB Atlas Provider version matrix for migration tests (JSON array)'
type: string
default: '[""]' # "" for latest version
atlas_cloud_env:
description: 'Atlas cloud environment used, can be either `dev` or `qa`, empty for `dev`'
type: string
required: false
send_notification:
description: 'Send the Slack notification if any of the tests fail.'
type: boolean
default: true
schedule:
- cron: "0 0 2-31 * *" # workflow runs every day at midnight UTC except on the first day of the month
concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: false
jobs:
variables:
env:
schedule_terraform_matrix: '["1.13.x"]'
schedule_provider_matrix: '[""]' # "" for latest version
runs-on: ubuntu-latest
outputs:
terraform_matrix: ${{ inputs.terraform_matrix || env.schedule_terraform_matrix }}
provider_matrix: ${{ inputs.provider_matrix || env.schedule_provider_matrix }}
is_sun: ${{ steps.set_day.outputs.DAY == 'Sun' }}
steps:
- name: set day
id: set_day
run: |
echo "DAY=$(date +'%a')"
echo "DAY=$(date +'%a')" >> "$GITHUB_OUTPUT"
clean-before:
secrets: inherit
uses: ./.github/workflows/cleanup-test-env.yml
tests:
needs: [clean-before, variables]
if: ${{ !cancelled() }}
strategy:
max-parallel: 1
fail-fast: false
matrix:
terraform_version: ${{ fromJSON(needs.variables.outputs.terraform_matrix) }}
provider_version: ${{ fromJSON(needs.variables.outputs.provider_matrix) }}
name: ${{ matrix.terraform_version || 'latest' }}-${{ matrix.provider_version || 'latest' }}-${{ inputs.use_sa && 'sa' || 'pak' }}
secrets: inherit
uses: ./.github/workflows/acceptance-tests.yml
with:
terraform_version: ${{ matrix.terraform_version }}
provider_version: ${{ matrix.provider_version }}
atlas_cloud_env: ${{ inputs.atlas_cloud_env || needs.variables.outputs.is_sun == 'true' && 'qa' || '' }} # Run against QA on Sundays
use_sa: ${{ inputs.use_sa || false }}
clean-after:
needs: tests
if: ${{ !cancelled() }}
secrets: inherit
uses: ./.github/workflows/cleanup-test-env.yml
slack-notification:
needs: [tests, clean-after]
if: ${{ !cancelled() && needs.tests.result == 'failure' && !contains(github.event.inputs.send_notification, 'false') }}
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Send Slack message
id: slack
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "Test Suite failed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "❌ *Test Suite failed* ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Failed Action>"
}
}
]
}