opencode/.github/workflows/codemode-rust.yml
kommander e9164a18ce test(codemode): check test262 parity in both directions
The runner now checks the files in the reference's skipped.txt too: those
that pass here are gaps on the TypeScript side, listed with a category in
test262/reference-gaps.txt. The check fails when an unlisted one passes, a
listed one fails here or leaves the reference's skipped.txt, or the
reference's own runner, through test262/reference.ts, passes a listed one.
Each category says whether Rust really has the behaviour or passes through
a looser check where the reference is strict on purpose.
2026-11-18 18:54:08 +01:00

125 lines
4.9 KiB
YAML

name: Codemode Rust
on:
pull_request:
paths:
- packages/codemode-rust/**
- packages/codemode/**
- .github/workflows/codemode-rust.yml
push:
branches: [dev]
paths:
- packages/codemode-rust/**
- packages/codemode/**
- .github/workflows/codemode-rust.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
working-directory: packages/codemode-rust
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
jobs:
check:
name: Format, Clippy and tests
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 20
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
# The toolchain, profile and components come from packages/codemode-rust/rust-toolchain.toml.
- name: Install Rust
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
shared-key: codemode-rust-dev
workspaces: packages/codemode-rust -> target
- run: cargo fmt --check
- run: cargo clippy --locked --workspace --all-targets -- -D warnings
# Includes bench/tests/conformance.rs, which checks every conformance case against the reference outcome.
- run: cargo test --locked --workspace
conformance-fresh:
name: Conformance expectations match the reference
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: ./.github/actions/setup-bun
# A change to the reference fails here until the Rust side is updated and the expectations regenerated.
- name: Regenerate every expectation from ../codemode
run: bun conformance/generate.ts
- name: Check nothing changed
run: |
git status --porcelain -- conformance
git diff --exit-code -- conformance
test -z "$(git status --porcelain -- conformance)"
test262:
name: test262 parity
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 20
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
# The reference runs the listed reference gaps, so its dependencies are installed too.
- uses: ./.github/actions/setup-bun
- name: Install Rust
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
shared-key: codemode-rust-release
workspaces: packages/codemode-rust -> target
- name: Read the pinned test262 revision
id: test262
run: |
revision=$(jq -r .revision ../codemode/test/test262/manifest.json)
echo "revision=$revision" >> "$GITHUB_OUTPUT"
echo "checkout=$HOME/.cache/test262-$revision" >> "$GITHUB_OUTPUT"
- name: Cache the test262 checkout
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ steps.test262.outputs.checkout }}
key: test262-${{ steps.test262.outputs.revision }}
# Parity both ways. Fails when a file fails that test262/rust-skipped.txt does not list, or a listed file
# passes; and when a file the reference skips passes but test262/reference-gaps.txt does not list it, or a
# listed file fails here, leaves the reference's skipped.txt, or passes in the reference.
- name: Run test262 against rust-skipped.txt and reference-gaps.txt
env:
TEST262_CHECKOUT: ${{ steps.test262.outputs.checkout }}
run: bash test262/run.sh
bench:
name: Benchmarks (informational)
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 20
# Shared runners are too noisy for a performance gate; the numbers go to the job summary only.
continue-on-error: true
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: ./.github/actions/setup-bun
- name: Install Rust
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
shared-key: codemode-rust-release
workspaces: packages/codemode-rust -> target
- name: Install GNU time
run: "[ -x /usr/bin/time ] || (sudo apt-get update && sudo apt-get install -y time)"
- run: cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed
- name: Compare with the reference
env:
ITERATIONS: "5"
COLD_RUNS: "5"
PLUGIN_RUNS: "2000"
run: bash bench/compare.sh
- name: Write the results to the job summary
run: cat bench/RESULTS.md >> "$GITHUB_STEP_SUMMARY"