-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 2.84 KB
/
ci.yml
File metadata and controls
105 lines (88 loc) · 2.84 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Continuous Integration
# {CI workflow for pull requests and feature branches}
# {Runs tests and code quality checks without deployment}
on:
pull_request:
branches:
- main
- master
- develop
# {Run on pull requests to main branches}
push:
branches-ignore:
- main
- master
# {Run on pushes to feature branches, but not main}
env:
JAVA_VERSION: '11'
jobs:
ci:
name: CI - Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
java-version: ['11']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: 'maven'
- name: Verify Chrome is available
run: google-chrome --version || chromium-browser --version
# {GitHub ubuntu-latest includes Chrome; this confirms it before E2E tests}
- name: Build with Maven
run: mvn clean compile
# {Compile code to check for compilation errors}
- name: Start Jetty server (background)
run: nohup mvn jetty:run -q > jetty.log 2>&1 &
# {Non-blocking: starts Jetty on :8080 so E2E Selenium tests can connect}
- name: Wait for Jetty to be ready
run: |
echo "Waiting for Jetty on localhost:8080..."
for i in $(seq 1 30); do
if curl -sf http://localhost:8080/ > /dev/null 2>&1; then
echo "✅ Jetty is ready (attempt $i)"
break
fi
if [ $i -eq 30 ]; then
echo "❌ Jetty did not start within 90 seconds"
cat jetty.log
exit 1
fi
echo " Attempt $i/30 — sleeping 3s..."
sleep 3
done
- name: Run Tests
run: mvn test
# {Run all tests — unit + E2E (Jetty is now running on :8080)}
continue-on-error: false
- name: Generate Test Report
if: always()
uses: dorny/test-reporter@v1
with:
name: Maven Tests
path: target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: false
# {Generate test report visible in GitHub PR}
- name: Stop Jetty server
if: always()
run: pkill -f "jetty:run" || true
# {Always stop Jetty, even if tests failed}
- name: Build WAR file
run: mvn package -DskipTests
# {Build WAR file to verify packaging works}
continue-on-error: false
- name: Check WAR file exists
run: |
if ls target/*.war 1>/dev/null 2>&1; then
echo "✅ WAR file built successfully"
ls -lh target/*.war
else
echo "❌ WAR file not found"
exit 1
fi