forked from RuiXuqi/CleanroomModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (106 loc) · 3.78 KB
/
Copy pathruntime-test.yml
File metadata and controls
130 lines (106 loc) · 3.78 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
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
- name: Prepare client runtime directory
run: mkdir -p run/client/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/client/mods
- name: Configure client runtime
run: |
mkdir -p run/client
cat <<EOF >> run/client/options.txt
onboardAccessibility:false
pauseOnLostFocus:false
EOF
- name: Run client runtime test
run: xvfb-run -a timeout 10m ./gradlew runClient --no-daemon -Pmod_version="${MOD_VERSION}"
- name: Run server runtime test
run: |
set -euo pipefail
mkdir -p run/server
echo "eula=true" > run/server/eula.txt
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
exit 1
fi
if [ -d run/server/crash-reports ] && find run/server/crash-reports -maxdepth 1 -type f -name "*.txt" | grep -q .; then
echo "Server generated a crash report."
find run/server/crash-reports -maxdepth 1 -type f -name "*.txt" -print
tail -n 200 run/server/runtime-test-server.log || true
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."
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
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