Skip to content

Commit e701fec

Browse files
committed
test 8
1 parent 4a3e604 commit e701fec

1 file changed

Lines changed: 78 additions & 48 deletions

File tree

.github/workflows/runtime-test.yml

Lines changed: 78 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ permissions:
1515
env:
1616
JAVA_VERSION: 25
1717
CLEANROOM_VERSION: 0.6.10-alpha
18-
HEADLESSMC_VERSION: 2.10.0
18+
PRISM_VERSION: 11.0.3
19+
PRISM_INSTANCE_ID: cleanroom
20+
PRISM_PLAYER_NAME: RuntimeTest
1921

2022
jobs:
2123
runtime-test:
@@ -33,16 +35,18 @@ jobs:
3335
path: |
3436
.gradle
3537
build/runtime-test/minecraft
36-
build/runtime-test/HeadlessMC
37-
build/runtime-test/headlessmc-launcher-*.jar
38+
build/runtime-test/PrismLauncher-Linux-x86_64.AppImage
39+
build/runtime-test/cleanroom-instance-template.zip
40+
build/runtime-test/PrismLauncher/libraries
41+
build/runtime-test/PrismLauncher/assets
3842
build/runtime-test/support
3943
build/runtime-test/client-mods
4044
build/runtime-test/remapped-mods
4145
build/runtime-test/runtime-mcp-remap.marker
4246
build/runtime-test/cleanroom-client-installed.marker
43-
key: ${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-hmc${{ env.HEADLESSMC_VERSION }}-helper4.5.1-runtime-test-${{ hashFiles('build.gradle', 'gradle.properties', 'gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/gradle-wrapper.jar', 'gradle/scripts/**') }}
47+
key: ${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-prism${{ env.PRISM_VERSION }}-helper4.5.1-runtime-test-${{ hashFiles('build.gradle', 'gradle.properties', 'gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/gradle-wrapper.jar', 'gradle/scripts/**', '.github/workflows/runtime-test.yml') }}
4448
restore-keys: |
45-
${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-hmc${{ env.HEADLESSMC_VERSION }}-helper4.5.1-runtime-test-
49+
${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-prism${{ env.PRISM_VERSION }}-helper4.5.1-runtime-test-
4650
4751
- name: Setup Java
4852
uses: actions/setup-java@v4
@@ -172,21 +176,45 @@ jobs:
172176
fi
173177
echo "${server_sha1} ${server_jar}" | sha1sum --check
174178
175-
- name: Install Headless Display
179+
- name: Install Virtual Display
176180
run: |
177181
if ! command -v xvfb-run >/dev/null 2>&1; then
178182
sudo apt-get update
179183
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb
180184
fi
181185
182-
- name: Download HeadlessMC
183-
if: ${{ hashFiles('build/runtime-test/headlessmc-launcher-*.jar') == '' }}
184-
uses: robinraju/release-downloader@v1.11
185-
with:
186-
repository: 3arthqu4ke/headlessmc
187-
tag: "${{ env.HEADLESSMC_VERSION }}"
188-
fileName: "headlessmc-launcher-${{ env.HEADLESSMC_VERSION }}.jar"
189-
out-file-path: build/runtime-test
186+
- name: Prepare Prism Launcher
187+
run: |
188+
set -euo pipefail
189+
runtime_root="$PWD/build/runtime-test"
190+
launcher="${runtime_root}/PrismLauncher-Linux-x86_64.AppImage"
191+
launcher_url="https://github.com/PrismLauncher/PrismLauncher/releases/download/${PRISM_VERSION}/PrismLauncher-Linux-x86_64.AppImage"
192+
if [ ! -f "${launcher}" ]; then
193+
curl --fail --location --retry 3 --output "${launcher}" "${launcher_url}"
194+
fi
195+
chmod +x "${launcher}"
196+
197+
- name: Download Cleanroom MMC Instance
198+
run: |
199+
set -euo pipefail
200+
runtime_root="$PWD/build/runtime-test"
201+
template="${runtime_root}/cleanroom-instance-template.zip"
202+
template_url="https://github.com/CleanroomMC/Cleanroom/releases/download/${CLEANROOM_VERSION}/cleanroom-${CLEANROOM_VERSION}.zip"
203+
if [ ! -f "${template}" ]; then
204+
curl --fail --location --retry 3 --output "${template}" "${template_url}"
205+
fi
206+
unzip -tq "${template}"
207+
for required_file in \
208+
instance.cfg \
209+
mmc-pack.json \
210+
patches/net.minecraft.json \
211+
patches/net.minecraftforge.json \
212+
patches/org.lwjgl3.json; do
213+
unzip -Z1 "${template}" | grep -Fxq "${required_file}" || {
214+
echo "Cleanroom MMC template is missing ${required_file}" >&2
215+
exit 1
216+
}
217+
done
190218
191219
- name: Launch Cleanroom Production Server
192220
run: |
@@ -244,46 +272,45 @@ jobs:
244272
run: |
245273
set -euo pipefail
246274
runtime_root="$PWD/build/runtime-test"
247-
minecraft_dir="${runtime_root}/minecraft"
248-
instance_dir="${runtime_root}/instance"
249-
launcher="${runtime_root}/headlessmc-launcher-${HEADLESSMC_VERSION}.jar"
250-
251-
profile="${minecraft_dir}/versions/1.12.2-Cleanroom-${CLEANROOM_VERSION}/1.12.2-Cleanroom-${CLEANROOM_VERSION}.json"
252-
python3 - "${profile}" <<'PY'
253-
import pathlib
254-
import sys
255-
256-
profile = pathlib.Path(sys.argv[1])
257-
text = profile.read_text(encoding='utf-8')
258-
profile.write_text(text.replace('osx-arm64', 'osx'), encoding='utf-8')
259-
PY
260-
261-
mkdir -p "${instance_dir}/mods"
262-
cp "${runtime_root}/client-mods/"*.jar "${instance_dir}/mods/"
263-
mkdir -p "${runtime_root}/HeadlessMC"
264-
cat > "${runtime_root}/HeadlessMC/config.properties" <<EOF
265-
hmc.java.versions=${JAVA_HOME}/bin/java
266-
hmc.gamedir=${instance_dir}
267-
hmc.mcdir=${minecraft_dir}
268-
hmc.offline=true
269-
hmc.rethrow.launch.exceptions=true
270-
hmc.exit.on.failed.command=true
271-
EOF
275+
prism_root="${runtime_root}/PrismLauncher"
276+
instance_dir="${prism_root}/instances/${PRISM_INSTANCE_ID}"
277+
launcher="${runtime_root}/PrismLauncher-Linux-x86_64.AppImage"
278+
template="${runtime_root}/cleanroom-instance-template.zip"
279+
prism_log="${runtime_root}/prism-client.log"
280+
281+
rm -rf "${instance_dir}"
282+
mkdir -p "${instance_dir}"
283+
unzip -q "${template}" -d "${instance_dir}"
284+
sed -i "s#^JavaPath=.*#JavaPath=${JAVA_HOME}/bin/java#" "${instance_dir}/instance.cfg"
285+
mkdir -p "${prism_root}/libraries" "${prism_root}/assets"
286+
if [ -d "${runtime_root}/minecraft/libraries" ]; then
287+
cp -a "${runtime_root}/minecraft/libraries/." "${prism_root}/libraries/"
288+
fi
289+
if [ -d "${runtime_root}/minecraft/assets" ]; then
290+
cp -a "${runtime_root}/minecraft/assets/." "${prism_root}/assets/"
291+
fi
292+
mkdir -p "${instance_dir}/minecraft/mods"
293+
find "${runtime_root}/instance/mods" -maxdepth 1 -type f -name '*.jar' \
294+
-exec cp {} "${instance_dir}/minecraft/mods/" \;
295+
if [ -d "${runtime_root}/client-mods" ]; then
296+
find "${runtime_root}/client-mods" -maxdepth 1 -type f -name '*.jar' \
297+
-exec cp {} "${instance_dir}/minecraft/mods/" \;
298+
fi
272299
273-
(
274-
cd "${runtime_root}"
275-
xvfb-run -a java -jar "${launcher}" \
276-
--command launch "1.12.2-Cleanroom-${CLEANROOM_VERSION}" \
277-
-regex \
278-
-lwjgl \
279-
--jvm "-Djava.awt.headless=true"
280-
)
300+
set -o pipefail
301+
timeout --signal=TERM --kill-after=30s 20m \
302+
xvfb-run -a "${launcher}" \
303+
--appimage-extract-and-run \
304+
--dir "${prism_root}" \
305+
--launch "${PRISM_INSTANCE_ID}" \
306+
--offline "${PRISM_PLAYER_NAME}" \
307+
2>&1 | tee "${prism_log}"
281308
282309
- name: Prune Old Runtime Test Caches
283310
if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
284311
uses: actions/github-script@v7
285312
env:
286-
RUNTIME_CACHE_PREFIX: ${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-hmc${{ env.HEADLESSMC_VERSION }}-helper4.5.1-runtime-test-
313+
RUNTIME_CACHE_PREFIX: ${{ runner.os }}-java${{ env.JAVA_VERSION }}-gradle9.7-cleanroom${{ env.CLEANROOM_VERSION }}-prism${{ env.PRISM_VERSION }}-helper4.5.1-runtime-test-
287314
RUNTIME_CACHE_RETENTION: 3
288315
with:
289316
script: |
@@ -335,6 +362,9 @@ jobs:
335362
build/runtime-test/minecraft/logs
336363
build/runtime-test/minecraft/crash-reports
337364
build/runtime-test/gradle-runtime.log
365+
build/runtime-test/prism-client.log
366+
build/runtime-test/PrismLauncher/instances/${{ env.PRISM_INSTANCE_ID }}/minecraft/logs
367+
build/runtime-test/PrismLauncher/instances/${{ env.PRISM_INSTANCE_ID }}/minecraft/crash-reports
338368
build/runtime-test/cleanroom-client-installed.marker
339369
${{ runner.temp }}/runtime-test-diagnostics
340370
retention-days: 7

0 commit comments

Comments
 (0)