-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (154 loc) · 5.21 KB
/
Copy pathruntime-test.yml
File metadata and controls
183 lines (154 loc) · 5.21 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
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
name: Runtime test
on:
workflow_dispatch:
workflow_call:
merge_group:
push:
branches:
- '**'
permissions:
contents: read
jobs:
runtime-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
- uses: gradle/actions/setup-gradle@v6
with:
gradle-version: 9.6.0
name: Set up Gradle
- name: Add permission
run: chmod +x ./gradlew
- name: Set build version
run: |
previous_tag="$(git describe --tags --abbrev=0 --exclude=dev 2>/dev/null || echo 0.0.0)"
previous_tag="${previous_tag#v}"
short_hash="$(git rev-parse --short HEAD)"
echo "MOD_VERSION=${previous_tag}+${short_hash}" >> "$GITHUB_ENV"
echo "Build version: ${previous_tag}+${short_hash}"
- name: Execute Gradle build
run: ./gradlew build -x spotlessCheck -Pmod_version="${MOD_VERSION}"
- name: Install client runtime dependencies
run: sudo DEBIAN_FRONTEND=noninteractive apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb x11-xserver-utils
- name: Prepare client runtime directory
run: mkdir -p run/mods
- name: Download client runtime test mod
uses: robinraju/release-downloader@v1.11
with:
repository: headlesshq/mc-runtime-test
tag: "4.4.0"
fileName: "mc-runtime-test-1.12.2-*-lexforge-release.jar"
out-file-path: run/mods
- name: Verify client runtime test mod
run: |
set -euo pipefail
ls -la run/mods
test -n "$(find run/mods -maxdepth 1 -type f -name 'mc-runtime-test-*.jar' -print -quit)" || {
echo "Runtime test mod jar missing in run/mods."
exit 1
}
- name: Configure client runtime
run: |
mkdir -p run
cat <<EOF >> run/options.txt
onboardAccessibility:false
pauseOnLostFocus:false
EOF
- name: Run client runtime test
run: |
set -euo pipefail
xvfb-run -a bash -c '
set -euo pipefail
xrandr -q
timeout 10m ./gradlew runClient --no-daemon -Pmod_version="${MOD_VERSION}"
'
- name: Collect client runtime logs
if: always()
run: |
set -euo pipefail
mkdir -p run/client
if [ -d run/logs ]; then
mkdir -p run/client/logs
cp -a run/logs/. run/client/logs/
fi
if [ -d run/crash-reports ]; then
mkdir -p run/client/crash-reports
cp -a run/crash-reports/. run/client/crash-reports/
fi
- name: Run server runtime test
run: |
set -euo pipefail
mkdir -p run/server
rm -f run/mods/mc-runtime-test-*.jar
rm -rf run/logs run/crash-reports
echo "eula=true" > run/eula.txt
cat <<EOF > run/server.properties
online-mode=false
EOF
collect_server_logs() {
if [ -d run/logs ]; then
mkdir -p run/server/logs
cp -a run/logs/. run/server/logs/
fi
if [ -d run/crash-reports ]; then
mkdir -p run/server/crash-reports
cp -a run/crash-reports/. run/server/crash-reports/
fi
}
setsid ./gradlew runServer --no-daemon -Pmod_version="${MOD_VERSION}" > run/server/runtime-test-server.log 2>&1 &
server_pid=$!
cleanup() {
kill -TERM "-${server_pid}" 2>/dev/null || true
wait "${server_pid}" 2>/dev/null || true
}
trap cleanup EXIT
deadline=$((SECONDS + 600))
while [ "${SECONDS}" -lt "${deadline}" ]; do
if ! kill -0 "${server_pid}" 2>/dev/null; then
wait "${server_pid}" || exit_code=$?
echo "Server exited before startup with code ${exit_code:-0}."
tail -n 200 run/server/runtime-test-server.log || true
collect_server_logs
exit 1
fi
if [ -d run/crash-reports ] && find run/crash-reports -maxdepth 1 -type f -name "*.txt" | grep -q .; then
echo "Server generated a crash report."
find run/crash-reports -maxdepth 1 -type f -name "*.txt" -print
tail -n 200 run/server/runtime-test-server.log || true
collect_server_logs
exit 1
fi
if grep -E 'Done \(|For help, type "help"' run/server/runtime-test-server.log >/dev/null 2>&1; then
echo "Server startup detected."
collect_server_logs
cleanup
trap - EXIT
exit 0
fi
sleep 5
done
echo "Server did not finish startup within 10 minutes."
tail -n 200 run/server/runtime-test-server.log || true
collect_server_logs
exit 1
- name: Upload runtime logs
if: always()
uses: actions/upload-artifact@v7
with:
name: runtime-test-logs
if-no-files-found: ignore
path: |
run/client/logs
run/client/crash-reports
run/server/logs
run/server/crash-reports
run/server/runtime-test-server.log
run/logs
run/crash-reports