-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (183 loc) · 7.92 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
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'
jobs:
test:
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: [Petstore, Market, GestaoHospital, Eval]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Launch Petstore
if: ${{ matrix.scope == 'Petstore' }}
working-directory: ./sut-petstore
run: |
mvn package -q -DskipTests=true
docker build -t swagger-petstore .
docker run -d -p 8081:8080 --name swagger-petstore swagger-petstore
chmod u+x ../setup/wait-container-ready.sh
../setup/wait-container-ready.sh swagger-petstore "public ResponseContext findPetsByCategoryAndStatus"
- name: Launch Market
if: ${{ matrix.scope == 'Market' }}
working-directory: ./sut-market
run: |
#don't precompile, here, dockerfile does
docker build -t market-rest --build-arg module=market-rest .
docker build -t market-web --build-arg module=market-web .
docker compose -f docker-compose.yaml up -d
chmod u+x ../setup/wait-container-ready.sh
../setup/wait-container-ready.sh db "ready for start up"
../setup/wait-container-ready.sh market-rest "Started RestApplication"
- name: Launch GestaoHospital
if: ${{ matrix.scope == 'GestaoHospital' }}
working-directory: ./sut-gestaoHospital
run: |
mvn package -q -DskipTests=true
docker compose up -d --force-recreate --build
chmod u+x ../setup/wait-container-ready.sh
../setup/wait-container-ready.sh mongodb "HospitalDB.product_collection"
../setup/wait-container-ready.sh gestaohospital "Started GestaohospitalarApplication"
- run: docker ps
- name: Rules cache
id: rules-cache
uses: actions/[email protected]
with:
path: .tdrules-cache
key: cache-${{ matrix.scope }}-v1-${{ github.run_id }}
restore-keys: cache-${{ matrix.scope }}-v1-
- name: Test All SUTs
if: ${{ matrix.scope != 'Eval' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn test -pl st-tdg-test -Dtest=**/*${{ matrix.scope }}* -Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: Evaluate Mutation Score
if: ${{ matrix.scope == 'Eval' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -pl st-tdg-eval test -Dmaven.test.failure.ignore=true -U --no-transfer-progress
mvn -pl st-tdg-eval test-compile org.pitest:pitest-maven:mutationCoverage
- if: ${{ always() && matrix.scope == 'Petstore' }}
run: docker logs swagger-petstore > st-tdg-test/target/docker-petstore-server.log
- if: ${{ always() && matrix.scope == 'Market' }}
run: |
docker logs market-rest > st-tdg-test/target/docker-market-server.log
docker logs db > st-tdg-test/target/docker-market-db.log
- if: ${{ always() && matrix.scope == 'GestaoHospital' }}
run: |
docker logs gestaohospital > st-tdg-test/target/docker-gestaoHospital-server.log
docker logs mongodb > st-tdg-test/target/docker-gestaoHospital-db.log
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v5
with:
check_name: "test-result-${{ matrix.scope }}"
report_paths: "**/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- name: Publish test report files
if: always()
uses: actions/upload-artifact@v4
with:
name: "test-report-files-${{ matrix.scope }}"
path: |
**/target/site
**/target/surefire-reports
**/target/pit-reports
**/target/out
**/target/*.html
**/target/*.log
test-report:
needs: [test]
#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) && !contains('/head/refs/dashgit/combined/', 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 all artifacts with test report files
- uses: actions/[email protected]
if: always()
with:
path: .
- run: ls -la
# Generates and uploads the html reports and the individual surefire reports for further reference
# Includes the options to add links to Visual Assert diff files
- name: Aggregated junit html report
if: always()
uses: javiertuya/[email protected]
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: reports
report-title: "Test Report: ALL - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}"
diff-links-enabled: true
#diff-links-prefix: "target/"
diff-links-reports: "reports/junit-*/**/*.html"
#diff-links-files: "/**/target/*.html"
- name: Copy pit reports
run: cp -r test-report-files-Eval/st-tdg-eval/target/pit-reports reports/pit-reports
- name: Index file to html reports
if: always()
run: |
echo "<html><head><title>Latest Test Reports</title></head><body>" > index.html
echo "<h2>Latest Test Reports - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}</h2>" >> index.html
echo "<p><a href=\"reports/junit-noframes/junit-noframes.html\">JUnit test report - Single page</a></p>" >> index.html
echo "<p><a href=\"reports/junit-frames/index.html\">JUnit test report - Multiple page with frames</a></p>" >> index.html
echo "<p><a href=\"reports/pit-reports/index.html\">PIT test report</a></p>" >> index.html
echo "</body></html>" >> index.html
ls -la reports
- name: Publish test report files
if: always()
uses: actions/upload-artifact@v4
with:
name: "test-report-ALL"
path: |
index.html
reports
**/target/surefire-reports
**/target/out
**/target/*.html
**/target/*.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]
if: always()
run: sudo chmod -c -R 0755 reports
- name: Upload artifact
if: always()
uses: actions/[email protected]
with:
path: "."
- name: Deploy to GitHub Pages
if: always()
id: deployment
uses: actions/[email protected]