-
Notifications
You must be signed in to change notification settings - Fork 22
220 lines (211 loc) · 8.17 KB
/
e2e-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
name: E2E Test
on:
pull_request_target:
branches:
- main
paths-ignore:
- '**.md'
types:
- opened
- synchronize
- reopened
- edited
push:
branches:
- main
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
HAWTIO_BRANCH: 4.x
jobs:
test:
permissions:
pull-requests: read
strategy:
fail-fast: false
matrix:
node: ['18', '20']
java: ['17', '21']
runtime: ['springboot', 'quarkus']
browser: ['firefox'] # 'chrome' tests are unstable: https://github.com/hawtio/hawtio-next/issues/478
env:
REPORT_DIR: results-${{matrix.runtime}}-node(${{matrix.node}})-java(${{matrix.java}})-${{matrix.browser}}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: 'refs/pull/${{ github.event.number }}/merge'
- name: Checkout code
uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}
- name: Docker Setup QEMU
uses: docker/[email protected]
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install
- name: Build
run: yarn build:all
- name: Start server
run: |
yarn start:app --no-color --no-hot --no-live-reload --no-client-overlay > log &
# Check both CRACO and Webpack log messages until we migrate to Webpack
# https://github.com/hawtio/hawtio-next/pull/847
timeout 30 bash -c "while ! grep -e 'You can now view app in the browser.' -e 'webpack .\+ compiled successfully' log ; do cat log; sleep 5; done"
- name: Detect testsuite branch
id: get-images
env:
body: ${{ github.event.pull_request.body || ''}}
run: |
if [[ "${body}" =~ \`branch:[[:space:]]([[:alnum:]\/_.-]+)(:([[:alnum:]\/_.-]+))?\` ]]; then
if [ -z "${BASH_REMATCH[2]}" ]; then
echo "repo=hawtio/hawtio" >> $GITHUB_OUTPUT
echo "branch=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "repo=${BASH_REMATCH[1]}/hawtio" >> $GITHUB_OUTPUT
echo "branch=${BASH_REMATCH[2]:1}" >> $GITHUB_OUTPUT
fi
else
branch=${{env.HAWTIO_BRANCH}}
app_image=quay.io/hawtio/hawtio-${{ matrix.runtime }}-test-app:$branch-${{ matrix.java }}
testsuite_image=quay.io/hawtio/hawtio-test-suite:$branch-${{ matrix.java }}
docker pull $app_image
docker pull $testsuite_image
echo "app-image=$app_image" >> $GITHUB_ENV
echo "testsuite-image=$testsuite_image" >> $GITHUB_ENV
fi
- name: Checkout Hawtio
if: ${{ steps.get-images.outputs.repo != ''}}
uses: actions/checkout@v4
with:
repository: ${{ steps.get-images.outputs.repo }}
ref: ${{ steps.get-images.outputs.branch }}
path: hawtio
- name: Set up Java
if: ${{ steps.get-images.outputs.repo != ''}}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{matrix.java}}
cache: 'maven'
- name: Build Hawtio
if: ${{ steps.get-images.outputs.repo != ''}}
run: |
cd hawtio
mvn --batch-mode --no-transfer-progress install -DskipTests -Pe2e -Pdocker-testsuite -Ptests-docker -Dhawtio-container -pl :hawtio-test-suite,:hawtio-tests-quarkus,:hawtio-tests-springboot -am
echo 'app-image=hawtio-${{ matrix.runtime }}-app:${{ matrix.java }}' >> $GITHUB_ENV
echo 'testsuite-image=hawtio-test-suite:${{ matrix.java }}' >> $GITHUB_ENV
- name: Setup application
run: |
case ${{ matrix.runtime }} in
quarkus)
APP_PORT=8080
echo "url-suffix=hawtio" >> $GITHUB_ENV
echo 'app-port=8080' >> $GITHUB_ENV
;;
springboot)
APP_PORT=10001
echo "url-suffix=actuator/hawtio" >> $GITHUB_ENV
echo 'app-port=10001' >> $GITHUB_ENV
;;
esac
id=$(docker run --name app --network host -d ${{ env.app-image }})
timeout 30 bash -c "while ! docker logs $id 2>&1 | grep -q 'Hello Camel!'; do sleep 1; done"
- name: Run tests
run: |
mkdir -p $PWD/$REPORT_DIR/
docker run --rm --network host \
-v $PWD/$REPORT_DIR:/hawtio-test-suite/tests/hawtio-test-suite/target \
-v $PWD/$REPORT_DIR/build:/hawtio-test-suite/tests/hawtio-test-suite/build/ \
--shm-size="2g" \
${{ env.testsuite-image }} -Pe2e-${{ matrix.runtime }} -Dselenide.browser=${{ matrix.browser }} \
-Dio.hawt.test.url=http://localhost:3000/hawtio \
-Dio.hawt.test.app.connect.url=http://localhost:${{ env.app-port }}/${{ env.url-suffix }}/jolokia \
-Dhawtio-next-ci
- name: Prepare report artifacts
if: always()
run: |
mkdir -p results/$REPORT_DIR/
cp $REPORT_DIR/cucumber-reports/* results/$REPORT_DIR/
docker logs app 2>&1 > results/$REPORT_DIR/container.log
docker logs app 2>&1 > $REPORT_DIR/container.log
echo "Container log:"
cat results/$REPORT_DIR/container.log
- name: Archive test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: 'test-${{ env.REPORT_DIR }}'
path: |
${{ env.REPORT_DIR }}/build/reports/tests/*.png
${{ env.REPORT_DIR }}/*.log
${{ env.REPORT_DIR }}/cucumber-reports/*
publish-results:
runs-on: ubuntu-latest
needs: test
if: always()
permissions:
checks: write
actions: read
pull-requests: write
steps:
- name: Archive failed test reports
uses: actions/upload-artifact/merge@v4
if: always()
with:
name: 'test-results'
pattern: test-results-*
separate-directories: true
- name: Download Test Results
uses: actions/[email protected]
with:
name: 'test-results'
path: 'test-results'
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
**/Cucumber.xml
json_file: results.json
- name: Install xmllint
run: sudo apt-get install -y xmlstarlet jq
- name: Generate summary
run: |
export CHECK_URL=$(jq -r .check_url results.json)
wget https://raw.githubusercontent.com/hawtio/hawtio/${{ env.HAWTIO_BRANCH }}/tests/hawtio-test-suite/process_test_results.sh
wget https://raw.githubusercontent.com/hawtio/hawtio/${{ env.HAWTIO_BRANCH }}/tests/hawtio-test-suite/pr_results_template.xsl
bash process_test_results.sh test-results > summary.md
- name: Update summary
run: |
cat summary.md >> $GITHUB_STEP_SUMMARY
- uses: tibdex/github-app-token@v2
if: github.event_name == 'pull_request_target'
id: generate-token
with:
app_id: ${{ secrets.HAWTIO_CI_APP_ID }}
private_key: ${{ secrets.HAWTIO_CI_PRIVATE_KEY }}
- name: Comment PR with summary
if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v3
with:
github-token: ${{ steps.generate-token.outputs.token }}
file-path: summary.md
comment-tag: execution