generated from giis-uniovi/samples-giis-template
-
Notifications
You must be signed in to change notification settings - Fork 2
234 lines (218 loc) · 10.2 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
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_CASSANDRA_PWD: ${RANDOM}${RANDOM}${RANDOM}
TEST_MYSQL_PWD: ${RANDOM}${RANDOM}${RANDOM}
jobs:
test-transform:
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/')))
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Test transform module and aggregate surefire report
run: mvn test -Dtest=* -pl modevo-transform -am -Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: Additional aggregated junit report
uses: javiertuya/junit-report-action@v1
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target/site
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v5
with:
check_name: "test-result-transform"
report_paths: "**/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: always()
name: Publish test report files
uses: actions/upload-artifact@v4
with:
name: "test-report-files-transform"
path: |
target/site
**/target/site/jacoco/jacoco.xml
**/target/surefire-reports
test-script:
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/')))
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
# Starts the DBMS containers when applicable
- name: Launch Cassandra
run: |
docker run --name test-cassandra -d -p 9042:9042 \
-v ${GITHUB_WORKSPACE}/modevo-script/dat/inp/creationSchema.cql:/creationSchema.cql \
-e JVM_OPTS="-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0" \
cassandra:4.1.4
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-cassandra 1 "Created default superuser role"
docker exec test-cassandra cqlsh localhost 9042 -u cassandra -p cassandra -f creationSchema.cql
- name: Test and aggregate surefire report
run: mvn test -Dtest=!TestTransform* -pl modevo-script -am -Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: Additional aggregated junit report
uses: javiertuya/junit-report-action@v1
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target/site
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v5
with:
check_name: "test-result-script"
report_paths: "**/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: always()
name: Publish test report files
uses: actions/upload-artifact@v4
with:
name: "test-report-files-script"
path: |
target/site
**/target/site/jacoco/jacoco.xml
**/target/surefire-reports
verify-consistency:
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/')))
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Initialize MySQL database
run: |
docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=rootpassword -d -p 3306:3306 mysql:9.0
chmod u+x setup/wait-container-ready.sh
./setup/wait-container-ready.sh test-mysql 2 "ready for connections. Version:"
docker exec -i test-mysql sh -c "exec mysql -uroot -prootpassword" < ./setup/custom.sql
docker exec -i test-mysql sh -c "exec mysql -uroot -prootpassword" < ./setup/minds.sql
docker exec -i test-mysql sh -c "exec mysql -uroot -prootpassword" < ./setup/wire.sql
docker exec -i test-mysql sh -c "exec mysql -uroot -prootpassword" < ./setup/thingsboard.sql
docker exec -i test-mysql sh -c "exec mysql -uroot -prootpassword" < ./setup/thingsboard2.sql
- name: Initialize Cassandra database
run: |
docker run --name test-cassandra -d -p 9042:9042 \
-v ${GITHUB_WORKSPACE}/modevo-script/dat/inp/creationSchema.cql:/creationSchema.cql \
-e JVM_OPTS="-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0" \
cassandra:4.1.4
chmod u+x setup/wait-container-ready.sh
./setup/wait-container-ready.sh test-cassandra 1 "Created default superuser role"
docker exec test-cassandra cqlsh localhost 9042 -u cassandra -p cassandra -f creationSchema.cql
- name: Test and aggregate surefire report
run: mvn test -Dtest=!TestTransform,!TestExecutionScript -pl modevo-consistency -am -Dmaven.test.failure.ignore=true -Dsurefire.failIfNoSpecifiedTests=false -U --no-transfer-progress
- name: Additional aggregated junit report
uses: javiertuya/junit-report-action@v1
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target/site
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v5
with:
check_name: "verify-result-consistency"
report_paths: "**/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: always()
name: Publish test report files
uses: actions/upload-artifact@v4
with:
name: "verify-report-files-consistency"
path: |
target/site
**/target/site/jacoco/jacoco.xml
**/target/surefire-reports
sonarqube:
needs: [test-transform, test-script, verify-consistency]
#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: actions/[email protected]
if: always()
with:
name: "test-report-files-transform"
- uses: actions/[email protected]
if: always()
with:
name: "test-report-files-script"
- uses: actions/[email protected]
if: always()
with:
name: "verify-report-files-consistency"
- 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/upload-artifact@v4
with:
name: "test-report-ALL"
path: |
target-ALL/site
**/target/surefire-reports
**/target/*.html
**/target/*.log
**/reports/*.html
**/reports/*.log
- uses: javiertuya/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
restore-artifact-name1: "test-report-files-script"
restore-artifact-name2: "test-report-files-transform"
restore-artifact-name3: "verify-report-files-consistency"
publish-java-snapshot:
if: ${{ false }} # disable for now
#avoid publishing PRs and dependabot branches
#if: ${{ github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/heads/dependabot/') && !startsWith(github.ref, 'refs/heads/dashgit/combined/') }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: javiertuya/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
java-version: '17'
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: 2
always-keep-regex: "\\d*\\.\\d*\\.\\d*-main-SNAPSHOT$"