-
Notifications
You must be signed in to change notification settings - Fork 9
239 lines (207 loc) · 7.58 KB
/
test-harness.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Liquibase Test Harness for BigQuery
on:
pull_request_target:
branches:
- '*'
push:
branches:
- 'main'
- 'master'
paths:
- 'src/test/resources/terraform/**'
workflow_dispatch:
env:
tf_version: 'latest'
permissions:
contents: write
pull-requests: write
jobs:
authorize:
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
setup:
needs: authorize
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
SPACELIFT_API_KEY_ENDPOINT: ${{ secrets.SPACELIFT_API_KEY_ENDPOINT }}
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
TF_TOKEN_spacelift_io: ${{ secrets.SPACELIFT_API_TOKEN }}
GOOGLE_IMPERSONATE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_IMPERSONATE_SERVICE_ACCOUNT }}
defaults:
run:
working-directory: src/test/resources/terraform
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
# This action will queue the workflow if another workflow is already running
- uses: ahmadnassri/action-workflow-queue@v1
with:
timeout: 3000000 # 30 minutes
delay: 300000 # 5 minutes
- name: configure auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: set GCP project
id: config_project
run: gcloud config set project testharnesstests
- name: Install spacectl
uses: spacelift-io/setup-spacectl@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Terraform Format
if: ${{ github.event_name == 'pull_request' }}
id: terraform_fmt
run: terraform fmt
- name: Terraform Init
id: terraform_init
run: terraform init
- name: Terraform Validate
if: ${{ github.event_name == 'pull_request' }}
id: terraform_validate
run: terraform validate -no-color
- name: Preview infrastructure
run: |
spacectl stack local-preview --id liquibase-bigquery-testharness-tests > ${GITHUB_WORKSPACE}/plan.out
cat ${GITHUB_WORKSPACE}/plan.out
- name: Deploy infrastructure
#if: ${{ github.event_name == 'push' }}
run: |
spacectl stack set-current-commit --id liquibase-bigquery-testharness-tests --sha ${{ github.sha }}
spacectl stack deploy --id liquibase-bigquery-testharness-tests --auto-confirm
test:
name: Run Test Harness
runs-on: ubuntu-latest
needs: [setup]
strategy:
max-parallel: 1
matrix:
liquibase-support-level: [Contributed, Foundational, Advanced] # Define the different test levels to run
fail-fast: false # Set fail-fast to false to run all test levels even if some of them fail
env:
github-token: ${{ secrets.LIQUIBOT_PAT_GPM_ACCESS }}
permissions:
contents: 'read'
id-token: 'write'
checks: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
#look for dependencies in maven
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: |
[
{
"id": "liquibase",
"url": "https://maven.pkg.github.com/liquibase/liquibase",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- name: configure auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Run ${{ matrix.liquibase-support-level }} Liquibase Test Harness # Run the Liquibase test harness at each test level
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.PRO_LICENSE_KEY }} # Set the environment variable for the Liquibase Pro license key
run: |
mvn -Dtest=liquibase.ext.bigquery.${{ matrix.liquibase-support-level }}HarnessSuiteIT test # Run the Liquibase test harness at each test level
- name: Test Reporter # Generate a test report using the Test Reporter action
uses: dorny/[email protected]
if: always() # Run the action even if the previous steps fail
with:
name: Liquibase Test Harness - ${{ matrix.liquibase-support-level }} Reports # Set the name of the test report
path: target/surefire-reports/TEST-*.xml # Set the path to the test report files
reporter: java-junit # Set the reporter to use
fail-on-error: false # Set fail-on-error to false to show report even if it has failed tests
- name: Archive Bigquery Database Test Results
uses: actions/upload-artifact@v3
with:
name: bigquery-test-results
path: target/surefire-reports
- name: Test Summary
uses: test-summary/action@v2
with:
paths: "target/surefire-reports/**/TEST-*.xml"
if: always()
destroy:
runs-on: ubuntu-latest
needs: [setup,test]
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
SPACELIFT_API_KEY_ENDPOINT: ${{ secrets.SPACELIFT_API_KEY_ENDPOINT }}
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
TF_TOKEN_spacelift_io: ${{ secrets.SPACELIFT_API_TOKEN }}
GOOGLE_IMPERSONATE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_IMPERSONATE_SERVICE_ACCOUNT }}
defaults:
run:
working-directory: src/test/resources/terraform
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
- name: configure auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: set GCP project
id: config_project
run: gcloud config set project testharnesstests
- name: Install spacectl
uses: spacelift-io/setup-spacectl@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Terraform Init
id: terraform_init
run: terraform init
- name: Terraform Destroy
id: terraform_destroy
run: |
spacectl stack task -id liquibase-bigquery-testharness-tests -tail terraform destroy -auto-approve