mirror of
https://github.com/imjasonh/nescript
synced 2026-07-08 00:45:38 +00:00
Runs the jsnes + puppeteer harness on every push/PR so the same execution-level bugs that the test suite previously couldn't catch (missing JMP/JSR fixups, orphaned handler locals, uninitialized struct fields, silently-swallowed intrinsic calls) will be caught in CI going forward. The job installs the handful of shared libs Chrome for Testing needs on the ubuntu-latest runner, builds the compiler in release, compiles every example, then drives each ROM through the harness. On failure it uploads the captured screenshots and the JSON report as a build artifact so regressions are easy to triage without re-running locally. Kept separate from the existing `Build Examples` job so compile-time and execution-time issues report independently. https://claude.ai/code/session_014Z5y3Q9krLcAxYpZQJhZ5V
134 lines
3.7 KiB
YAML
134 lines
3.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUSTFLAGS: "-D warnings"
|
|
|
|
jobs:
|
|
check:
|
|
name: Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
- run: cargo check --all-targets
|
|
|
|
fmt:
|
|
name: Format
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt
|
|
- run: cargo fmt --all -- --check
|
|
|
|
clippy:
|
|
name: Clippy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy
|
|
- uses: Swatinem/rust-cache@v2
|
|
- run: cargo clippy --all-targets -- -D warnings
|
|
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
- run: cargo test --all-targets
|
|
|
|
examples:
|
|
name: Build Examples
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
- run: cargo build --release
|
|
- name: Compile all .ne examples
|
|
run: |
|
|
for f in examples/*.ne; do
|
|
echo "==> Compiling $f"
|
|
cargo run --release -- build "$f"
|
|
done
|
|
- name: Verify ROMs are valid iNES
|
|
run: |
|
|
for f in examples/*.nes; do
|
|
echo "==> Checking $f"
|
|
# iNES magic: first 4 bytes must be "NES\x1a"
|
|
header=$(od -A n -t x1 -N 4 "$f" | tr -d ' ')
|
|
if [ "$header" != "4e45531a" ]; then
|
|
echo "FAIL: $f is not a valid iNES ROM (header: $header)"
|
|
exit 1
|
|
fi
|
|
size=$(stat -c%s "$f")
|
|
echo " OK: $size bytes"
|
|
done
|
|
|
|
emulator:
|
|
name: Emulator Smoke Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
- name: Install Chrome runtime deps for puppeteer
|
|
# puppeteer ships its own Chrome for Testing binary via the
|
|
# package's postinstall hook, but the runner image is missing
|
|
# a handful of shared libs that Chrome needs to launch.
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends \
|
|
libnss3 \
|
|
libatk-bridge2.0-0 \
|
|
libatk1.0-0 \
|
|
libatspi2.0-0 \
|
|
libcups2t64 \
|
|
libdbus-1-3 \
|
|
libdrm2 \
|
|
libgbm1 \
|
|
libpango-1.0-0 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libxfixes3 \
|
|
libxkbcommon0 \
|
|
libxrandr2 \
|
|
libasound2t64
|
|
- name: Build compiler
|
|
run: cargo build --release
|
|
- name: Compile all .ne examples
|
|
run: |
|
|
for f in examples/*.ne; do
|
|
echo "==> Compiling $f"
|
|
./target/release/nescript build "$f"
|
|
done
|
|
- name: Install emulator harness dependencies
|
|
working-directory: tests/emulator
|
|
run: npm ci
|
|
- name: Run each ROM in jsnes and verify it renders
|
|
working-directory: tests/emulator
|
|
run: node run_examples.mjs
|
|
- name: Upload emulator screenshots on failure
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: emulator-screenshots
|
|
path: |
|
|
tests/emulator/screenshots/
|
|
tests/emulator/report.json
|