Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8cc2eea
CI: a release workflow, and a nightly one (first: the PC and the brow…
martin-mat Oct 24, 2026
4ecae51
CI: build and test called by the release run in a concurrency group o…
martin-mat Oct 24, 2026
d9418f1
CI nightly: the Atari ST (Hatari, EmuTOS from source) and the Amiga (…
martin-mat Oct 24, 2026
478b0fe
CI nightly: the C64 in VICE (built from the 3.9 tarball with our patc…
martin-mat Oct 24, 2026
f7264a5
CI nightly: the MZ-800 in mz800emu (built from the MZPico fork with S…
martin-mat Oct 24, 2026
5ca5c74
CI nightly: SDL3's build dependencies (X11, ALSA), no Wayland
martin-mat Oct 24, 2026
ef085e7
CI nightly: mz800emu needs json-glib
martin-mat Oct 24, 2026
1054776
CI nightly: the apt packages on every run (cached VICE and mz800emu l…
martin-mat Oct 24, 2026
86628f7
CI nightly: minizip-ng's library path for the mz800emu link; VICE's o…
martin-mat Oct 24, 2026
888392e
CI nightly: minizip-ng without PPMd (its static library left the code…
martin-mat Oct 24, 2026
3aaef3b
CI nightly: mz800emu with its ui_resources; its log when the MZ job f…
martin-mat Oct 24, 2026
34554bb
CI nightly: VICE without -march=native (a cached build ran on another…
martin-mat Oct 24, 2026
7acf3e0
CI nightly: mz800emu on an invisible X display (SDL opens its video e…
martin-mat Oct 24, 2026
5f290d3
CI nightly: cross-play, the MZ with the Spectrum and the CPC, and the…
martin-mat Oct 24, 2026
edf8f24
CI: the emulator tests on every pull request and push to main as well…
martin-mat Oct 24, 2026
8b2223d
CI: the Atari XL/XE replay in atari800 (its built-in AltirraOS), the …
martin-mat Oct 24, 2026
18151d1
CI: cross-play between the browser and the PC, each one hosting
martin-mat Oct 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ on:
push:
branches: [main]
workflow_dispatch:
workflow_call: # the release workflow runs it too

defaults:
run:
shell: bash # named: then bash runs with -e -o pipefail (unnamed: -e only, and a failing
# command piped into tail would pass)

concurrency:
group: build-${{ github.ref }}
group: ${{ github.workflow }}-build-${{ github.ref }} # (called by release.yml: the caller's name, a group of its own)
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -88,8 +89,11 @@ jobs:
curl -sSL -o /tmp/llvm-mos.tar.xz \
"https://github.com/llvm-mos/llvm-mos-sdk/releases/download/$LLVM_MOS_VERSION/llvm-mos-linux.tar.xz"
tar -xJf /tmp/llvm-mos.tar.xz -C ~
- name: c1541 (the C64's disk image; VICE's package, no ROMs needed)
if: matrix.dir == 'c64'
run: sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends vice
- name: build
run: LLVM_MOS=~/llvm-mos python3 tools/${{ matrix.script }}
run: C1541=$(command -v c1541 || true) LLVM_MOS=~/llvm-mos python3 tools/${{ matrix.script }}
- name: memory budget
run: LLVM_MOS=~/llvm-mos python3 tools/check_sizes.py
- uses: actions/upload-artifact@v4
Expand Down
421 changes: 421 additions & 0 deletions .github/workflows/emulators.yml

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# A tag vX.Y.Z: the version checked against the game's (GAME_VERSION in
# c/core/game.h), every target built and every test run (the build and test
# workflows), the files gathered under one naming scheme with their SHA-256
# sums, and a DRAFT release made for them. Publishing it stays a person's
# decision (the release page's "Publish").
name: release

on:
push:
tags: ['v*']
pull_request: # a dry run when this workflow changes: no release, the files as an artifact
paths: ['.github/workflows/release.yml']

jobs:
version:
name: the tag matches the game's version
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: v
shell: bash
run: |
game=$(sed -n 's/^#define GAME_VERSION "\(.*\)".*/\1/p' c/core/game.h)
[ -n "$game" ] || { echo "::error::no GAME_VERSION in c/core/game.h"; exit 1; }
if [ "$GITHUB_EVENT_NAME" = push ]; then
tag="${GITHUB_REF_NAME#v}"
echo "tag $tag, GAME_VERSION $game"
[ "$tag" = "$game" ] || { echo "::error::tag v$tag but c/core/game.h has GAME_VERSION \"$game\""; exit 1; }
else echo "dry run: GAME_VERSION $game"; fi
echo "version=$game" >> "$GITHUB_OUTPUT"

build:
needs: version
uses: ./.github/workflows/build.yml

test:
needs: version
uses: ./.github/workflows/test.yml

release:
name: draft release
needs: [version, build, test]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: the release files
shell: bash
run: |
v=${{ needs.version.outputs.version }}
mkdir dist
put() { [ -f "$1" ] || { echo "::error::missing $1"; exit 1; }; cp "$1" "dist/bombernet-$v-$2"; }
put artifacts/mz/bomber.mzf mz800.mzf
put artifacts/zx/bomber.tap zx-spectrum-48k.tap
put artifacts/zx128/bomber.tap zx-spectrum-128k-esp01.tap
put artifacts/cpc/bomber.dsk amstrad-cpc.dsk
put artifacts/cpc/bomber.cpc amstrad-cpc.cpc
put artifacts/atari/bomber.xex atari-xl.xex
put artifacts/c64/bomber.prg c64.prg
put artifacts/c64/bomber.d64 c64.d64
put artifacts/amiga/bomber amiga
put artifacts/amiga/bombernet.adf amiga.adf
put artifacts/st/BOMBER.PRG atari-st.prg
put artifacts/st/bombernet.st atari-st.st
put artifacts/pc/BOMBER.EXE pc-dos.exe
put artifacts/pc/bombernet.img pc-dos.img
(cd artifacts/web && zip -q -9 "../../dist/bombernet-$v-web.zip" bombernet.html bombernet.js bombernet.wasm)
(cd dist && sha256sum * > SHA256SUMS)
ls -l dist
- name: the files (a dry run)
if: github.event_name != 'push'
uses: actions/upload-artifact@v4
with:
name: release-files
path: dist/
retention-days: 7
- name: draft release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
v=${{ needs.version.outputs.version }}
cat > notes.md <<NOTES
BomberNet $v for every machine. Built and tested by the release workflow; the files' SHA-256 sums are in SHA256SUMS.

| Machine | File |
|---|---|
| Sharp MZ-800 (MZPico) | bombernet-$v-mz800.mzf |
| ZX Spectrum 48K and up (Spectranet) | bombernet-$v-zx-spectrum-48k.tap |
| ZX Spectrum 128K, eLeMeNt / MB03+ with an ESP-01 | bombernet-$v-zx-spectrum-128k-esp01.tap |
| Amstrad CPC (M4 board) | bombernet-$v-amstrad-cpc.dsk, .cpc |
| Atari XL/XE (FujiNet) | bombernet-$v-atari-xl.xex |
| Commodore 64 (WiC64, Ultimate) | bombernet-$v-c64.prg, .d64 |
| Amiga (any TCP/IP stack) | bombernet-$v-amiga, bombernet-$v-amiga.adf |
| Atari ST (WiFi modem) | bombernet-$v-atari-st.prg, .st |
| IBM PC, DOS (WiFi modem, Ethernet with a packet driver) | bombernet-$v-pc-dos.exe, .img |
| Any browser (WebAssembly) | bombernet-$v-web.zip |

NOTES
gh release create "$GITHUB_REF_NAME" dist/* --draft --title "BomberNet $v" --notes-file notes.md --generate-notes
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ on:
push:
branches: [main]
workflow_dispatch:
workflow_call: # the release workflow runs it too

defaults:
run:
shell: bash # named: then bash runs with -e -o pipefail (unnamed: -e only, and a failing
# command piped into tail would pass)

concurrency:
group: test-${{ github.ref }}
group: ${{ github.workflow }}-test-${{ github.ref }} # (called by release.yml: the caller's name, a group of its own)
cancel-in-progress: true

jobs:
Expand Down
1 change: 1 addition & 0 deletions tools/amiga_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,6 @@ def close(self): self.p.kill()
print(f'host frame {hs["frame"]} abort {hs["abort"]}, join frame {js["frame"]} abort {js["abort"]}; '
f'{len(common)} hashed frames compared, {len(mism)} mismatches'
+ (f' (first at {mism[0]})' if mism else '') + f'; {float(hs["frame"]) / (time.time() - t0):.1f} frames a second', flush=True)
sys.exit(1 if mism or hs['abort'] != '0' or js['abort'] != '0' or not common else 0)
finally:
host.close(); join.close()
65 changes: 65 additions & 0 deletions tools/atari_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
"""Run an ATARI_TEST build (tools/build_atari.py --test) in atari800 and read
its verdict: the build replays its recording from the title on, checks every
hash, and at the end turns the border green (all equal), yellow (all equal,
some frames over 60 ms of the emulated machine's time) or red (a hash
differed, from that frame on). The border is read from a screenshot.

tools/atari_test.py [build/atari/bomber.xex] [--png out.png]

atari800 (Ubuntu's package; ATARI800 to name another) as an 800XL, PAL, with
its built-in AltirraOS (no ROM to download), fast-forwarded, on the X display
AMIGA_DISPLAY (an Xvfb, :97), with a configuration of its own."""
import os, subprocess, sys, time
from PIL import Image

ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
args = [a for i, a in enumerate(sys.argv[1:], 1) if not a.startswith('--') and sys.argv[i - 1] != '--png']
xex = args[0] if args else os.path.join(ROOT, 'build', 'atari', 'bomber.xex')
out = os.path.join(ROOT, 'build', 'atari')
png = sys.argv[sys.argv.index('--png') + 1] if '--png' in sys.argv else os.path.join(out, 'test.png')
cfg = os.path.join(out, 'atari800.cfg') # never the user's ~/.atari800.cfg
open(cfg, 'w').write('')
env = dict(os.environ, DISPLAY=os.environ.get('AMIGA_DISPLAY', ':97')) # the invisible X display, never the desktop's
cmd = [os.environ.get('ATARI800', 'atari800'), '-config', cfg, '-no-autosave-config', '-xl', '-xl-rev', 'altirra', '-pal',
'-nobasic', '-nosound', '-windowed', '-turbo', '-run', xex]
log = open(os.path.join(out, 'atari800.log'), 'w')
p = subprocess.Popen(cmd, stdout=log, stderr=subprocess.STDOUT, env=env)
t0 = time.time()


def border():
"""the border's colour (just inside the window's top left corner), or None before the window shows"""
shot = png + '.part.png'
subprocess.run(['ffmpeg', '-loglevel', 'error', '-y', '-f', 'x11grab', '-video_size', '1024x768', '-i', env['DISPLAY'],
'-frames:v', '1', shot], env=env)
if not os.path.exists(shot): return None
os.replace(shot, png)
im = Image.open(png).convert('RGB')
box = im.getbbox()
return im.getpixel((box[0] + 4, box[1] + 4)) if box else None


def verdict(c):
"""black (still playing: COLOR4 is 0 in the game), red, green or yellow (by hue)"""
if c is None or max(c) < 40: return None
r, g, b = c
if r > g * 1.5 and r > b: return 'red'
if g > r * 1.2: return 'green'
return 'yellow'


v = None
try:
while time.time() - t0 < 120 and p.poll() is None:
time.sleep(1)
v = verdict(border())
if v:
time.sleep(1); v = verdict(border()) # a frame later: the figures drawn too
break
finally:
p.kill()
if not v: sys.exit(f'no verdict after {time.time() - t0:.0f} s (log: build/atari/atari800.log, screen: {png})')
print(f'{os.path.basename(xex)}: hashes {"MISMATCH" if v == "red" else "all equal"}'
f'{", some frames over 60 ms" if v == "yellow" else ""}; screenshot {png}; {time.time() - t0:.0f} s')
sys.exit(1 if v == 'red' else 0)
5 changes: 5 additions & 0 deletions tools/c64_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,10 @@ def tap(v):
f'abort {v.u8("net_abort")}', flush=True)
print('state hashes', host.mem('state_hash', 2).hex(), join.mem('state_hash', 2).hex(),
'at frames', host.u16('frame_no'), join.u16('frame_no'))
# the verdict: the relay compares the hashes every 16 frames and aborts both on a difference (an abort
# flag), so no abort and enough frames played (10 a second at least) is a pass
played = min(v.u16('frame_no') - fr for v, (fr, _) in zip(both, f0))
aborts = [v.u8('net_abort') for v in both]
sys.exit(1 if any(aborts) or played < SECS * 10 else 0)
finally:
for v in both: v.close()
7 changes: 7 additions & 0 deletions tools/ci/displays.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# The two invisible X displays the emulator tests use (:97, :98; AMIGA_DISPLAY, AMIGA_DISPLAY2).
for d in 97 98; do
Xvfb :$d -screen 0 1024x768x24 -nolisten tcp > /dev/null 2>&1 &
done
for i in $(seq 50); do xdpyinfo -display :97 > /dev/null 2>&1 && xdpyinfo -display :98 > /dev/null 2>&1 && exit 0; sleep 0.2; done
echo "Xvfb did not start"; exit 1
7 changes: 7 additions & 0 deletions tools/ci/emucfg_net/mz800emu.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; mz800emu's settings for the network tests (the CI copies this into build/emucfg_net; MZ800EMU_CFG):
; the Unicard as an MZPico with its NET extension, talking to the local relay's TCP port.
[UNICARD]
mzpico_mode = 1
net_relay = 127.0.0.1:8766
connected = 1
readonly = 0
7 changes: 7 additions & 0 deletions tools/ci/relay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# The local reference relay on 127.0.0.1:8765 (WebSocket) and 8766 (TCP), log in build/relay.log.
cd "$(dirname "$0")/../.." || exit 1
[ -x build/venv/bin/uvicorn ] || { python3 -m venv build/venv && build/venv/bin/pip install -q -r relay/requirements.txt; }
(cd relay && ../build/venv/bin/uvicorn relay:app --host 127.0.0.1 --port 8765 > ../build/relay.log 2>&1 &)
for i in $(seq 50); do nc -z 127.0.0.1 8765 && exit 0; sleep 0.2; done
echo "the relay did not start"; tail -20 build/relay.log; exit 1
7 changes: 7 additions & 0 deletions tools/ci/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# A test that runs emulators in real time, given one more chance: tools/ci/retry.sh command args...
# (a busy CI machine can starve an emulator for a moment; a real failure fails twice)
"$@" && exit 0
echo "::warning::failed once, retrying: $*"
sleep 5
exec "$@"
9 changes: 9 additions & 0 deletions tools/ci/toolchains.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ AMITOOLS_VERSION=0.8.1
# the Python emulators the tests use (tools/zxemu.py, tools/cpcemu.py), from PyPI
ZX_EMU_VERSION=0.13.15
Z80_EMU_VERSION=1.2.0
# EmuTOS (the Atari ST tests: Hatari ships no TOS), a commit of github.com/emutos/emutos
EMUTOS_COMMIT=02c2db7
# VICE (the C64 tests), built from its release tarball with tools/c64/vice-3.9-bombernet.patch
VICE_VERSION=3.9
# mz800emu (the MZ-800 tests): the MZPico fork's commit, and the libraries it needs that Ubuntu lacks
MZ800EMU_COMMIT=45725d7
SDL3_TAG=release-3.4.14
SDL3_IMAGE_TAG=release-3.4.4
MINIZIP_NG_COMMIT=7d2917b
5 changes: 4 additions & 1 deletion tools/webpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
tools/crossplay.py's web machine): open a page, keys, JavaScript, screenshots.
Chromium runs on the invisible X display (:97, as tools/netbench.py starts
it; its own profile: Chromium ignores the debugging port on the default one).
CHROMIUM: the browser (default the snap's chromium); CHROMIUM_FLAGS: more
flags (CI: --no-sandbox, where the runner gives no user namespaces).
serve(dir) serves a build directory over HTTP on 127.0.0.1 for the page."""
import base64, functools, http.server, itertools, json, os, socket, subprocess, sys, threading, time, urllib.request
from websockets.sync.client import connect
Expand All @@ -22,7 +24,8 @@ def chromium():
subprocess.Popen([CHROMIUM, f'--remote-debugging-port={PORT}', f'--user-data-dir={profile}', '--no-first-run',
'--autoplay-policy=no-user-gesture-required', '--ignore-gpu-blocklist', '--enable-unsafe-swiftshader',
'--disable-background-timer-throttling', '--disable-renderer-backgrounding',
'--disable-backgrounding-occluded-windows', 'about:blank'], env=env,
'--disable-backgrounding-occluded-windows', *os.environ.get('CHROMIUM_FLAGS', '').split(),
'about:blank'], env=env,
stdout=open(os.path.join(ROOT, 'build', 'chromium.log'), 'w'), stderr=subprocess.STDOUT)
for _ in range(60):
try: socket.create_connection(('127.0.0.1', PORT), timeout=1).close(); return
Expand Down
Loading