From 7c415ce543a4e83478668fa4627de560d96fb5d3 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 01:30:48 +0000 Subject: [PATCH 1/3] Add GitHub Actions CI workflow Builds src32_testbench, runs the Rust integration tests (with sol guest images built from source), the LLVM/SRC32 toolchain and Foundation tests with a Clang matching llvmlite's LLVM, the sol compiler tests and the WASM SDK package builder tests. Known-failing Rust tests run in a non-blocking job. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_0136WnUMfm3zqwkjjxGvwZZ8 --- .github/workflows/ci.yml | 161 +++++++++++++++++++++++++++++++++++++++ MEMORY.md | 5 ++ 2 files changed, 166 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aa3917b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,161 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + PYTHON_VERSION: "3.12" + +jobs: + # エミュレータ本体と src32_testbench。testbench は後続ジョブで使うので artifact にする。 + rust: + name: Rust (testbench build + integration tests) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Install system packages + run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Build src32_testbench + run: cargo build --bin src32_testbench + - uses: actions/upload-artifact@v4 + with: + name: src32_testbench + path: target/debug/src32_testbench + retention-days: 7 + - name: Build sol guest images used by integration tests + run: | + set -e + mkdir -p target/guests + build() { + python3 tools/solc/solc.py compile "$1" -o "target/guests/$2.a" + python3 tools/asm/asm.py "target/guests/$2.a" -o "$2.bin" + } + build dos.sol dos + build tinybasic.sol tinybasic + build tools/dsfs/dsfs_smoke.sol dsfs_guest + # lib の単体テストは外部リポジトリ (s3w2_core) の golden ファイルを include するため + # CI ではビルドできない。tests/ の統合テストだけを実行する。 + # strek_* と tb_load_live は既知の失敗/外部ファイル依存なので known-failures ジョブへ回す。 + - name: Integration tests + run: | + set -e + args=() + for f in tests/*.rs; do + name=$(basename "$f" .rs) + case "$name" in + strek_micro|strek_smoke|strek_verify|tb_load_live) continue ;; + esac + args+=(--test "$name") + done + cargo test --no-fail-fast "${args[@]}" -- \ + --skip dos_hex_returns_to_shell_at_800_cycles_per_frame + + # 失敗が既知のテスト。結果は見えるようにするが CI 全体は落とさない。 + known-failures: + name: Rust known failures (non-blocking) + runs-on: ubuntu-24.04 + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - name: Install system packages + run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Build sol guest images + run: | + set -e + mkdir -p target/guests + python3 tools/solc/solc.py compile dos.sol -o target/guests/dos.a + python3 tools/asm/asm.py target/guests/dos.a -o dos.bin + python3 tools/solc/solc.py compile tinybasic.sol -o target/guests/tinybasic.a + python3 tools/asm/asm.py target/guests/tinybasic.a -o tinybasic.bin + - name: Known-failing tests + run: | + cargo test --no-fail-fast --test strek_micro --test strek_smoke --test tb_load_live + cargo test --test dos_smoke dos_hex_returns_to_shell_at_800_cycles_per_frame + + # LLVM/SRC32 ツールチェーンと Foundation の受け入れテスト (test_toolchain.py)。 + # Clang は llvmlite が組み込んでいる LLVM と同じメジャーバージョンを使う + # (ずれると -O1/-O2 で "icmp constexprs" エラーになる)。 + toolchain: + name: LLVM toolchain + Foundation tests + needs: rust + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: tools/llvm-src32/requirements.txt + - name: Install Python packages + run: pip install -r tools/llvm-src32/requirements.txt + - name: Install Clang matching llvmlite + run: | + set -e + major=$(python -c "import llvmlite.binding as l; print(l.llvm_version_info[0])") + echo "llvmlite uses LLVM $major" + wget -q https://apt.llvm.org/llvm.sh + sudo bash llvm.sh "$major" + echo "CLANG=/usr/bin/clang-$major" >> "$GITHUB_ENV" + - uses: actions/download-artifact@v4 + with: + name: src32_testbench + path: target/debug + - name: Prepare testbench + run: | + chmod +x target/debug/src32_testbench + echo "SRC32_TESTBENCH=$PWD/target/debug/src32_testbench" >> "$GITHUB_ENV" + - name: Toolchain tests + run: | + "$CLANG" --version + python -m unittest discover -s tools/llvm-src32 -p 'test_*.py' -v + + # sol コンパイラ / VM / LSP。Foundation の実行テストは testbench を使う。 + solc: + name: sol compiler tests + needs: rust + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - run: pip install pytest + - uses: actions/download-artifact@v4 + with: + name: src32_testbench + path: target/debug + - name: Prepare testbench + run: | + chmod +x target/debug/src32_testbench + echo "SRC32_TESTBENCH=$PWD/target/debug/src32_testbench" >> "$GITHUB_ENV" + - name: pytest + run: python -m pytest tools/solc -q + + wasm-sdk: + name: WASM expansion card SDK + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Package builder tests + run: python -m unittest discover -s sdk/wasm-expansion-card -p 'test_*.py' -v diff --git a/MEMORY.md b/MEMORY.md index be234c3..63c9951 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -1041,3 +1041,8 @@ - Real race: a tick between the timer ACK and the IRQC W1C leaves the timer source high with PENDING cleared, so no edge ever arrives again (ticks froze at -O2 cached/pipeline). handle_irqs re-checks the sticky TIMER_PENDING (0x80040188) after draining IRQC. Keep that re-check whenever the ACK -> W1C window contains work. - src32_testbench has no UART (0x80040000 unmapped): debug_write with len > 0 or kernel_panic output bus-errors in the kernel. The test only uses len 0 and a bad pointer. - tests/phase1 (R1=42): counters A/B advance, fault process dies with 0x80050002 and its RAM is zeroed, A's word never gets the faulting store, SERVICE probe sleeps 7..8 ticks (priority preemption), error codes, proc_exit code, then 10-tick slices alone alternate A/B. The hook snapshots the probe mailbox each tick because exit zeroes it. Mutations (slice expiry disabled; region switch disabled) fail the test. test_toolchain.py test_foundation_phase1_kernel runs O0/O1/O2 x 4 CPUs with --frames 30; JIT passed manually. With Clang 18 in the cloud container, kernel-trap and syscall-user examples fail at -O1/-O2 ("icmp constexprs") on the base commit too. + +## GitHub Actions CI (2026-10-22) +- .github/workflows/ci.yml: `rust` builds src32_testbench (debug, uploaded as artifact) and runs the `tests/*.rs` integration tests only; lib unit tests cannot build without the external `s3w2_core` golden .inc files. Guest images dos.bin / tinybasic.bin / dsfs_guest.bin are gitignored, so CI builds them from dos.sol, tinybasic.sol and tools/dsfs/dsfs_smoke.sol (solc.py compile -> asm.py) into the repo root before `cargo test`. +- Known failures are kept visible in the non-blocking `known-failures` job: strek_micro, strek_smoke, tb_load_live, and dos_smoke `dos_hex_returns_to_shell_at_800_cycles_per_frame`. strek_verify needs a sibling Tiny-Basic checkout and is not run. When one of these is fixed, move it back into the blocking job. +- `toolchain` installs Clang of the same LLVM major as llvmlite (`llvmlite.binding.llvm_version_info`) via apt.llvm.org and sets CLANG; a mismatched Clang (e.g. Ubuntu's Clang 18 vs llvmlite's LLVM 20+) fails -O1/-O2 with "icmp constexprs". It also needs cmake + ninja (present on ubuntu-24.04 runners). From 44883779a8f00ac889aa9b81754967713efcab29 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 01:38:44 +0000 Subject: [PATCH 2/3] Add release workflow for binaries and VS Code extensions Pushing a v* tag builds cpt32, cpt32-tool and src32_testbench for Linux, Windows and macOS and both VS Code extensions, and publishes them as a GitHub Release. CI also packages the extensions on every PR, and actions move to their Node 24 releases. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_0136WnUMfm3zqwkjjxGvwZZ8 --- .github/workflows/ci.yml | 46 +++++++++++--- .github/workflows/release.yml | 115 ++++++++++++++++++++++++++++++++++ MEMORY.md | 1 + 3 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa3917b..186bcfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,12 @@ jobs: name: Rust (testbench build + integration tests) runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Install system packages run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Build src32_testbench @@ -69,12 +69,12 @@ jobs: runs-on: ubuntu-24.04 continue-on-error: true steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Install system packages run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Build sol guest images @@ -98,8 +98,8 @@ jobs: needs: rust runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} cache: pip @@ -133,8 +133,8 @@ jobs: needs: rust runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - run: pip install pytest @@ -153,9 +153,35 @@ jobs: name: WASM expansion card SDK runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Package builder tests run: python -m unittest discover -s sdk/wasm-expansion-card -p 'test_*.py' -v + + # VS Code 拡張 (sol / SRC32 アセンブリ) の .vsix を作って artifact に残す。 + vscode-extensions: + name: VS Code extensions + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: 22 + cache: npm + cache-dependency-path: tools/vscode-sol-syntax/package-lock.json + - name: Package vscode-sol-syntax + working-directory: tools/vscode-sol-syntax + run: | + npm ci + npm run compile + npx vsce package --no-dependencies + - name: Package vscode-src32-asm-syntax + working-directory: tools/vscode-src32-asm-syntax + run: npx --yes @vscode/vsce@3 package --no-dependencies + - uses: actions/upload-artifact@v4 + with: + name: vscode-extensions + path: tools/*/*.vsix + retention-days: 7 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c381d1e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,115 @@ +name: Release + +# v で始まるタグ (例: v0.1.0) を push すると、各 OS の cpt32 バイナリと +# VS Code 拡張の .vsix を GitHub Releases に公開する。 +# 手動実行 (workflow_dispatch) と、このファイルを変更した PR では Release を作らず、 +# 成果物を artifact に残すだけ (ビルドの確認用)。 +on: + push: + tags: ["v*"] + pull_request: + paths: [".github/workflows/release.yml"] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + binaries: + name: Binaries (${{ matrix.name }}) + strategy: + fail-fast: false + matrix: + include: + - name: linux-x86_64 + os: ubuntu-24.04 + ext: "" + - name: windows-x86_64 + os: windows-latest + ext: ".exe" + - name: macos-arm64 + os: macos-latest + ext: "" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v5 + - name: Install system packages + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + key: release + - name: Build + run: cargo build --release --bin cpt32 --bin cpt32-tool --bin src32_testbench + - name: Stage files + shell: bash + run: | + set -e + name="cpt32-${GITHUB_REF_NAME//\//-}-${{ matrix.name }}" + dir="dist/$name" + mkdir -p "$dir/assets" + for bin in cpt32 cpt32-tool src32_testbench; do + cp "target/release/$bin${{ matrix.ext }}" "$dir/" + done + cp README.md LICENSE THIRD_PARTY_NOTICES.txt ACKNOWLEDGEMENTS.md config.example.yaml "$dir/" + cp -r licenses "$dir/" + cp assets/bios.rom "$dir/assets/" + echo "PKG_NAME=$name" >> "$GITHUB_ENV" + - name: Archive (zip) + if: runner.os == 'Windows' + shell: pwsh + run: Compress-Archive -Path "dist/$env:PKG_NAME" -DestinationPath "dist/$env:PKG_NAME.zip" + - name: Archive (tar.gz) + if: runner.os != 'Windows' + run: tar -C dist -czf "dist/$PKG_NAME.tar.gz" "$PKG_NAME" + - uses: actions/upload-artifact@v4 + with: + name: binaries-${{ matrix.name }} + path: | + dist/*.zip + dist/*.tar.gz + if-no-files-found: error + + vscode-extensions: + name: VS Code extensions + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: 22 + cache: npm + cache-dependency-path: tools/vscode-sol-syntax/package-lock.json + - name: Package vscode-sol-syntax + working-directory: tools/vscode-sol-syntax + run: | + npm ci + npm run compile + npx vsce package --no-dependencies + - name: Package vscode-src32-asm-syntax + working-directory: tools/vscode-src32-asm-syntax + run: npx --yes @vscode/vsce@3 package --no-dependencies + - uses: actions/upload-artifact@v4 + with: + name: vscode-extensions + path: tools/*/*.vsix + if-no-files-found: error + + release: + name: Publish GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + needs: [binaries, vscode-extensions] + runs-on: ubuntu-24.04 + permissions: + contents: write + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - uses: softprops/action-gh-release@v2 + with: + files: dist/* + generate_release_notes: true + prerelease: ${{ contains(github.ref_name, '-') }} diff --git a/MEMORY.md b/MEMORY.md index 63c9951..13f32bd 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -1046,3 +1046,4 @@ - .github/workflows/ci.yml: `rust` builds src32_testbench (debug, uploaded as artifact) and runs the `tests/*.rs` integration tests only; lib unit tests cannot build without the external `s3w2_core` golden .inc files. Guest images dos.bin / tinybasic.bin / dsfs_guest.bin are gitignored, so CI builds them from dos.sol, tinybasic.sol and tools/dsfs/dsfs_smoke.sol (solc.py compile -> asm.py) into the repo root before `cargo test`. - Known failures are kept visible in the non-blocking `known-failures` job: strek_micro, strek_smoke, tb_load_live, and dos_smoke `dos_hex_returns_to_shell_at_800_cycles_per_frame`. strek_verify needs a sibling Tiny-Basic checkout and is not run. When one of these is fixed, move it back into the blocking job. - `toolchain` installs Clang of the same LLVM major as llvmlite (`llvmlite.binding.llvm_version_info`) via apt.llvm.org and sets CLANG; a mismatched Clang (e.g. Ubuntu's Clang 18 vs llvmlite's LLVM 20+) fails -O1/-O2 with "icmp constexprs". It also needs cmake + ninja (present on ubuntu-24.04 runners). +- Release (CD): .github/workflows/release.yml. Pushing a `v*` tag builds cpt32 / cpt32-tool / src32_testbench in release mode for linux-x86_64, windows-x86_64 and macos-arm64 (archive also carries README, licenses, config.example.yaml, assets/bios.rom) plus both VS Code .vsix files, and publishes them with softprops/action-gh-release (tags containing `-` become prereleases). PRs touching release.yml and workflow_dispatch run the builds without publishing. CI's `vscode-extensions` job also packages the .vsix on every PR. From ed0a9c3e218593a84ff68f1d6029749ef52e9183 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 01:45:41 +0000 Subject: [PATCH 3/3] CI: run WAX tool and loader tests, keep known failures non-red Add tools/wax and foundation/tests/wax (from the merged WAX loader) to the Python test job. Known-failing Rust tests now use step-level continue-on-error so they no longer show as a failed PR check. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_0136WnUMfm3zqwkjjxGvwZZ8 --- .github/workflows/ci.yml | 14 +++++++++----- MEMORY.md | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 186bcfc..7f9f8aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,11 +63,11 @@ jobs: cargo test --no-fail-fast "${args[@]}" -- \ --skip dos_hex_returns_to_shell_at_800_cycles_per_frame - # 失敗が既知のテスト。結果は見えるようにするが CI 全体は落とさない。 + # 失敗が既知のテスト。ステップ単位の continue-on-error なので PR のチェックは緑のまま、 + # 結果はこのジョブのログ (Known-failing tests ステップ) で確認できる。 known-failures: name: Rust known failures (non-blocking) runs-on: ubuntu-24.04 - continue-on-error: true steps: - uses: actions/checkout@v5 - name: Install system packages @@ -86,6 +86,7 @@ jobs: python3 tools/solc/solc.py compile tinybasic.sol -o target/guests/tinybasic.a python3 tools/asm/asm.py target/guests/tinybasic.a -o tinybasic.bin - name: Known-failing tests + continue-on-error: true run: | cargo test --no-fail-fast --test strek_micro --test strek_smoke --test tb_load_live cargo test --test dos_smoke dos_hex_returns_to_shell_at_800_cycles_per_frame @@ -127,9 +128,10 @@ jobs: "$CLANG" --version python -m unittest discover -s tools/llvm-src32 -p 'test_*.py' -v - # sol コンパイラ / VM / LSP。Foundation の実行テストは testbench を使う。 + # sol コンパイラ / VM / LSP、WAX ツール、Foundation WAX ローダのホストテスト。 + # sol の Foundation 実行テストは testbench を使う。 solc: - name: sol compiler tests + name: sol compiler + WAX tests needs: rust runs-on: ubuntu-24.04 steps: @@ -147,7 +149,9 @@ jobs: chmod +x target/debug/src32_testbench echo "SRC32_TESTBENCH=$PWD/target/debug/src32_testbench" >> "$GITHUB_ENV" - name: pytest - run: python -m pytest tools/solc -q + run: python -m pytest tools/solc tools/wax -q + - name: Foundation WAX loader (host) + run: python -m unittest discover -s foundation/tests/wax -v wasm-sdk: name: WASM expansion card SDK diff --git a/MEMORY.md b/MEMORY.md index d133f18..177f816 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -1053,6 +1053,6 @@ ## GitHub Actions CI (2026-10-22) - .github/workflows/ci.yml: `rust` builds src32_testbench (debug, uploaded as artifact) and runs the `tests/*.rs` integration tests only; lib unit tests cannot build without the external `s3w2_core` golden .inc files. Guest images dos.bin / tinybasic.bin / dsfs_guest.bin are gitignored, so CI builds them from dos.sol, tinybasic.sol and tools/dsfs/dsfs_smoke.sol (solc.py compile -> asm.py) into the repo root before `cargo test`. -- Known failures are kept visible in the non-blocking `known-failures` job: strek_micro, strek_smoke, tb_load_live, and dos_smoke `dos_hex_returns_to_shell_at_800_cycles_per_frame`. strek_verify needs a sibling Tiny-Basic checkout and is not run. When one of these is fixed, move it back into the blocking job. +- Known failures run in the `known-failures` job with step-level continue-on-error (PR check stays green, results in the step log): strek_micro, strek_smoke, tb_load_live, and dos_smoke `dos_hex_returns_to_shell_at_800_cycles_per_frame`. strek_verify needs a sibling Tiny-Basic checkout and is not run. When one of these is fixed, move it back into the blocking job. - `toolchain` installs Clang of the same LLVM major as llvmlite (`llvmlite.binding.llvm_version_info`) via apt.llvm.org and sets CLANG; a mismatched Clang (e.g. Ubuntu's Clang 18 vs llvmlite's LLVM 20+) fails -O1/-O2 with "icmp constexprs". It also needs cmake + ninja (present on ubuntu-24.04 runners). - Release (CD): .github/workflows/release.yml. Pushing a `v*` tag builds cpt32 / cpt32-tool / src32_testbench in release mode for linux-x86_64, windows-x86_64 and macos-arm64 (archive also carries README, licenses, config.example.yaml, assets/bios.rom) plus both VS Code .vsix files, and publishes them with softprops/action-gh-release (tags containing `-` become prereleases). PRs touching release.yml and workflow_dispatch run the builds without publishing. CI's `vscode-extensions` job also packages the .vsix on every PR.