-
Notifications
You must be signed in to change notification settings - Fork 352
178 lines (173 loc) · 7.62 KB
/
run-tests.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
name: Test
env:
# This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
cache: maven
- name: Test core # NOTE: dhis-2/pom.xml needs to be installed as built artifacts are needed by dhis-web
run: mvn clean install --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
timeout-minutes: 30
- name: Report coverage to codecov
uses: codecov/codecov-action@v3
with:
directory: ./dhis-2
flags: unit
fail_ci_if_error: false
verbose: true
# delete the next 2 steps once we are confident in the coverage setup
- name: Tar jacoco coverage report to debug
run: tar -cvf coverage.tar dhis-2/dhis-test-coverage/target/site/jacoco-aggregate
- uses: actions/upload-artifact@v4
name: Upload jacoco coverage report to debug
with:
name: unit-test-coverage
path: coverage.tar
retention-days: 5
# no coverage is gathered for dhis-web as it will be removed
- name: Test dhis-web
run: mvn test --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/dhis-web/pom.xml
timeout-minutes: 30
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty,-dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
- name: Archive surefire reports
uses: actions/upload-artifact@v4
with:
name: unit-test-surefire-reports
path: |
dhis-2/target/site/surefire-report.html
surefire_reports.tar
retention-days: 5
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
cache: maven
- name: Run integration tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -Pintegration -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
if: failure()
with:
name: integration-test-logs
path: "**/target/test.log"
if-no-files-found: error # check our logging configuration if that happens
retention-days: 3
- name: Report coverage to codecov
uses: codecov/codecov-action@v3
with:
directory: ./dhis-2
flags: integration
fail_ci_if_error: false
verbose: true
# delete the next 2 steps once we are confident in the coverage setup
- name: Tar jacoco coverage report to debug
run: tar -cvf coverage.tar dhis-2/dhis-test-coverage/target/site/jacoco-aggregate
- uses: actions/upload-artifact@v4
name: Upload jacoco coverage report to debug
with:
name: integration-test-coverage
path: coverage.tar
retention-days: 5
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty,-dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
- name: Archive surefire reports
uses: actions/upload-artifact@v4
with:
name: integration-test-surefire-reports
path: |
dhis-2/target/site/surefire-report.html
surefire_reports.tar
retention-days: 5
integration-h2-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
cache: maven
- name: Run integration h2 tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -PintegrationH2 -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
if: failure()
with:
name: integration-h2-test-logs
path: "**/target/test.log"
if-no-files-found: error # check our logging configuration if that happens
retention-days: 3
- name: Report coverage to codecov
uses: codecov/codecov-action@v3
with:
directory: ./dhis-2
flags: integration-h2
fail_ci_if_error: false
verbose: true
# delete the next 2 steps once we are confident in the coverage setup
- name: Tar jacoco coverage report to debug
run: tar -cvf coverage.tar dhis-2/dhis-test-coverage/target/site/jacoco-aggregate
- uses: actions/upload-artifact@v4
name: Upload jacoco coverage report to debug
with:
name: integration-h2-test-coverage
path: coverage.tar
retention-days: 5
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty,-dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
- name: Archive surefire reports
uses: actions/upload-artifact@v4
with:
name: integration-h2-test-surefire-reports
path: |
dhis-2/target/site/surefire-report.html
surefire_reports.tar
retention-days: 5
send-slack-message:
runs-on: ubuntu-latest
if: |
always() &&
contains(needs.*.result, 'failure') &&
github.ref == 'refs/heads/master'
needs: [ unit-test, integration-test, integration-h2-test ]
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }}
SLACK_CHANNEL: 'team-backend'
SLACK_MESSAGE: "Latest test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}"
SLACK_COLOR: '#ff0000'