59 programs, each with what the reader must do with it: the language specification's 21 example programs, unchanged (those that run held to their results, the rest to the code that names the first construct the reader cannot hold exactly, or the example's own error), and a program for each construct with a reference written without it. stdgates.qasm applies every standard gate once, and its reference writes each in U and CX alone. Expectations: refused (a code), warns (every warning's code), deterministic (every shot's outcome), distribution (exact outcome probabilities), expectations (exact Pauli values), equivalent (a reference's unitary up to a global phase), exact (the bit-exact circuit takes it or refuses it with a code), outputs, timing and calibrations. bundle.json holds the cases with their text inline for builds that read no files; a test holds it equal to the files. CI: wai-quantum-lang.yml runs the reader's tests, the corpus natively, the reader built without the lowerings, and the corpus under wasm32-wasip2 by wasmtime; wai-web's wasm32 tests read every case through the page's engine (the wasm32 count goes from 8 to 9). Co-Authored-By: Claude Opus 5.5 <[email protected]>
147 lines
6.5 KiB
YAML
147 lines
6.5 KiB
YAML
name: wai-quantum OpenQASM reader
|
|
|
|
# The OpenQASM reader every surface uses (wai/wai-quantum/src/qasm.rs and
|
|
# src/qasm/): its unit tests (the lexer, the parser, the elaborator, the
|
|
# diagnostic table and the page that documents it, every modifier against the
|
|
# matrix it must equal, every condition compiled to steps against every value
|
|
# of its bits), and the OpenQASM 3 conformance corpus
|
|
# (wai/quantum-conformance/qasm3/: the specification's example programs and a
|
|
# program for each construct, each with what the reader must do with it).
|
|
#
|
|
# The corpus runs natively, where a second test holds its bundle equal to its
|
|
# files, and under wasm32-wasip2 by wasmtime, where the cases come from the
|
|
# bundle the test compiles in. The browser build runs the corpus too
|
|
# (wai-web-wasm.yml, wai-web's wasm32 tests). The reader is also built without
|
|
# the lowerings (features quantum_lang and quantum_toolchain), as the edge
|
|
# component builds it.
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'wai/wai-quantum/**'
|
|
- 'wai/quantum-conformance/qasm3/**'
|
|
- 'rust-toolchain.toml'
|
|
- '.github/workflows/wai-quantum-lang.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'wai/wai-quantum/**'
|
|
- 'wai/quantum-conformance/qasm3/**'
|
|
- 'rust-toolchain.toml'
|
|
- '.github/workflows/wai-quantum-lang.yml'
|
|
|
|
jobs:
|
|
relevant:
|
|
name: does this change touch it
|
|
runs-on: linux-arm64
|
|
outputs:
|
|
run: ${{ steps.gate.outputs.run }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
- id: gate
|
|
run: |
|
|
set -euo pipefail
|
|
r=$(python3 scripts/pr-touches-paths.py .github/workflows/wai-quantum-lang.yml \
|
|
"${{ github.event.pull_request.base.sha }}" \
|
|
"${{ github.event.pull_request.head.sha }}")
|
|
echo "this change touches the OpenQASM reader: $r"
|
|
echo "run=$r" >> "$GITHUB_OUTPUT"
|
|
|
|
native:
|
|
name: reader and corpus · linux
|
|
needs: relevant
|
|
if: needs.relevant.outputs.run == 'true'
|
|
runs-on: linux
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- name: Install Rust 1.98.0
|
|
shell: bash
|
|
run: |
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
command -v rustup >/dev/null 2>&1 || \
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.98.0
|
|
rustup toolchain install 1.98.0 --profile minimal
|
|
rustup default 1.98.0
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
# A module filter is satisfied by any one test of the module, so each
|
|
# module's tests are required by name to have run.
|
|
- name: The reader's unit tests
|
|
shell: bash
|
|
working-directory: wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
cargo test --locked --release --features full --lib qasm 2>&1 | tee "$RUNNER_TEMP/qasm.log"
|
|
grep -qE '^test result: ok\. [1-9][0-9]+ passed; 0 failed' "$RUNNER_TEMP/qasm.log" || { echo "::error::the reader's tests did not pass"; exit 1; }
|
|
for m in qasm::diag qasm::lex qasm::parse qasm::value qasm::lang_tests qasm::tests quantum_toolchain::tests::qasm_round_trip; do
|
|
grep -q "^test $m.* \.\.\. ok$" "$RUNNER_TEMP/qasm.log" || { echo "::error::no test of $m ran"; exit 1; }
|
|
done
|
|
- name: The conformance corpus
|
|
shell: bash
|
|
working-directory: wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
cargo test --locked --release --features full --test qasm3_conformance 2>&1 | tee "$RUNNER_TEMP/corpus.log"
|
|
grep -q 'test result: ok. 2 passed; 0 failed' "$RUNNER_TEMP/corpus.log" || { echo "::error::the corpus did not pass"; exit 1; }
|
|
- name: The reader without the lowerings
|
|
shell: bash
|
|
working-directory: wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
cargo check --locked --no-default-features --features quantum_lang --lib
|
|
cargo check --locked --no-default-features --features quantum_toolchain --lib
|
|
|
|
wasip2:
|
|
name: corpus under wasm32-wasip2 (wasmtime)
|
|
needs: relevant
|
|
if: needs.relevant.outputs.run == 'true'
|
|
runs-on: linux
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- name: Install Rust 1.98.0 with the wasm32-wasip2 target
|
|
shell: bash
|
|
run: |
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
command -v rustup >/dev/null 2>&1 || \
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.98.0
|
|
rustup toolchain install 1.98.0 --profile minimal
|
|
rustup default 1.98.0
|
|
rustup target add --toolchain 1.98.0 wasm32-wasip2
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
# The release binary, pinned by version and SHA-256, rather than a build from source.
|
|
- name: Install wasmtime 49.0.2
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
[ "$(uname -m)" = x86_64 ] || { echo "::error::the pinned wasmtime archive is x86_64; this host is $(uname -m)"; exit 1; }
|
|
if ! command -v xz >/dev/null 2>&1; then
|
|
SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo"
|
|
$SUDO apt-get update -qq
|
|
$SUDO apt-get install -y -qq xz-utils
|
|
fi
|
|
v=49.0.2
|
|
f="wasmtime-v$v-x86_64-linux.tar.xz"
|
|
curl --proto '=https' --tlsv1.2 -sSfL -o "$RUNNER_TEMP/$f" \
|
|
"https://github.com/bytecodealliance/wasmtime/releases/download/v$v/$f"
|
|
echo "a4d6e9e3a5a60f527cf7793d674c48930c80c2e8977995b8a275cad3254b9322 $RUNNER_TEMP/$f" | sha256sum -c -
|
|
tar -xJf "$RUNNER_TEMP/$f" -C "$RUNNER_TEMP"
|
|
echo "$RUNNER_TEMP/wasmtime-v$v-x86_64-linux" >> "$GITHUB_PATH"
|
|
# A debug build, so integer overflow panics instead of wrapping. The test
|
|
# that reads the corpus's files has no wasip2 build; the one that runs the
|
|
# cases from the compiled-in bundle does.
|
|
- name: The conformance corpus under wasmtime
|
|
shell: bash
|
|
working-directory: wai/wai-quantum
|
|
env:
|
|
CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime
|
|
run: |
|
|
set -euo pipefail
|
|
cargo test --locked --target wasm32-wasip2 --features full --test qasm3_conformance 2>&1 | tee "$RUNNER_TEMP/wasip2.log"
|
|
grep -q 'test result: ok. 1 passed; 0 failed' "$RUNNER_TEMP/wasip2.log" || { echo "::error::the corpus did not pass under wasip2"; exit 1; }
|