-
Notifications
You must be signed in to change notification settings - Fork 1
270 lines (227 loc) · 7.72 KB
/
ubuntu-maven.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
name: Ubuntu Maven build
env:
MAVEN_OPTS: -Djava.awt.headless=true
MAVEN_VERSION: '3.9.8'
concurrency: # More info: https://stackoverflow.com/a/68422069/253468
group: ${{ github.workflow }}-${{ ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' ) && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: "16 23 * * 0"
jobs:
build:
name: Build w/ Java 17
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK
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 }}
- name: Priming build with Maven
run: mvn -B -V -fae -DskipTests -DskipITs -DskipQA=true install
- name: Test with Maven
run: |
mvn -B -fae -e test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build javadoc
run: mvn javadoc:javadoc
postgresql-test:
name: PostgreSQL verify
runs-on: ubuntu-latest
if: ${{ github.author != 'dependabot[bot]' }}
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up JDK
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 }}
- name: 'Login to b3p.nl'
uses: docker/login-action@v3
with:
registry: docker.b3p.nl
username: ${{ secrets.DOCKER_B3P_PULL_ACTOR }}
password: ${{ secrets.DOCKER_B3P_PULL_TOKEN }}
- name: 'Setup testdata databases'
run: ./build/ci/testdata-setup.sh
- name: Test PostgreSQL with Maven
run: mvn -B -fae -e -DskipQA=true -Pqa-skip -Ddocker.skip=true -Ppostgresql verify -Dspring-boot.run.profiles=dev,populate-testdata,postgresql -Dspring-boot.run.arguments=--spatial.dbs.connect=true
- name: 'Upload test results'
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results
path: |
target/failsafe-reports/TEST-*.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Upload event file so test results can be processed for the PR
# https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
site:
name: 'Publish gh-pages'
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') }}
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up JDK
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 }}
- name: 'Build Maven site'
env:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
run: mvn site
- name: 'Deploy gh-pages'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: target/site
publish:
name: Deploy artifacts
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
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 }}
- name: Build and Push
# no need to run any QC or tests
# note deploy will deploy both Maven artifact as well as Docker image
env:
B3P_DEPLOY_ACTOR: ${{ secrets.B3P_DEPLOY_ACTOR }}
B3P_DEPLOY_TOKEN: ${{ secrets.B3P_DEPLOY_TOKEN }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker run --privileged --rm tonistiigi/binfmt --install arm64
mvn -B -V -fae -DskipTests -DskipITs -DskipQA=true -Pqa-skip clean deploy --settings .github/maven-settings.xml
- name: 'Publish SBOM'
uses: DependencyTrack/gh-upload-sbom@v3
with:
serverhostname: ${{ secrets.DEPENDENCY_TRACK_HOSTNAME }}
apikey: ${{ secrets.DEPENDENCY_TRACK_APIKEY }}
project: '00501150-f4b1-4d75-a099-a6a9d1d8f06a'
bomfilename: 'target/classes/META-INF/sbom/application.cdx.json'
deploy:
name: Deploy stack
runs-on: ubuntu-latest
needs: publish
permissions:
actions: write
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Deploy compose stack
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GHCR_CLEANUP_PAT }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'tailormap',
repo: 'tailormap-viewer',
workflow_id: 'test-and-deploy.yml',
ref: 'main'
})
docker-test:
name: Test docker image
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'pull_request' }}
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: tailormap
POSTGRES_PASSWORD: tailormap
POSTGRES_DB: tailormap
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 15s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up JDK
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 }}
- name: Build docker image
run: mvn -B -V -fae -DskipTests -DskipITs -DskipQA=true -Pqa-skip package
- name: Try Created Docker image
run: |
docker run -d --name tailormap-api -h tailormap-api --network host ghcr.io/tailormap/tailormap-api:snapshot
sleep 60
docker logs tailormap-api
curl http://localhost:8080/api/actuator/health
curl http://localhost:8080/api/version
cleanup:
name: Maven cache cleanup
if: ${{ always() }}
needs: [ build, publish, postgresql-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: setup-java-Linux-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
setup-java-Linux-maven-
- name: Cleanup snapshot cache
run: |
find ~/.m2/repository -name "*SNAPSHOT*" -type d | xargs rm -rf {}