Build and verify a retained-runtime travel class patch
All checks were successful
Open Guild Travel Build / open-travel (push) Successful in 3m11s
DuneRealms Plugin CI / plugins (push) Successful in 9m25s

This commit is contained in:
unimatrixgit 2026-12-03 20:41:07 +01:00
commit 74b33f40c0
2 changed files with 126 additions and 0 deletions

View file

@ -0,0 +1,43 @@
name: Open Guild Travel Build
on:
workflow_dispatch:
push:
branches: ['feat/open-travel-*']
jobs:
open-travel:
runs-on: dune-ci
steps:
- name: Check out exact revision
shell: bash
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git init .
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
git checkout --detach FETCH_HEAD
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '9.2.1'
- name: Build reviewed travel classes
shell: bash
run: |
set -euo pipefail
for module in JarvisConnector DuneRealmsGUI DuneMenus; do
gradle --no-daemon -p "$module" test jar
done
mkdir open-travel-artifacts
python3 tools/plugin_open_travel.py open-travel-artifacts/open-travel-classes.zip
cp tools/plugin_open_travel.py open-travel-artifacts/
printf '%s\n' "$(git rev-parse HEAD)" > open-travel-artifacts/SOURCE_COMMIT
(cd open-travel-artifacts && sha256sum -- open-travel-classes.zip *.py SOURCE_COMMIT > SHA256SUMS)
- uses: actions/upload-artifact@v3
with:
name: DuneRealms-Open-Travel
path: open-travel-artifacts/
if-no-files-found: error

View file

@ -0,0 +1,83 @@
"""Build and assemble only the reviewed open-travel classes."""
import argparse
import hashlib
from pathlib import Path
from zipfile import ZipFile
PACKAGES = {
'DunerealmsGUI.jar': ('DuneRealmsGUI', 'gui', ('DuneGUI', 'GuildRoutes', 'GuildRoutes$Offer')),
'DuneMenus.jar': ('DuneMenus', 'menus', ('JarvisBackend', 'TravelMenu')),
'jarvistranslator.jar': ('JarvisConnector', 'jarvis', ('GuildTransport', 'TravelBounty')),
}
BASELINES = {
'DunerealmsGUI.jar': {
'54735136fb8e15852a69271cfa5b436af4116914876bc539fe9994140854378a',
'73061d45ba727aa9fd7aac462a62a8efb0681b2d6baa1662db514730abb83163',
},
'DuneMenus.jar': {
'4585825d0ac6cc70b0c95988cf4e8eb0f378e473d33a10b0a98c4b75fee51a8d',
'0e06d86fda465cf0a65469632da90f26bfca9b0c4899a4bdbdb4199d6a3eed04',
},
'jarvistranslator.jar': {
'5f770b0cb41b49b03bb567d43fedb861631f8a3f95915b32dac071dfbc311c7e',
'd3f7ae1ec8491146fd4ccf9e1d745cfd83dcc08b5704a7013e9b3023fa00cbd6',
},
}
def entries(archive):
names = archive.namelist()
if len(names) != len(set(names)):
raise ValueError('Duplicate ZIP entry')
return set(names)
def class_paths(kind):
_, package, classes = PACKAGES[kind]
return {f'com/dunerealms/{package}/{name}.class' for name in classes}
def extract(output):
with ZipFile(output, 'x') as patch:
for kind, (module, _, _) in PACKAGES.items():
with ZipFile(Path(module) / 'build/libs' / kind) as jar:
entries(jar)
for name in sorted(class_paths(kind)):
patch.writestr(kind + '/' + name, jar.read(name))
def assemble(kind, baseline, patch, output):
if hashlib.sha256(baseline.read_bytes()).hexdigest() not in BASELINES[kind]:
raise ValueError('Expected the exact retained travel runtime')
classes = class_paths(kind)
new = {name for name in classes if name.endswith('/TravelBounty.class')}
with ZipFile(baseline) as original, ZipFile(patch) as updates:
expected = {key + '/' + name for key in PACKAGES for name in class_paths(key)}
original_names = entries(original)
if entries(updates) != expected or not classes - new <= original_names or new & original_names:
raise ValueError('Unexpected open-travel class set')
changed = {name: updates.read(kind + '/' + name) for name in classes}
if any(not data.startswith(b'\xca\xfe\xba\xbe') for data in changed.values()):
raise ValueError('Invalid open-travel class')
with ZipFile(output, 'x') as candidate:
for info in original.infolist():
data = changed[info.filename] if info.filename in changed else original.read(info)
candidate.writestr(info, data)
for name in sorted(new):
candidate.writestr(name, changed[name])
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('patch', type=Path)
parser.add_argument('--kind', choices=PACKAGES)
parser.add_argument('--baseline', type=Path)
parser.add_argument('--output', type=Path)
arguments = parser.parse_args()
if arguments.kind is None:
extract(arguments.patch)
elif arguments.baseline is None or arguments.output is None:
parser.error('Assembly needs a baseline and output')
else:
assemble(arguments.kind, arguments.baseline, arguments.patch, arguments.output)