generated from giis-uniovi/samples-giis-template
-
Notifications
You must be signed in to change notification settings - Fork 0
336 lines (311 loc) · 14.1 KB
/
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
name: test-all
on:
push:
branches-ignore:
- 'dependabot/**' #avoid duplicates: only run the PR, not the commit
- 'gh-pages' #github pages do not trigger all tests
tags-ignore:
- 'v*' #avoid rerun existing commit on release
pull_request:
branches:
- 'main'
env:
TEST_POSTGRES_PWD: ${RANDOM}${RANDOM}${RANDOM}
#sqlserver must comply with password requirements (upper, lower, digit, symbol)
TEST_SQLSERVER_PWD: ${RANDOM}Ax.${RANDOM}${RANDOM}
TEST_ORACLE_PWD: ${RANDOM}${RANDOM}${RANDOM}
TEST_SQLITE_PWD: ""
jobs:
test-java:
runs-on: ubuntu-latest
#if: ${{ false }} # disable for now
#avoids duplicate execution of pr from local repo, but allows pr from forked repos and dependabot
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/')))
strategy:
matrix:
scope: [Core, Postgres, Sqlserver, Oracle]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
# Starts the DBMS containers when applicable
- name: Launch Postgres
if: ${{ matrix.scope == 'Postgres' }}
run: |
docker run -d -p 5432:5432 --name test-postgres --restart unless-stopped \
-e POSTGRES_PASSWORD="$TEST_POSTGRES_PWD" \
-e TEST_POSTGRES_PWD="$TEST_POSTGRES_PWD" \
-v ${GITHUB_WORKSPACE}/setup/postgres:/docker-entrypoint-initdb.d \
postgres:14
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-postgres "END SETUP!"
- name: Launch Sqlserver
if: ${{ matrix.scope == 'Sqlserver' }}
run: |
docker stop test-sqlserver && docker rm test-sqlserver
docker run -d -p 1433:1433 --name test-sqlserver --restart unless-stopped \
-e SA_PASSWORD="$TEST_SQLSERVER_PWD" \
-e TEST_SQLSERVER_PWD="$TEST_SQLSERVER_PWD" \
-e "ACCEPT_EULA=Y" -e "MSSQL_PID=Developer" \
-v ${GITHUB_WORKSPACE}/setup/sqlserver:/setup.d \
mcr.microsoft.com/mssql/server:2017-latest
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-sqlserver "SQL Server is now ready for client connections"
# SQLServer does not have an on startup script, run it now
docker exec test-sqlserver bash -c "chmod u+x setup.d/sqlserver-setup.sh && ./setup.d/sqlserver-setup.sh"
- name: Launch Oracle
if: ${{ matrix.scope == 'Oracle' }}
run: |
docker run -d -p 1521:1521 --name test-oracle --restart unless-stopped \
-e ORACLE_PASSWORD=$TEST_ORACLE_PWD \
-e TEST_ORACLE_PWD="$TEST_ORACLE_PWD" \
-v ${GITHUB_WORKSPACE}/setup/oracle:/container-entrypoint-initdb.d \
gvenzl/oracle-xe:11.2.0.2-slim-faststart
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-oracle "DATABASE IS READY TO USE!"
# Run the tests, a step for those that use a DBMS, other for core
- name: Test and aggregate surefire report - ${{ matrix.scope }}
if: ${{ matrix.scope == 'Core' }}
run: >
mvn test surefire-report:report -Daggregate=true
-Dtest=!TestPostgres*,!TestSqlserver*,!TestOracle*
-Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: Test and aggregate surefire report - ${{ matrix.scope }}
if: ${{ matrix.scope != 'Core' }}
run: >
mvn test surefire-report:report -Daggregate=true
-Dtest=Test${{ matrix.scope }}* -pl tdrules-client-rdb,tdrules-store-rdb -am -Dsurefire.failIfNoSpecifiedTests=false
-Dmaven.test.failure.ignore=true -U --no-transfer-progress
-Duser.timezone=Europe/Madrid
# NOTE: must specify a timezone to avoid oracle error ORA-01882: timezone region not found
- name: Additional aggregated junit report
if: always()
uses: javiertuya/[email protected]
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target/site
report-title: "Test Report: ${{ matrix.scope }} - Branch: ${{ github.ref_name }}"
- name: Generate report checks
if: always()
uses: mikepenz/[email protected]
with:
check_name: "test-result-${{ matrix.scope }}"
report_paths: "**/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: always()
name: Set unique jacoco.xml file names for each scope
#if not sonarqube will overwrite al jacoco files generated for the same module but different scopes
run: |
for file in */target/site/jacoco/jacoco.xml ; do mv $file ${file//jacoco.xml/jacoco-${{ matrix.scope }}.xml} ; done
ls -la */target/site/jacoco/*.xml
- name: Publish test report files
if: always()
uses: actions/[email protected]
with:
name: "test-report-files-${{ matrix.scope }}"
path: |
target/site
**/target/site/jacoco/jacoco*.xml
**/target/surefire-reports
**/target/*.html
**/target/*.log
test-net:
runs-on: ubuntu-latest
#if: ${{ false }} # disable for now
#avoids duplicate execution of pr from local repo, but allows pr from forked repos and dependabot
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/')))
defaults:
run:
working-directory: net
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
dotnet-version: '6.0.x'
- name: Launch Sqlserver
run: |
docker stop test-sqlserver && docker rm test-sqlserver
docker run -d -p 1433:1433 --name test-sqlserver --restart unless-stopped \
-e SA_PASSWORD="$TEST_SQLSERVER_PWD" \
-e TEST_SQLSERVER_PWD="$TEST_SQLSERVER_PWD" \
-e "ACCEPT_EULA=Y" -e "MSSQL_PID=Developer" \
-v ${GITHUB_WORKSPACE}/setup/sqlserver:/setup.d \
mcr.microsoft.com/mssql/server:2017-latest
chmod u+x ../setup/wait-container-ready.sh && ../setup/wait-container-ready.sh test-sqlserver "SQL Server is now ready for client connections"
# SQLServer does not have an on startup script, run it now
docker exec test-sqlserver bash -c "chmod u+x setup.d/sqlserver-setup.sh && ./setup.d/sqlserver-setup.sh"
- name: Run test
run: dotnet test --logger "trx;LogFileName=../../reports/tdrules-report.trx" TdRulesTest/TdRulesTest.csproj
- name: Junit html report
if: always()
uses: javiertuya/[email protected]
with:
net-trx-report: "net/reports/tdrules-report.trx"
net-surefire-folder: "net/target/surefire-reports"
surefire-files: "net/target/surefire-reports/TEST-*.xml"
report-dir: net/target/site
report-title: "Test Report: Net - Branch: ${{ github.ref_name }}"
- name: Generate report checks
if: always()
uses: mikepenz/[email protected]
with:
check_name: "test-result-Net"
report_paths: "net/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- name: Publish test report files
if: always()
uses: actions/upload-artifact@v3
with:
name: "test-report-files-Net"
path: |
net/target/site
net/target/surefire-reports
net/reports/tdrules-report.trx
net/reports/*.html
net/reports/*.log
# As a last step, checks that conversion works to detect potential incompatible changes in the java side.
# Note that updates on the java side are still made in the develop environment and pushed.
- name: Validate Sharpen Conversion - Prepare Java envrionment
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Validate Sharpen Conversion - Preprocess
if: always()
run: |
mvn -f ../pom.xml generate-sources -am
ant clean sharpen.preprocess
- name: Validate Sharpen Conversion - Sharpen
uses: javiertuya/[email protected]
with:
working-dir: net
project-dir: sharpen-temp/java
sharpen-args: '@sharpen-all-options.txt'
- name: Validate Sharpen Conversion - Postprocess
if: always()
run: |
ls -la sharpen-temp/sharpen-temp.net
sudo chown -R $(id -u):$(id -g) sharpen-temp/sharpen-temp.net
ant sharpen.postprocess sharpen.openapi
dotnet build
test-report:
needs: [test-java, test-net]
#if: ${{ false }} # disable for now
#avoid publishing to Github pages PRs and dependabot branches
if: ${{ always() && github.event_name != 'pull_request' && !contains('/head/refs/dependabot/', github.ref) }}
runs-on: ubuntu-latest
# Configuration to deploy at github pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Downloads java test report files
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-Core"
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-Postgres"
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-Sqlserver"
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-Oracle"
# Net reports were zipped under a different root, specifies the path.
# Modifies the namespaces to allow differentiate from the java test results
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-Net"
path: "net"
- if: always()
run: sed -i 's/Test4giis/Test4NET/g' net/target/surefire-reports/*
# Generates and uploads the html reports and the individual surefire reports for further reference
- name: Aggregated junit html report
if: always()
uses: javiertuya/[email protected]
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target-ALL/site
report-title: "Test Report: ALL - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}"
- name: Index file to html reports
run: |
echo "<html><head><title>Latest Test Reports</title></head><body>" > target-ALL/site/index.html
echo "<h2>Latest Test Reports - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}</h2>" >> target-ALL/site/index.html
echo "<p><a href=\"junit-noframes/junit-noframes.html\">Single page reports</a></p>" >> target-ALL/site/index.html
echo "<p><a href=\"junit-frames/index.html\">Multiple page reports with frames</a></p>" >> target-ALL/site/index.html
echo "</body></html>" >> target-ALL/site/index.html
- if: always()
name: Publish test report files
uses: actions/[email protected]
with:
name: "test-report-ALL"
path: |
target-ALL/site
**/target/surefire-reports
**/target/*.html
**/target/*.log
**/reports/*.html
**/reports/*.log
# Deploy to GitHub Pages
# Some files (e.g. junit reports) have 600 permissions.
# As of [email protected], permissions must be set explicitly
# to 0755 (as indicated in warnings produced by v1.0.8)
- name: Fix permissions to actions/[email protected]
run: sudo chmod -c -R 0755 target-ALL/site
- name: Upload artifact
if: always()
uses: actions/[email protected]
with:
path: 'target-ALL/site'
- name: Deploy to GitHub Pages
if: always()
id: deployment
uses: actions/[email protected]
sonarqube:
needs: [test-java]
#if: ${{ false }} # disable for now
#This job fails when comming from a dependabot PR (can't read the sonarqube token for security reasons).
#Links to discussions and workaround at: https://github.com/giis-uniovi/samples-giis-template/issues/4
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: javiertuya/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
restore-artifact-name1: "test-report-files-Core"
restore-artifact-name2: "test-report-files-Sqlserver"
restore-artifact-name3: "test-report-files-Postgres"
restore-artifact-name4: "test-report-files-Oracle"
publish-java-snapshot:
#if: ${{ false }} # disable for now
#avoid publishing PRs and dependabot branches
if: ${{ github.event_name != 'pull_request' && !contains('/head/refs/dependabot/', github.ref) }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: javiertuya/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
java-version: '11'
mvn-deploy-args: '-P publish-github -DskipTests=true -Dmaven.test.failure.ignore=false -U --no-transfer-progress'
delete-old-snapshots: true
min-snapshots-to-keep: 4
always-keep-regex: "\\d*\\.\\d*\\.\\d*-main-SNAPSHOT$"