Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Build: tests in eight parts side by side, the kit and the release after them
Mason363a98df9b7e998
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.ymlnew file mode 100644index 00000000..389de511--- /dev/null+++ b/.github/actions/setup/action.yml@@ -0,0 +1,27 @@+name: Tools+description: The ARM toolchain, Node with nwlink, Python with the build's packages, pngquant and Rust's ARM target+runs:+ using: composite+ steps:+ - name: ARM toolchain+ shell: bash+ run: |+ v=15.2.1-1.1+ curl -sSL "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v$v/xpack-arm-none-eabi-gcc-$v-linux-x64.tar.gz" | tar -xz -C "$RUNNER_TEMP"+ echo "$RUNNER_TEMP/xpack-arm-none-eabi-gcc-$v/bin" >> "$GITHUB_PATH"++ - uses: actions/setup-node@v4+ with:+ node-version: 20++ - uses: actions/setup-python@v5+ with:+ python-version: "3.12"++ - name: Packages+ shell: bash+ run: |+ sudo apt-get update -q && sudo apt-get install -yq pngquant+ pip install pillow numpy zopfli pyelftools unicorn==2.1.4+ npm install -g [email protected]+ rustup target add thumbv7em-none-eabihfdiff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex c92d5ba4..598b3916 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -1,7 +1,8 @@name: Build-# Builds NumPlay.nwa, its discreet versions and every game on its own, and publishes them as a GitHub-# release when main reaches a version (VERSION) not released yet. Pushing a tag like v1.2.0 does too.+# Builds NumPlay.nwa, its discreet versions and every game on its own, tests them in eight parts side by side,+# then gives NumPlay Studio the new kit and publishes a GitHub release when main reaches a version (VERSION) not+# released yet. Pushing a tag like v1.2.0 does too.on:push:@@ -25,31 +26,11 @@ jobs:runs-on: ubuntu-24.04steps:- uses: actions/checkout@v4-- - name: ARM toolchain- run: |- v=15.2.1-1.1- curl -sSL "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v$v/xpack-arm-none-eabi-gcc-$v-linux-x64.tar.gz" | tar -xz -C "$RUNNER_TEMP"- echo "$RUNNER_TEMP/xpack-arm-none-eabi-gcc-$v/bin" >> "$GITHUB_PATH"-- - uses: actions/setup-node@v4- with:- node-version: 20-- - uses: actions/setup-python@v5- with:- python-version: "3.12"-- - name: Tools- run: |- sudo apt-get update -q && sudo apt-get install -yq pngquant- pip install pillow numpy zopfli pyelftools unicorn==2.1.4- npm install -g [email protected]- rustup target add thumbv7em-none-eabihf+ - uses: ./.github/actions/setup- name: Buildrun: python3 tools/build.py -j 4 && make kit-langs NWLINK=nwlink-+- uses: actions/upload-artifact@v4with:name: nwa@@ -57,62 +38,47 @@ jobs:build/compiled/NumPlay*.nwabuild/compiled/games/*.nwa+ - uses: actions/upload-artifact@v4+ with:+ name: release+ path: |+ build/compiled+ build/data/site-kit++ # Each part builds again (faster than handing over the whole build) and runs its share: tests/ci.py+ test:+ runs-on: ubuntu-24.04+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4, 5, 6, 7, 8]+ steps:+ - uses: actions/checkout@v4+ - uses: ./.github/actions/setup++ - name: Build+ run: python3 tools/build.py -j 4+- name: Test- run: |- python3 tests/test_games.py build/compiled/games- python3 tests/test_uninstall.py build/compiled/NumPlay.nwa --game numdrive- python3 tests/test_progress.py build/compiled/NumPlay.nwa- python3 tests/test_numblocks_progress.py build/compiled/games/NumBlocks.nwa- python3 tests/test_upsilon.py build/compiled/NumPlay-Upsilon.nwa- python3 tests/test_small_ram.py build/compiled/NumPlay.nwa- python3 tests/test_apps.py build/data- make -C games/numblocks host test- make -C games/numdrive host test- make -C games/championisland host test- make -C games/undertale host test- make -C games/doom host test- make -C games/isaac host test- make -C games/pvz host test- make -C games/fnaf host test- make -C games/sonic host test- make -C games/subway host test- make -C games/hillclimb host test- make -C games/leveldevil host test- make -C games/cookieclicker host test- make -C games/jetpackjoyride host test- make -C games/donkeykong host test- make -C games/dune host test- make -C games/monkeymart host test- make -C games/tombofthemask host test- make -C games/invaders host test- make -C games/sudoku host test- make -C games/uttt host test- make -C games/sokoban host test- make -C games/twoplayer host test- make -C games/flappydunk host test- make -C games/towerblock host test- make -C games/suika host test- make -C games/doodlejump host test- make -C games/stickmanhook host test- make -C games/coreball host test- make -C games/uno host test- make -C games/fnf host test BUILD_DIR=../../build/data/games/fnf- make -C games/angrybirds host test- make -C games/polytrack host test- make -C games/paperclips host test- make -C games/badtime host test- make -C games/mahjong host test- make -C games/rider host test- make -C games/snowrider host test- make -C games/templerun host test- make -C games/fnaf2 host test- make -C games/famidash host test- make -C games/catninja host test+ run: python3 tests/ci.py --shard ${{ matrix.shard }} --of 8+ publish:+ needs: [build, test]+ if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request'+ runs-on: ubuntu-24.04+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-python@v5+ with:+ python-version: "3.12"++ - uses: actions/download-artifact@v4+ with:+ name: release+ path: build- name: Kit for the website- if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request'env:GH_TOKEN: ${{ github.token }}# NumPlay Studio (customize/) links a NumPlay of your own from the kit (make kit): it goes on the@@ -137,7 +103,6 @@ jobs:gh workflow run pages.yml --ref main --repo "$GITHUB_REPOSITORY" || echo "(the site was not deployed again)"- name: Release- if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')env:GH_TOKEN: ${{ github.token }}# The tag pushed, or on main v + VERSION (made here if it isn't released yet). GitHub lists thediff --git a/tests/ci.py b/tests/ci.pynew file mode 100644index 00000000..202944ab--- /dev/null+++ b/tests/ci.py@@ -0,0 +1,75 @@+#!/usr/bin/env python3+"""CI's tests in N parts that run side by side (.github/workflows/build.yml): part K of N plays every Nth app in+the emulator (tests/test_games.py --shard) and runs its share of the other tests, shared out by how long each took+on CI (WEIGHT, in seconds), longest first, each to the part with the least so far. Runs every test of its part,+then prints their times and fails if any failed.++Usage: tests/ci.py --shard K --of N (after tools/build.py, from the repository's root)"""+import argparse+import subprocess+import sys+import time++APPS = "build/compiled/games"+NUMPLAY = "build/compiled/NumPlay.nwa"+OTHER = [+ f"python3 tests/test_uninstall.py {NUMPLAY} --game numdrive",+ f"python3 tests/test_progress.py {NUMPLAY}",+ "python3 tests/test_numblocks_progress.py build/compiled/games/NumBlocks.nwa",+ "python3 tests/test_upsilon.py build/compiled/NumPlay-Upsilon.nwa",+ f"python3 tests/test_small_ram.py {NUMPLAY}",+ "python3 tests/test_apps.py build/data",+]+HOST = ["numblocks", "numdrive", "championisland", "undertale", "doom", "isaac", "pvz", "fnaf", "sonic", "subway",+ "hillclimb", "leveldevil", "cookieclicker", "jetpackjoyride", "donkeykong", "dune", "monkeymart",+ "tombofthemask", "invaders", "sudoku", "uttt", "sokoban", "twoplayer", "flappydunk", "towerblock", "suika",+ "doodlejump", "stickmanhook", "coreball", "uno", "fnf", "angrybirds", "polytrack", "paperclips", "badtime",+ "mahjong", "rider", "snowrider", "templerun", "fnaf2", "famidash", "catninja"]+HOST_ARGS = {"fnf": " BUILD_DIR=../../build/data/games/fnf"}+# seconds on CI (v1.24.3's run); the emulator's 71 apps took 2450 in all, the Python tests about 380+WEIGHT = {"numblocks": 89, "numdrive": 20, "championisland": 69, "undertale": 445, "doom": 54, "isaac": 380,+ "pvz": 214, "fnaf": 215, "sonic": 53, "subway": 46, "hillclimb": 94, "leveldevil": 3, "cookieclicker": 61,+ "jetpackjoyride": 134, "donkeykong": 291, "dune": 135, "monkeymart": 85, "tombofthemask": 119,+ "invaders": 7, "sudoku": 3, "uttt": 2, "sokoban": 2, "twoplayer": 114, "flappydunk": 2, "towerblock": 2,+ "suika": 112, "doodlejump": 5, "stickmanhook": 103, "coreball": 26, "uno": 36, "fnf": 80, "angrybirds": 627,+ "polytrack": 116, "paperclips": 164, "badtime": 59, "mahjong": 25, "rider": 137, "snowrider": 30,+ "templerun": 384, "fnaf2": 654, "famidash": 7, "catninja": 60}+EMULATOR = 2450+PYTHON = 380+++def parts(n):+ """the commands of each of n parts"""+ load = [EMULATOR / n] * n+ out = [[f"python3 tests/test_games.py {APPS} --shard {k + 1}/{n}"] for k in range(n)]+ jobs = [(PYTHON / len(OTHER), c) for c in OTHER]+ jobs += [(WEIGHT.get(g, 60), f"make -C games/{g} host test{HOST_ARGS.get(g, '')}") for g in HOST]+ for w, c in sorted(jobs, key=lambda j: -j[0]):+ k = load.index(min(load))+ load[k] += w+ out[k].append(c)+ return out+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--shard", type=int, required=True)+ ap.add_argument("--of", type=int, required=True)+ a = ap.parse_args()+ times, failed = [], []+ for c in parts(a.of)[a.shard - 1]:+ print(f"::group::{c}", flush=True)+ t = time.time()+ ok = subprocess.run(c, shell=True).returncode == 0+ times.append((time.time() - t, c))+ print("::endgroup::", flush=True)+ if not ok:+ failed.append(c)+ print(f"::error::{c} failed", flush=True)+ for t, c in sorted(times, reverse=True):+ print(f"{t:7.0f} s {c}")+ sys.exit(1 if failed else 0)+++if __name__ == "__main__":+ main()diff --git a/tests/test_games.py b/tests/test_games.pyindex 10a6ea77..f9915d4a 100644--- a/tests/test_games.py+++ b/tests/test_games.py@@ -867,14 +867,18 @@ def main():ap.add_argument("--game")ap.add_argument("--out", default="build/test_games")ap.add_argument("--numplay", help="play the games inside this NumPlay.nwa instead")+ ap.add_argument("--shard", default="1/1", help="K/N: only every Nth app, from the Kth (CI's parts, tests/ci.py)")a = ap.parse_args()+ k, n = map(int, a.shard.split("/"))order = [g["id"] for g in json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "games","games.json"))) if g.get("default", True)]os.makedirs(a.out, exist_ok=True)failed = False- for name in GAMES:+ for i, name in enumerate(GAMES):if a.game and a.game != name or a.numplay and name not in order: # (a big game: on its own only)continue+ if i % n != k - 1:+ continueif a.numplay: # (NumPlay keeps its own copy, packed: tests/test_progress.py)problems, stack, recs = play(name, a.numplay, a.out, order.index(name))else: