-
Notifications
You must be signed in to change notification settings - Fork 1.9k
328 lines (293 loc) · 11.7 KB
/
run-tests.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
name: Run Tests
on:
workflow_call:
workflow_dispatch:
inputs:
archive_test_results:
description: 'If set to true, the unit and integration test results will be archived to the build artifacts page.'
required: false
default: 'false'
push:
branches:
- master
pull_request_target:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**.md'
jobs:
authorize:
#concurrent runs for pull requests from forked repositories will be canceled, while runs for pull requests from the master repository won't be affected.
#for a pull_request against master: the concurrency check will cancel commit A so that commit B check can run.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref == 'master' && (github.event_name == 'push' && 'push-to-master' || github.event_name == 'pull_request' && 'merge-to-master') || github.event_name == 'pull_request_target' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.base_ref == 'master' }}
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-20.04
outputs:
timestamp: ${{ steps.get-date.outputs.date }}
latestMergeSha: ${{ steps.get-sha.outputs.latestMergeSha }}
thisBranchName: ${{ steps.get-branch-name.outputs.thisBranchName }}
setupSuccessful: "true"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Get current date
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT
- name: Get Latest Merge Commit SHA
id: get-sha
run: |
latest_merge_sha=`(git rev-parse HEAD)`
echo "latestMergeSha=${latest_merge_sha}" >> $GITHUB_OUTPUT
- name: Get Current BranchName
id: get-branch-name
run: |
# this logic checks if the branch is from a forked repository PR or not. Where -n is the inverse of -z (not empty)
if [ -n "${GITHUB_HEAD_REF}" ];
then
branch_name=${GITHUB_HEAD_REF}
else
branch_name=${{ github.ref_name }}
fi
modified_branch_name=`(echo $branch_name | tr '/_' '-')`
echo "thisBranchName=$modified_branch_name" >> $GITHUB_OUTPUT
echo $modified_branch_name
build_tests:
name: Run Test for (Java ${{ matrix.java }} ${{ matrix.os }})
needs: setup
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-latest, windows-2019 ]
java: [ 8, 11, 17, 21 ]
exclude:
# exclude non-java 8 on macos and windows builds
- os: macos-latest
java: 11
- os: windows-2019
java: 11
- os: macos-latest
java: 17
- os: windows-2019
java: 17
- os: macos-latest
java: 21
- os: windows-2019
java: 21
runs-on: ${{ matrix.os }}
env:
OS_TYPE: ${{ matrix.os }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Built Code Cache
if: ${{ matrix.java == 17}}
uses: actions/[email protected]
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
# 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 }}"
}
]
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Build & Test Java 8
if: ${{ matrix.java == 8}}
run: |
./mvnw -B "-Dbuild.repository.owner=liquibase" "-Dbuild.repository.name=liquibase" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.latestMergeSha }}" "-DtrimStackTrace=false" -P 'skip-integration-tests' -pl '!liquibase-cdi-jakarta' clean test package surefire-report:report
- name: Build & Test Java non-jdk-8
if: ${{ matrix.java != 8}}
run: |
./mvnw -B "-Dbuild.repository.owner=liquibase" "-Dbuild.repository.name=liquibase" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.latestMergeSha }}" "-DtrimStackTrace=false" -P 'skip-integration-tests' clean test package surefire-report:report
- name: Remove Original Jars for *nix
if: env.OS_TYPE != 'windows-2019'
run: |
find . -name original-*.jar -exec rm {} \;
- name: Upload Artifacts for build.yml
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: temp-artifact
path: |
./**/target/*.jar
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: liquibase-test-results-jdk${{ matrix.java }}
path: |
./**/target/surefire-reports
./**/target/site
- name: Save Jacoco Report for Sonar
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-jacoco-test-results
path: |
./liquibase-standard/target/jacoco.exec
- name: Archive Modules
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-modules
path: |
*/target/*-0-SNAPSHOT.jar
integration-test:
name: Integration Test
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
testSystem:
- db2
- h2
#- h2:1.4
- hsqldb
- mariadb
- mssql
- mysql
- oracle
- postgresql
- sqlite
- firebird
needs: build_tests
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Prepare
id: prepare
uses: actions/github-script@v7
with:
script: |
core.setOutput("testResultsArtifact", "liquibase-test-results-integration-${{ matrix.testSystem }}".replace(/[^a-zA-Z0-9\-_]/g, "_"));
- name: Set up JDK 17
if: ${{ matrix.testSystem != 'snowflake' }}
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Set up JDK 11 # get rid of this after https://github.com/snowflakedb/snowflake-jdbc/issues/589 is fixed
if: ${{ matrix.testSystem == 'snowflake' }}
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Restore Built Code Cache
uses: actions/[email protected]
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Setup Python
if: ${{ matrix.testSystem == 'snowflake' }}
uses: actions/[email protected]
with:
python-version: '3.12.1'
- name: Start & Configure LocalStack
if: ${{ matrix.testSystem == 'snowflake' }}
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
pip install localstack awscli-local
DEBUG=1 DOCKER_FLAGS='-e SF_LOG=trace' IMAGE_NAME=localstack/snowflake localstack start -d
echo "Waiting for LocalStack startup..."
localstack wait -t 30
echo "Startup complete"
echo "TH_DB_ADMIN=test" >> $GITHUB_ENV
echo "TH_DB_PASSWD=test" >> $GITHUB_ENV
echo "TH_DB=snowflake" >> $GITHUB_ENV
echo "TH_SNOW_URL=jdbc:snowflake://http://snowflake.localhost.localstack.cloud:4566" >> $GITHUB_ENV
- name: Run Tests
run: ./mvnw -B clean verify -DtrimStackTrace=false -Dliquibase.sdk.testSystem.test=${{ matrix.testSystem }} -Dliquibase.sdk.testSystem.acceptLicenses=${{ matrix.testSystem }} -Dliquibase.sdk.testSystem.snowflake.url=${{ env.TH_SNOW_URL }} -Dliquibase.sdk.testSystem.snowflake.username=${{ env.TH_DB_ADMIN }} -Dliquibase.sdk.testSystem.snowflake.password=${{ env.TH_DB_PASSWD }} -Dtest=*IntegrationTest,*ExecutorTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.prepare.outputs.testResultsArtifact }}
path: |
./**/target/surefire-reports
- name: Save Jacoco Report for Sonar
uses: actions/upload-artifact@v3
with:
name: liquibase-integration-jacoco-test-results-${{ matrix.testSystem }}
path: |
./liquibase-integration-tests/target/jacoco.exec
sonar:
needs: [ build_tests, integration-test ]
uses: liquibase/build-logic/.github/workflows/[email protected]
with:
thisBranchName: ${{ needs.setup.outputs.thisBranchName }}
thisSha: ${{ needs.setup.outputs.thisSha }}
liquibaseBranchName: ${{ needs.setup.outputs.liquibaseBranchName }}
pullRequestNumber: ${{ github.event.pull_request.number }}
pullRequestBranchName: ${{ github.event.pull_request.head.ref }}
pullRequestBaseBranchName: ${{ github.event.pull_request.base.ref }}
testedClassesModuleName: liquibase-standard
dbPlatforms: h2,hsqldb,mariadb,mssql,mysql,oracle,postgresql,sqlite,firebird,db2
secrets: inherit
run-build-publish-file:
needs: [ build_tests,integration-test ]
uses: liquibase/liquibase/.github/workflows/build.yml@master
secrets: inherit