-
Notifications
You must be signed in to change notification settings - Fork 3
425 lines (387 loc) · 16.1 KB
/
pro-extension-test.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
name: Build and Test Pro Extension
on:
workflow_call:
inputs:
java:
description: "Java version to test"
required: false
default: "[11, 17, 21]"
type: string
os:
description: "Operating system to build/test on"
required: false
default: '["ubuntu-latest", "windows-latest"]'
type: string
os-test:
description: "Operating system to test on"
required: false
default: '["ubuntu-latest", "windows-latest"]'
type: string
nightly:
description: "Specifies nightly builds against liquibase master-SNAPSHOT"
required: false
default: false
type: boolean
extraCommand:
description: "Specify it if you want to run an extra command before attaching the artifact. This runs on both Linux and Windows runners."
required: false
default: ""
type: string
extraLinuxCommand:
description: "Specify it if you want to run an extra command before attaching the artifact on Linux."
required: false
default: ""
type: string
extraWindowsCommand:
description: "Specify it if you want to run an extra command before attaching the artifact on Windows."
required: false
default: ""
type: string
extraMavenArgs:
description: "Specify it if you want to run an extra maven argument"
required: false
default: ""
type: string
mavenProfiles:
description: "Specify it if you want to run different Maven profiles from the default (coverage). mavenProfiles example: 'coverage,run-proguard'"
required: false
default: "coverage"
type: string
artifactPath:
description: "Specify the path to the artifacts that should be attached to the build. Useful for multi-module extensions."
required: false
default: "."
type: string
combineJars:
description: "Specify it if you want to combine the built jars into a single jar"
required: false
default: false
type: boolean
secrets:
SONAR_TOKEN:
description: "SONAR_TOKEN from the caller workflow"
required: true
PRO_LICENSE_KEY:
description: "PRO_LICENSE_KEY from the caller workflow"
required: true
GHA_AWS_KEY_ID:
description: "GHA_AWS_KEY_ID from the caller workflow"
required: true
GHA_AWS_KEY:
description: "GHA_AWS_KEY from the caller workflow"
required: true
env:
AWS_REGION: us-east-1
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.PRO_LICENSE_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.GHA_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GHA_AWS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_VERSION: "3.9.5"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: ${{fromJson(inputs.os || '["ubuntu-latest"]')}}
name: Build & Package - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
cache: "maven"
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
# 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": "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 }}"
}
]
- name: Run extra command
if: inputs.extraCommand != ''
run: |
${{ inputs.extraCommand }}
- name: Run extra Linux command
if: inputs.extraLinuxCommand != '' && runner.os == 'Linux'
shell: bash
run: |
${{ inputs.extraLinuxCommand }}
- name: Run extra Windows Command
if: inputs.extraWindowsCommand != '' && runner.os == 'Windows'
shell: powershell
run: |
${{ inputs.extraWindowsCommand }}
- name: Build and Package latest liquibase version
if: ${{ inputs.nightly }}
shell: bash
run: mvn -B dependency:go-offline clean package -DskipTests=true "-Dliquibase.version=master-SNAPSHOT"
- name: Notify Slack on Build Failure
if: ${{ failure() && inputs.nightly }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "View details on GitHub Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} <@U042HRTL4DT>"
SLACK_TITLE: "❌ ${{ github.repository }} ❌ Build failed on branch ${{ github.ref }} for commit ${{ github.sha }} in repository ${{github.repository}}"
SLACK_USERNAME: liquibot
SLACK_WEBHOOK: ${{ secrets.NIGHTLY_BUILDS_SLACK_WEBHOOK }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_FOOTER: "${{ github.repository }}"
SLACK_LINK_NAMES: true
- name: Build and Package
if: ${{ !inputs.nightly }}
shell: bash
run: |
if [ -n "${{ inputs.extraMavenArgs }}" ]; then
mvn -B dependency:go-offline clean package -DskipTests=true ${{ inputs.extraMavenArgs }}
else
mvn -B dependency:go-offline clean package -DskipTests=true
fi
- name: Get Artifact ID
working-directory: ${{ inputs.artifactPath }}
id: get-artifact-id
shell: bash
run: echo "::set-output name=artifact_id::$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)"
- name: Get Artifact Version
working-directory: ${{ inputs.artifactPath }}
id: get-artifact-version
shell: bash
run: echo "::set-output name=artifact_version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
- name: Save Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get-artifact-id.outputs.artifact_id }}-${{ matrix.os }}-${{ steps.get-artifact-version.outputs.artifact_version }}-artifacts
path: |
${{ inputs.artifactPath }}/target/*
- name: Save Event File
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}
outputs:
artifact_id: ${{ steps.get-artifact-id.outputs.artifact_id }}
artifact_version: ${{ steps.get-artifact-version.outputs.artifact_version }}
unit-test:
strategy:
fail-fast: false
matrix:
java: ${{fromJson(inputs.java || '[8, 11, 17, 18]')}}
os: ${{fromJson(inputs.os-test || '["ubuntu-latest", "windows-latest"]')}}
name: Test Java ${{ matrix.java }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: build
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "temurin"
cache: "maven"
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
# 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": "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/download-artifact@v3
with:
name: ${{needs.build.outputs.artifact_id}}-${{ matrix.os }}-${{needs.build.outputs.artifact_version}}-artifacts
path: ./target
- name: Run extra command
if: inputs.extraCommand != ''
run: |
${{ inputs.extraCommand }}
- name: Run extra Linux command
if: inputs.extraLinuxCommand != '' && runner.os == 'Linux'
run: |
${{ inputs.extraLinuxCommand }}
- name: Run extra Windows command
if: inputs.extraWindowsCommand != '' && runner.os == 'Windows'
run: |
${{ inputs.extraWindowsCommand }}
- name: Run Tests
if: ${{ !inputs.nightly }}
shell: bash
run: |
if [ -n "${{ inputs.extraMavenArgs }}" ]; then
mvn -B test -P '${{ inputs.mavenProfiles }}' "${{ inputs.extraMavenArgs }}"
else
mvn -B test -P '${{ inputs.mavenProfiles }}'
fi
- name: Run Tests
if: ${{ inputs.nightly }}
shell: bash
run: |
if [ -n "${{ inputs.extraMavenArgs }}" ]; then
mvn -B test -P '${{ inputs.mavenProfiles }}' "${{ inputs.extraMavenArgs }}" "-Dliquibase.version=master-SNAPSHOT"
else
mvn -B test -P '${{ inputs.mavenProfiles }}' "-Dliquibase.version=master-SNAPSHOT"
fi
- name: Notify Slack on Build Failure
if: ${{ failure() && inputs.nightly }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "View details on GitHub Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} <@U042HRTL4DT>"
SLACK_TITLE: "❌ ${{ github.repository }} ❌ Tests failed on branch ${{ github.ref }} for commit ${{ github.sha }} in repository ${{github.repository}}"
SLACK_USERNAME: liquibot
SLACK_WEBHOOK: ${{ secrets.NIGHTLY_BUILDS_SLACK_WEBHOOK }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_FOOTER: "${{ github.repository }}"
SLACK_LINK_NAMES: true
- name: Archive Test Results - ${{ matrix.os }}
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: test-reports-jdk-${{ matrix.java }}-${{ matrix.os }}
path: |
**/target/surefire-reports
**/target/site/jacoco/jacoco.xml
combineJars:
needs: [ build, unit-test ]
if: ${{ inputs.combineJars }}
name: Combine Jars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Download Ubuntu Artifacts
uses: actions/download-artifact@v3
with:
name: ${{needs.build.outputs.artifact_id}}-ubuntu-latest-${{needs.build.outputs.artifact_version}}-artifacts
path: /tmp/ubuntu
- name: Download macOS Artifacts
uses: actions/download-artifact@v3
with:
name: ${{needs.build.outputs.artifact_id}}-macos-latest-${{needs.build.outputs.artifact_version}}-artifacts
path: /tmp/macos
- name: Download Windows Artifacts
uses: actions/download-artifact@v3
with:
name: ${{needs.build.outputs.artifact_id}}-windows-latest-${{needs.build.outputs.artifact_version}}-artifacts
path: /tmp/windows
- name: Create multiplatform jar
run: |
rm -rf /tmp/combined/ubuntu /tmp/combined/windows /tmp/combined/macos
mkdir -p /tmp/combined/ubuntu /tmp/combined/windows /tmp/combined/macos
unzip -d /tmp/combined/ubuntu /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar
unzip -d /tmp/combined/windows /tmp/windows/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar
unzip -d /tmp/combined/macos /tmp/macos/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar
rm -r -f /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}
mkdir /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}
cp -a /tmp/combined/ubuntu/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/
cp -a /tmp/combined/windows/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/
cp -a /tmp/combined/macos/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/
rm /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/vfs/fileslist.txt
cat /tmp/combined/ubuntu/vfs/fileslist.txt /tmp/combined/windows/vfs/fileslist.txt /tmp/combined/macos/vfs/fileslist.txt > /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/vfs/fileslist.txt
rm -f /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar
cd /tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}/
zip -r ../${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar *
cd ..
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}-sources.jar /tmp/combined/
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}-javadoc.jar /tmp/combined/
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.pom /tmp/combined/
- name: Upload multiplatform artifact
uses: actions/upload-artifact@v3
with:
name: multiplatform-artifacts
path: |
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}-sources.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}-javadoc.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{needs.build.outputs.artifact_version}}.pom
sonar-pr:
if: ${{ !inputs.nightly }}
needs: [unit-test]
uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@main
secrets: inherit
with:
extraCommand: ${{ inputs.extraCommand }}
artifactPath: ${{ inputs.artifactPath }}