-
Notifications
You must be signed in to change notification settings - Fork 17
352 lines (314 loc) · 13.4 KB
/
main.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Basic workflow with Actions
name: Default Test Execution
on:
# Triggers the workflow on push & pull request events for the main branch. Also allows for manual triggers
push:
branches: [ main, develop ]
pull_request:
types:
- opened
- reopened
- synchronize
schedule:
- cron: '0 6 * * *' # Execute every day at noon
workflow_dispatch:
inputs:
distinct_id:
description: 'distinct id for the triggered run from OSS'
required: false
runDescription:
description: 'Description of run'
required: false
runDetails:
description: 'JSON details of run. Provided by automation'
required: false
liquibaseBranch:
description: Liquibase branch to pull artifacts from. Leave empty to use latest commit on current branch. For forks, use the `owner:branch` format. Can support a comma separated list of branches to search for
required: false
liquibaseCommit:
description: Liquibase commit to pull artifacts from. Leave empty to use "liquibaseBranch" setting.
required: false
testClasses:
type: choice
description: Test Suite or test class to run
options:
- LiquibaseHarnessSuiteTest
- FoundationalHarnessSuiteTest
- AdvancedHarnessSuiteTest
- ChangeObjectTests
- ChangeDataTests
- SnapshotObjectTests
- GenerateChangelogTest
- FoundationalTest
ignoreLiquibaseSnapshot:
type: boolean
description: Don't autoconfigure Liquibase Snapshot
liquibaseRepo:
description: Repo pull artifacts from. Defaults to liquibase/liquibase but also supports liquibase/liquibase-pro
required: true
default: "liquibase/liquibase"
databases:
description: Databases to start up. Comma separated list of "name"
required: true
default: |
[
"mysql-5.6",
"mysql-5.7",
"mysql-8",
"percona-xtradb-cluster-5.7",
"percona-xtradb-cluster-8.0",
"postgres-12",
"postgres-13",
"postgres-14",
"postgres-15",
"postgres-16",
"mariadb-10.2",
"mariadb-10.3",
"mariadb-10.4",
"mariadb-10.5",
"mariadb-10.6",
"mariadb-10.7",
"mssql-2017",
"mssql-2019",
"mssql-2022",
"H2Database-2.2",
"crdb-23.1",
"crdb-23.2",
"crdb-24.1",
"edb-postgres-12",
"edb-postgres-13",
"edb-postgres-14",
"edb-postgres-15",
"edb-edb-12",
"edb-edb-13",
"edb-edb-14",
"edb-edb-15",
"derby",
"sqlite",
"hsqldb-2.4",
"hsqldb-2.5",
"firebird-3",
"firebird-4",
"db2-luw"
]
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:
name: Setup
needs: authorize
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
outputs:
liquibaseOwner: ${{ steps.configure-build.outputs.liquibaseOwner }}
liquibaseBranch: ${{ steps.configure-build.outputs.liquibaseBranch }}
liquibaseRepo: ${{ steps.configure-build.outputs.liquibaseRepo }}
liquibaseSha: ${{ steps.configure-build.outputs.liquibaseSha }}
databases: ${{ github.event.inputs.databases || '["mysql-5.6","mysql-5.7","mysql-8","percona-xtradb-cluster-5.7","percona-xtradb-cluster-8.0",
"postgres-12","postgres-13","postgres-14","postgres-15","postgres-16","mariadb-10.2","mariadb-10.3","mariadb-10.4","mariadb-10.5","mariadb-10.6",
"mariadb-10.7","mssql-2017","mssql-2019","mssql-2022","H2Database-2.2","crdb-23.1","crdb-23.2","crdb-24.1",
"edb-postgres-12","edb-postgres-13","edb-postgres-14","edb-postgres-15",
"edb-edb-12","edb-edb-13","edb-edb-14","edb-edb-15","derby","sqlite","hsqldb-2.4","hsqldb-2.5","firebird-3","firebird-4","db2-luw"]' }}
testClasses: ${{ inputs.testClasses || 'LiquibaseHarnessSuiteTest' }}
steps:
- uses: actions/checkout@v4
#https://github.com/Codex-/return-dispatch
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- name: Configure Build
id: configure-build
uses: actions/[email protected]
with:
github-token: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
let testBranchName = helper.getCurrentBranch();
console.log("Running in liquibase-test-harness branch " + testBranchName);
core.notice("Running in liquibase-test-harness branch " + testBranchName);
console.log("liquibaseBranch == " + "${{ github.event.inputs.liquibaseBranch }}");
core.setOutput("liquibaseBranch", "${{ github.event.inputs.liquibaseBranch }}" || testBranchName+", master");
console.log("liquibaseRepo == " + "${{ github.event.inputs.liquibaseRepo }}");
core.setOutput("liquibaseRepo", "${{ github.event.inputs.liquibaseRepo }}" || "liquibase/liquibase");
let liquibaseRepo = "${{ github.event.inputs.liquibaseRepo || 'liquibase/liquibase' }}";
let repoOwnerName = liquibaseRepo.split("/")[0]
let repoName = liquibaseRepo.split("/")[1]
let liquibaseBranchName = "${{ github.event.inputs.liquibaseBranch }}";
let liquibaseSha = "${{ github.event.inputs.liquibaseCommit }}";
if (!liquibaseSha) {
if (!liquibaseBranchName) {
liquibaseBranchName = testBranchName;
}
console.log("No liquibaseSha passed. Looking for branch "+liquibaseBranchName);
let liquibaseBranchResponse = await helper.findMatchingBranch(repoOwnerName, repoName, [liquibaseBranchName, "master", "main"]);
liquibaseSha = liquibaseBranchResponse.sha;
}
core.setOutput("liquibaseSha", liquibaseSha);
core.setOutput("liquibaseOwner", repoOwnerName);
let runDescription = "${{ github.event.inputs.runDescription }}";
if (!runDescription) {
runDescription = "None given";
}
core.notice("Triggered by this OSS PR: " + runDescription);
let runDetails = null;
if (context.payload && context.payload.inputs && context.payload.inputs.runDetails) {
runDetails = JSON.parse(context.payload.inputs.runDetails);
}
if (!runDetails) {
runDetails = {};
}
if (runDetails.notices) {
for (let notice of runDetails.notices) {
core.notice(notice);
}
}
- 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": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Install Snapshot Liquibase
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
run: |
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
mvn -B liquibase-sdk:install-snapshot \
"-Dliquibase.sdk.branchSearch=${{ steps.configure-build.outputs.liquibaseBranch }},master,main,develop" \
"-Dliquibase.sdk.repo=liquibase/liquibase,liquibase/liquibase-pro" \
"-Dliquibase.sdk.proWorkflowId=build.yml"\
"-Dliquibase.sdk.workflowId=run-tests.yml"
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
mvn liquibase-sdk:install-snapshot-cli \
"-Dliquibase.sdk.branchSearch=${{ steps.configure-build.outputs.liquibaseBranch }},master,main,develop" \
"-Dliquibase.sdk.repo=liquibase/liquibase,liquibase/liquibase-pro" \
"-Dliquibase.sdk.proWorkflowId=build.yml" \
"-Dliquibase.sdk.workflowId=run-tests.yml"
chmod -R 777 bin
ls -l ./bin
bin/liquibase --version
buildOverview="$(mvn -B -q liquibase-sdk:get-build-info '-Dliquibase.sdk.buildInfo.outputKey=overview' '-Dliquibase.sdk.repo=liquibase/liquibase')"
echo "::notice :: Installed Snapshot Liquibase $buildOverview"
buildOverview="$(mvn -B -q liquibase-sdk:get-build-info '-Dliquibase.sdk.buildInfo.outputKey=overview' '-Dliquibase.sdk.repo=liquibase/liquibase-pro')"
echo "::notice :: Installed Snapshot Liquibase-pro $buildOverview"
- name: Cache installed Liquibase
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/liquibase/
key: mvn-liquibase-${{ github.run_id }}-${{ github.run_attempt }}
test:
runs-on: ubuntu-20.04
needs: [ setup, authorize ]
strategy:
fail-fast: false
matrix:
database: ${{ fromJson(needs.setup.outputs.databases) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Cache installed Liquibase
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/liquibase/
key: mvn-liquibase-${{ github.run_id }}-${{ github.run_attempt }}
- name: Build ${{ matrix.database }} test infra
working-directory: src/test/resources/docker
run: ./create-infra.sh ${{ matrix.database }}
env:
REPO_URL: ${{ secrets.REPO_URL }}
REPO_USER: ${{ secrets.REPO_USER }}
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
- name: Configure Liquibase Version
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
run: |
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
- name: ${{ matrix.database }} Test Run
run: ./src/test/resources/automation-runner.sh ${{ matrix.database }} ${{ needs.setup.outputs.testClasses }}
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
- name: Archive ${{ matrix.database }} test results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.database }}-test-results
path: build/spock-reports
# GitHub Actions has its own cleanup and this might be redundant
- name: Tear down ${{ matrix.database }} test infra
working-directory: src/test/resources/docker
run: ./teardown-infra.sh ${{ matrix.database }}
finish:
name: Finish
runs-on: ubuntu-22.04
needs: [ setup, test, authorize ]
if: ${{ always() }}
steps:
- uses: actions/checkout@v4
- name: Coordinate Liquibase-Test-Harness
uses: actions/[email protected]
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
console.log("result is ${{ needs.test.result }}");
let result = "success"
if ("${{ needs.test.result }}" != "success") {
result = "failure";
}
console.log("Mark tests as "+result);
await github.rest.repos.createCommitStatus({
"owner": "${{ needs.setup.outputs.liquibaseOwner }}",
"repo": "liquibase",
"sha": "${{ needs.setup.outputs.liquibaseSha }}",
"state": result,
"context": "Run Test-Harness Tests",
"description": "Test-Harness tests complete",
"target_url": "https://github.com/liquibase/liquibase-test-harness/actions/runs/${{ github.run_id }}"
});