-
Notifications
You must be signed in to change notification settings - Fork 178
120 lines (112 loc) · 4.21 KB
/
test-suite.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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 except Saturdays, but can also be run manually.
on:
workflow_dispatch:
inputs:
terraform_matrix:
description: 'Terraform version matrix (JSON array)'
default: '["1.9.x", "1.8.x", "1.7.x", "1.6.x", "1.5.x", "1.4.x", "1.3.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
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:
versions:
env:
schedule_terraform_matrix: '["${{ vars.TF_VERSION_LATEST }}"]'
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 }}
steps:
- if: false
run: echo jobs need steps
clean-before:
secrets: inherit
uses: ./.github/workflows/cleanup-test-env.yml
tests:
needs: [clean-before, versions]
if: ${{ !cancelled() }}
strategy:
max-parallel: 1
fail-fast: false
matrix:
terraform_version: ${{ fromJSON(needs.versions.outputs.terraform_matrix) }}
provider_version: ${{ fromJSON(needs.versions.outputs.provider_matrix) }}
name: tests-${{ matrix.terraform_version || 'latest' }}-${{ matrix.provider_version || 'latest' }}
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 }}
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@70cd7be8e40a46e8b0eced40b0de447bdb42f68e
with:
payload: |
{
"text": ":red_circle: Test Suite failed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Test Suite failed* ${{ secrets.SLACK_ONCALL_TAG }}"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":github: Failed action"
},
"url": "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK