Files
goldeneye-pc-port/.github/workflows/ci.yml
T

488 lines
23 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI
on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
# No paths-ignore here: tag pushes must always build so a release can be
# cut even when the tagged commit only touched docs, and a workflow that
# never triggers would leave a required status check pending forever.
# Docs-only branch pushes are instead skipped by the `changes` job below,
# which reports the build jobs as "skipped" (green for branch protection).
pull_request:
# No paths-ignore here either: a docs-only PR must still trigger the
# workflow so the required checks report a status. The `changes` job
# below diffs the PR against its base and, for a docs-only PR, reports
# the build jobs as "skipped" — which branch protection accepts as
# success. With paths-ignore the workflow never ran and the required
# checks stayed "expected" forever, wedging every docs PR (M-44).
workflow_dispatch:
# Minimal token: CI only reads the repo and uploads build artifacts, neither of
# which needs write access. Fork PRs run untrusted build scripts on the runner,
# so keep the granted scope as small as possible and never expose secrets here.
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
# Jobs:
#
# linux-build — ubuntu, system GCC. Actually compiles + links (unlike
# validate), then packages the Linux bundle (exe + README +
# licenses + prepare-assets, NO ROM / assets / bundled libs)
# via tools_pc/bundle-linux.sh and uploads it. Surfaces
# GCC-on-Linux strictness gaps MinGW misses. Not a runtime
# claim; not a required check yet.
#
# validate — ubuntu, configure-only. Byte-compiles the tooling,
# regenerates the US ROM-asset symbol file, and CMake-
# configures ntsc-final (REGION_DEFS, the source list, and
# that SDL2 / zlib / OpenGL are discoverable). No ROM is used.
# Does NOT compile; running on ubuntu is NOT a claim the port
# works on Linux.
#
# windows-build — windows/MSYS2, the real supported platform. Compiles and
# links the full executable, then packages the distributable
# bundle (exe + runtime DLLs + README + licenses, NO ROM /
# assets) via tools_pc/bundle-win.sh and uploads it. Neither
# the ROM nor extracted assets are needed to BUILD (they are
# runtime-only), so CI builds but never runs the port.
#
# release — tags only (v*). Downloads the Windows + Linux bundles and
# attaches both to a DRAFT pre-release for that tag. Draft, so
# a human does the ROM smoke-test on each platform and hits
# Publish. This is the only job granted contents: write.
jobs:
# Did this change touch anything outside docs / licenses? No workflow-level
# paths-ignore exists (see the `on:` comments), so this job is the single
# place a docs-only push OR pull request is filtered out — a PR is diffed
# against its base sha, a branch push against `github.event.before`. Tag
# builds always run. Docs globs: **.md, docs/**, LICENSE, NOTICE.
changes:
runs-on: ubuntu-22.04
outputs:
code: ${{ steps.filter.outputs.code }}
# Windows builds default to the self-hosted box (fast, local ccache;
# docs/dev/notes/SELFHOSTED-RUNNER-PLAN.md §G2) for everything EXCEPT:
# (a) a release build (tag push) -- keep that on a clean, reproducible
# GitHub-hosted runner for the artifact that actually ships, and
# (b) a fork PR -- untrusted PR code must never reach a box that will
# later hold a ROM. Same-repo (non-fork) PRs now also get routed to
# self-hosted per the 2026-09-12 standing preference.
windows_selfhosted: ${{ steps.runner.outputs.selfhosted }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- id: runner
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "selfhosted=false" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "pull_request" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "selfhosted=false" >> "$GITHUB_OUTPUT"
else
echo "selfhosted=true" >> "$GITHUB_OUTPUT"
fi
- id: filter
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
base='${{ github.event.pull_request.base.sha }}'
head='${{ github.event.pull_request.head.sha }}'
elif [ "${{ github.event_name }}" != "push" ] || [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"; exit 0
else
base='${{ github.event.before }}'
head='${{ github.sha }}'
fi
if ! git cat-file -e "${base}^{commit}" 2>/dev/null || ! git cat-file -e "${head}^{commit}" 2>/dev/null; then
echo "no usable base ${base}/head ${head} — building to be safe"
echo "code=true" >> "$GITHUB_OUTPUT"; exit 0
fi
changed="$(git diff --name-only "$base" "$head")"
echo "Changed files:"; echo "$changed"
if echo "$changed" | grep -qvE '(\.md$|^docs/|^LICENSE$|^NOTICE$)'; then
echo "code=true" >> "$GITHUB_OUTPUT"
else
echo "docs-only push — skipping build"
echo "code=false" >> "$GITHUB_OUTPUT"
fi
validate:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake python3 libsdl2-dev zlib1g-dev libgl1-mesa-dev
- name: Byte-compile Python tooling
run: python3 -m compileall -q scripts tools_pc
# Generated dev-docs stay in sync with the tree (speed-ups plan Step 4).
- name: Check generated dev indexes are current
run: |
python3 tools_pc/gen_findings_index.py --check
python3 tools_pc/gen_env_probes.py --check
# Docs budget guardrail (ctx-opt P2): warn, don't fail. The §F index
# table should stay one-liners; fat cell content belongs in `## Dxx`
# sections at the file tail (lookup path: docs/dev/findings-index.csv).
- name: Check dev-docs size budgets (warn only)
run: |
# Budget = ~55 KB of table rows + ~110 KB of legacy D24–D33 / M-xxx
# narrative that predates the ctx-opt migration. The signal is fat
# ROWS re-accumulating, so the threshold sits ~15 KB above today's
# 166 KB total.
f=$(awk '/^### F\./{f=1;next} /^### G\./{f=0} f' docs/dev/findings.md | wc -c)
[ "$f" -le 184320 ] || echo "WARNING: findings.md §F region is $f bytes (> 180 KB) — fat rows accumulating; migrate cell content to ## Dxx sections at the file tail"
p=$(wc -c < docs/porting-notes.md)
[ "$p" -le 122880 ] || echo "WARNING: porting-notes.md is $p bytes (> 120 KB) — consider splitting or adding a TOC block"
# US only. gen_romassets.py resolves every symbol for the US region from
# the committed CSVs with no ROM present; PAL/JP each need a handful of
# region-specific prop/font offsets that only come from that region's ROM
# (see docs/building.md — PAL/JP builders generate romassets_e/j.s
# locally). No ROM is used or required here.
- name: Regenerate ROM-asset symbol file (US)
run: |
python3 scripts/gen_romassets.py u
git diff --stat -- port/src/romassets_u.s
- name: CMake configure (ntsc-final)
run: cmake -S . -B build-ntsc -DROMID=ntsc-final
# Linux (Ubuntu, system GCC) compile job. Unlike `validate` this actually
# runs `cmake --build`, so it surfaces the GCC-on-Linux strictness gaps that
# MinGW does not flag. The port has never been run on Linux — a green build
# here is a "does it compile + link" signal only, not a runtime claim.
# Not a required check yet; flip it to required once it is reliably green.
#
# Toolchain: Steam Runtime 3 "sniper" SDK container (Debian 11 base,
# glibc 2.31) + its gcc-14. Building against the old glibc is what sets the
# tarball's floor: the ubuntu-24.04 build needed glibc 2.38 (C23
# __isoc23_* symbols), so it refused to start on Ubuntu 22.04 / Debian 12.
# The image is pinned by version AND digest.
# SDL2 is built from source (2.30.0, the version the 24.04 build bundled
# and every Linux/Deck test used): the SDK's own libSDL2 is sdl2-compat,
# which needs SDL3 at runtime. pip is bootstrapped from a hash-pinned
# get-pip.py: Debian 11's security archive no longer serves python3-pip.
linux-build:
runs-on: ubuntu-24.04
container:
image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:3.0.20260805.254768@sha256:1c33c507bc75d012e77df5727f93b0d5b8c3f7c8d4142ba5f7a16882cc92e014
env:
CC: gcc-14
CXX: g++-14
# CMakeLists.txt opt-in enables CMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache
# when ccache is on PATH (b4de1c68, speed-ups plan Step 5). Game
# sources are frozen (1:1 with the decomp), so after the first run only
# touched port/ files miss cache -- near-total hit rate. CCACHE_DIR is
# set in a step: in a container job ${{ github.workspace }} is the
# host path, not the container's.
CCACHE_MAXSIZE: 500M
SDL2_VERSION: 2.30.0
SDL2_SHA256: 36e2e41557e0fa4a1519315c0f5958a87ccb27e25c51776beb6f1239526447b0
GET_PIP_SHA256: 95c0ae79ccf9ac1e47e4187f49081d6ae1f45997afd4549e14f37337cbcfd766
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install dependencies
run: |
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" >> "$GITHUB_ENV"
apt-get update
apt-get install -y patchelf
curl -fsSL -o /tmp/get-pip.py https://bootstrap.pypa.io/pip/3.9/get-pip.py
echo "$GET_PIP_SHA256 /tmp/get-pip.py" | sha256sum -c
python3 /tmp/get-pip.py --quiet
- name: Build SDL2 ${{ env.SDL2_VERSION }} from source
run: |
curl -fsSL -o /tmp/sdl2.tar.gz \
"https://github.com/libsdl-org/SDL/releases/download/release-$SDL2_VERSION/SDL2-$SDL2_VERSION.tar.gz"
echo "$SDL2_SHA256 /tmp/sdl2.tar.gz" | sha256sum -c
tar xzf /tmp/sdl2.tar.gz -C /tmp
cmake -S "/tmp/SDL2-$SDL2_VERSION" -B /tmp/sdl-build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local -DSDL_STATIC=OFF -DSDL_TEST=OFF
cmake --build /tmp/sdl-build -j"$(nproc)"
cmake --install /tmp/sdl-build
ldconfig
- name: Restore ccache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ccache-linux-sniper-${{ hashFiles('CMakeLists.txt') }}-${{ github.sha }}
restore-keys: |
ccache-linux-sniper-${{ hashFiles('CMakeLists.txt') }}-
ccache-linux-sniper-
- name: Regenerate ROM-asset symbol file (US)
run: python3 scripts/gen_romassets.py u
# Drop-in ROM support: freeze the asset-prep tool into a single
# ge007-convert binary the engine spawns on first run when the
# pcmodels/pccg sidecars are missing (port/src/romconvert.c). Pure-
# stdlib scripts, so PyInstaller --onefile is clean; lands in
# tools_pc/dist/prepare-assets/ where bundle-linux.sh picks it up.
- name: Freeze asset converter (PyInstaller)
run: |
python3 -c "import PyInstaller, sys; sys.exit(PyInstaller.__version__ != '6.22.3')" 2>/dev/null \
|| python3 -m pip install --quiet pyinstaller==6.22.3
python3 -m PyInstaller --onefile --noconfirm --clean \
--name ge007-convert \
--distpath tools_pc/dist/prepare-assets \
--workpath build-pyinst --specpath build-pyinst \
tools_pc/dist/prepare-assets/prepare-assets.py
ls -la tools_pc/dist/prepare-assets/ge007-convert
- name: Configure (ntsc-final)
run: cmake -S . -B build-linux -DROMID=ntsc-final
-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14
- name: Build (ntsc-final)
run: cmake --build build-linux -j"$(nproc)"
- name: ccache stats
run: ccache -s
- name: Show binary
run: |
ls -la build-linux/ge007* || true
file build-linux/ge007* || true
# Package the Linux bundle on every run so the release path stays
# exercised. SDL2 is bundled (patchelf sets the exe's rpath to $ORIGIN)
# so the tarball runs as-is on any distro / a sideloaded Steam Deck;
# zlib + libGL stay system deps. Same ROM / size guards as Windows.
- name: Package Linux bundle
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
V="${GITHUB_REF_NAME}"
else
V="0.0.0-ci.${GITHUB_SHA::7}"
fi
tools_pc/bundle-linux.sh "$V"
- name: Upload bundle
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: goldeneye-pc-port-linux-x86_64
path: |
dist/*.tar.gz
dist/*.tar.gz.sha256
if-no-files-found: error
retention-days: 14
# Real Windows (MSYS2 MINGW64) build — the only platform the port is
# developed and tested on. This compiles and LINKS the full executable.
#
# No ROM and no extracted assets are needed to build: the compiled asset set
# is a handful of committed pure-data .c files plus the generated
# address-constant romassets_<region>.s. The ROM (.z64) and the ROM-derived
# blobs are runtime-only dependencies — CI cannot run the game, only build it.
windows-build:
needs: changes
if: needs.changes.outputs.code == 'true'
# Self-hosted by default (fast, local ccache); windows-latest only for a
# release (tag) build or a fork PR — see the `changes` job's `runner`
# step for the exact rule (docs/dev/notes/SELFHOSTED-RUNNER-PLAN.md §G2).
runs-on: ${{ needs.changes.outputs.windows_selfhosted == 'true' && fromJSON('["self-hosted", "windows"]') || 'windows-latest' }}
defaults:
run:
shell: msys2 {0}
env:
# Same opt-in ccache CMakeLists.txt already wires up (Step 5). Note:
# this cache path is read/written by the JS actions/cache step outside
# the msys2 shell too, so it stays a plain workspace-relative path
# rather than an msys /c/... form.
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# windows-latest (release tag / fork PR) is ephemeral: full install +
# update every run. Self-hosted (everything else): `release: false`
# reuses the box's own C:\msys64 as-is and, with update/install both
# empty here, does no pacman -Syu / pacman -S at all (verified against
# the action's source) — it only registers the `msys2 {0}` shell
# wrapper every job needs. Packages themselves are hand-maintained on
# the box; the dependency check below (not this step) verifies they're
# present.
- uses: msys2/setup-msys2@ec48f7c5447b3140e2b088413ae3a55687bccb6e # v2.33.0
with:
msystem: MINGW64
release: ${{ needs.changes.outputs.windows_selfhosted != 'true' }}
update: ${{ needs.changes.outputs.windows_selfhosted != 'true' }}
install: ${{ needs.changes.outputs.windows_selfhosted != 'true' && 'mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-SDL2 mingw-w64-x86_64-zlib mingw-w64-x86_64-python mingw-w64-x86_64-ccache zip unzip' || '' }}
# Self-hosted only: fails fast with exact install instructions if the
# box's hand-maintained MSYS2 is missing a required package, instead of
# a confusing failure deeper in the build. windows-latest just installed
# everything above, so this would be redundant there.
- name: Check self-hosted dependencies
if: needs.changes.outputs.windows_selfhosted == 'true'
run: tools_pc/check-selfhosted-deps.sh
- name: Restore ccache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-windows-${{ hashFiles('CMakeLists.txt') }}-${{ github.sha }}
restore-keys: |
ccache-windows-${{ hashFiles('CMakeLists.txt') }}-
ccache-windows-
- name: Regenerate ROM-asset symbol file (US)
run: python scripts/gen_romassets.py u
# Drop-in ROM support: freeze the asset-prep tool into a single
# ge007-convert.exe the engine spawns on first run when the pcmodels/
# pccg sidecars are missing (port/src/romconvert.c). Lands in
# tools_pc/dist/prepare-assets/ where bundle-win.sh picks it up.
- name: Freeze asset converter (PyInstaller)
run: |
# MSYS2's mingw python ships without pip and has ensurepip
# disabled — install pip from pacman, then PyInstaller.
python -c "import PyInstaller, sys; sys.exit(PyInstaller.__version__ != '6.22.3')" 2>/dev/null || {
pacman -S --noconfirm --needed mingw-w64-x86_64-python-pip
python -m pip install --quiet --break-system-packages pyinstaller==6.22.3
}
python -m PyInstaller --onefile --noconfirm --clean \
--name ge007-convert \
--distpath tools_pc/dist/prepare-assets \
--workpath build-pyinst --specpath build-pyinst \
tools_pc/dist/prepare-assets/prepare-assets.py
ls -la tools_pc/dist/prepare-assets/ge007-convert.exe
- name: Build (ntsc-final)
run: ./build-pc.sh ntsc-final
# D441 ratchet: fail if the per-file count of 64-bit pointer/int ABI
# warnings rises relative to tools_pc/abi_baseline.json. Re-baseline
# locally with `python tools_pc/abi_ratchet.py build-pc --update`.
- name: ABI warning ratchet (D441)
run: python tools_pc/abi_ratchet.py build-pc
- name: ccache stats
run: ccache -s
# Package the distributable bundle on every run so the release path is
# always exercised. On a tag build VERSION is the tag; otherwise it is a
# throwaway CI string. bundle-win.sh hard-fails if a ROM image or an
# oversized blob ends up inside the bundle.
- name: Package Windows bundle
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
V="${GITHUB_REF_NAME}"
else
V="0.0.0-ci.${GITHUB_SHA::7}"
fi
tools_pc/bundle-win.sh "$V"
- name: Upload bundle
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: goldeneye-pc-port-win64
path: |
dist/*.zip
dist/*.zip.sha256
if-no-files-found: error
retention-days: 14
# CI builds and packages the executable but does not run it — running the
# port needs a ROM, which CI does not provide. Runtime checks (the
# -level_09 soak, a golden-frame diff) would run on a self-hosted runner
# instead. Not planned.
# Tags only. Attach the packaged Windows + Linux bundles to a DRAFT
# pre-release so a human can do the ROM smoke-test on each platform before
# publishing. This job — and only this job — gets contents: write, and it
# is also the only job that attests build provenance (id-token: write +
# attestations: write; attest-build-provenance needs both).
release:
if: github.ref_type == 'tag'
needs: [ changes, validate, windows-build, linux-build ]
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The pushed tag must match the version baked into the exe (the update
# check compares against it); bump GE007_VERSION in CMakeLists.txt first.
- name: Check tag matches GE007_VERSION
run: |
ver=$(sed -n 's/^set(GE007_VERSION "\([^"]*\)").*/\1/p' CMakeLists.txt)
if [ -z "$ver" ] || [ "${GITHUB_REF_NAME}" != "v${ver}" ]; then
echo "tag ${GITHUB_REF_NAME} != v${ver} (CMakeLists.txt GE007_VERSION)"; exit 1
fi
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: goldeneye-pc-port-win64
path: dist
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: goldeneye-pc-port-linux-x86_64
path: dist
# SLSA build provenance for the release artifacts (in-toto, signed by
# GitHub's OIDC key for this repo's workflow at the tagged commit).
# Anyone can check a downloaded file:
# gh attestation verify <file> --repo jkdansereau/goldeneye-pc-port
- uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
with:
subject-path: |
dist/*.zip
dist/*.zip.sha256
dist/*.tar.gz
dist/*.tar.gz.sha256
- name: Create or update draft pre-release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF_NAME}"
ASSETS=(dist/*.zip dist/*.zip.sha256 dist/*.tar.gz dist/*.tar.gz.sha256)
NOTES="$(mktemp)"
# Asset names are built from the tag with the leading v stripped
# (bundle-{linux,win}.sh), so substitute the same form -- a raw
# TAG would make the notes reference goldeneye-pc-port-v*.* assets
# that don't exist.
NOTES_VERSION="${TAG#v}"
sed "s/<version>/${NOTES_VERSION}/g" .github/release-notes.md > "$NOTES"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" "${ASSETS[@]}" --clobber
# Re-stamp the notes body too: it is only set at creation, and
# release-notes.md may have moved since the draft was first cut.
gh release edit "$TAG" --notes-file "$NOTES"
else
gh release create "$TAG" "${ASSETS[@]}" \
--draft --prerelease \
--title "GoldenEye 007 PC Port $TAG" \
--notes-file "$NOTES"
fi