-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (88 loc) · 3.32 KB
/
maven.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
name: Java CI with Maven
on:
pull_request:
branches: [ "master" ]
jobs:
container-job:
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Make Maven Wrapper executable
run: chmod +x ./mvnw
- name: Create Maven config
run: |
mkdir -p .mvn
echo "--batch-mode" > .mvn/maven.config
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Cache build artifacts
id: cache-build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-build-${{ hashFiles('src/**/*.java', '**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-
- name: Compile project
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw compile
- name: Run integration tests
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw verify
- name: Package project
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw package -DskipTests
- name: Start and wait for project readiness
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
nohup java -jar target/quarkus-app/quarkus-run.jar &
count_requests=0
MAX_REQUEST_ATTEMPTS=15
HEALTH_CHECK_ENDPOINT="http://localhost:8080/q/health/ready"
while [ "$count_requests" -lt "$MAX_REQUEST_ATTEMPTS" ]; do
count_requests=$((count_requests+1))
# Allows curl failures without stopping the script
set +e
http_code=$(curl "$HEALTH_CHECK_ENDPOINT" \
--silent \
--output /dev/null \
--write-out "%{http_code}")
set -e
curl_exit_code=$?
if [ $curl_exit_code -ne 0 ]; then
echo "Attempt ($count_requests/$MAX_REQUEST_ATTEMPTS): curl failed with exit code $curl_exit_code (could not connect)"
fi
if [ $curl_exit_code -eq 0 ]; then
echo "Attempt ($count_requests/$MAX_REQUEST_ATTEMPTS): HTTP $http_code"
fi
if [ "$http_code" -eq 200 ]; then
echo "Project is ready!"
exit 0
fi
sleep 1
done
echo "Max attempts ($count_requests/$MAX_REQUEST_ATTEMPTS) reached."
exit 1
- name: Setup K6
if: steps.cache-build.outputs.cache-hit != 'true'
uses: grafana/setup-k6-action@v1
- name: Run local k6 test
if: steps.cache-build.outputs.cache-hit != 'true'
uses: grafana/run-k6-action@v1
with:
path: ./e2e/api-test.js
# Dummy token for nektos/act. Can't run this step locally without it
github-token: ${{ github.token || 'dummy-token' }}
cloud-run-locally: ${{ github.token == 'dummy-token' && 'false' || 'true' }}
cloud-comment-on-pr: ${{ github.token == 'dummy-token' && 'true' || 'false' }}