-
Notifications
You must be signed in to change notification settings - Fork 37
81 lines (67 loc) · 2.19 KB
/
main.yml
File metadata and controls
81 lines (67 loc) · 2.19 KB
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
name: Tomcat integration
on:
push:
pull_request:
jobs:
tomcat-it:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
java: [17, 21]
tomcat: [9.0.117-jre17-temurin, 9.0.117-jre21-temurin]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
- name: Build library and test webapp
run: mvn -B -DskipTests package
- name: Build Tomcat test image
run: |
docker build \
--build-arg TOMCAT_TAG=${{ matrix.tomcat }} \
-f .github/Dockerfile.tomcat-it \
-t mylib-it:${{ github.sha }} .
- name: Start Tomcat
run: |
docker run -d --name tomcat-it -p 8080:8080 mylib-it:${{ github.sha }}
for i in {1..60}; do
if curl -fsS http://127.0.0.1:8080/health; then
exit 0
fi
sleep 2
done
echo "Tomcat did not become ready"
docker logs tomcat-it || true
exit 1
- name: Exercise app
run: |
curl -fsS http://127.0.0.1:8080/trigger
curl -fsS http://127.0.0.1:8080/health
- name: Stop Tomcat and collect logs
if: always()
run: |
mkdir -p artifacts
docker stop --time 30 tomcat-it || true
docker logs tomcat-it > artifacts/container.log 2>&1 || true
docker cp tomcat-it:/usr/local/tomcat/logs artifacts/tomcat-logs || true
docker inspect tomcat-it > artifacts/container-inspect.json || true
- name: Fail on unexpected shutdown errors
if: always()
run: |
if grep -R -E "(OutOfMemoryError|SEVERE|NoClassDefFoundError|ClassCastException|memory leak)" artifacts; then
echo "Unexpected errors found in Tomcat shutdown logs"
exit 1
fi
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: tomcat-logs-java${{ matrix.java }}-${{ matrix.tomcat }}
path: artifacts/
retention-days: 7