Skip to content

Fixes to parser

Fixes to parser #827

Workflow file for this run

name: Rust
# Contains checks:
# - That the code compiles
# - That the code and markdown complies with formatting
# - Lints (using clippy) to find *issues*
# - That crates that are published are publish-able
# - Testing
# - Standard Rust integration, unit tests and specification tests
# - (if main, not draft PR or 'fuzz-me' label) Fuzz tests (parser and checker)
# - That the WASM edition works and types are ok
# - (if main or 'compiler-performance') spins off the performance-and-size tests
on:
push: { branches: [main] }
pull_request: { branches: ['**'] }
env:
CARGO_TERM_COLOR: always
CACHE_PATHS: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
jobs:
validity:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check source is valid
run: cargo check --workspace
- name: Check binary
run: cargo check --bin ezno
formating:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check Rust formatting with rustfmt
run: cargo fmt --all --check
- uses: kaleidawave/release-downloader@improvements
env: { GH_TOKEN: '${{ env.GH_TOKEN }}' }
with: { items: 'kaleidawave/simple-toml-parser@canary[format]' }
- name: Check 'Cargo.toml' formatting
run: format cargo --check
tests:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install spectra
uses: kaleidawave/release-downloader@improvements
env: { GH_TOKEN: '${{ env.GH_TOKEN }}' }
with: { 'items': 'kaleidawave/experiments@assets[spectra]' }
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
parser:
- 'parser/**'
checker:
- 'checker/**'
- name: Run parser tests
if: steps.changes.outputs.parser == 'true' || github.ref_name == 'main'
run: cargo test -p ezno-parser --no-fail-fast
- name: Run parser examples
if: steps.changes.outputs.parser == 'true' || github.ref_name == 'main'
run: |
CORPUS_URL="https://gist.githubusercontent.com/kaleidawave/6708f604bc403021b56cb54ea50cac62/raw/javascript_files.txt"
curl -s "$CORPUS_URL" | while IFS= read -r URL; do
FILENAME="${URL##*/}"
curl -s "$URL" > $FILENAME
cargo run -p ezno-parser --example parse $FILENAME
done
- name: Run checker tests
if: steps.changes.outputs.checker == 'true' || github.ref_name == 'main'
run: cargo test -p ezno-checker
- name: Run checker tests
if: steps.changes.outputs.checker == 'true' || github.ref_name == 'main'
run: |
COMMAND='cargo run -p ezno-checker --example runner -- --interactive --rpc'
spectra test specification/specification.md '$COMMAND' --lists-as-expected
- name: Run CLI and base tests
run: cargo test
# TODO merge into tests
test262:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with: { filters: "parser: ['parser/**']" }
- run: bash run.sh
if: ${{ steps.changes.outputs.parser == 'true' }}
working-directory: test262
- uses: actions/upload-artifact@v4
if: ${{ steps.changes.outputs.parser == 'true' }}
with:
name: test262-results
path: test262/out
retention-days: 28
extras:
runs-on: ubuntu-latest
needs: validity
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: denoland/setup-deno@v1
with: { deno-version: v1.x }
- uses: actions/setup-node@v4
with: { node-version: 23 }
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- 'src/**'
parser:
- 'parser/**'
checker:
- 'checker/**'
- name: Check parser without extras
if: steps.changes.outputs.parser == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run: cargo check -p ezno-parser --no-default-features
- name: Check parser generator
if: steps.changes.outputs.parser == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run: cargo test -p ezno-ast-generator
- name: Check checker without default features
if: steps.changes.outputs.checker == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run: cargo check -p ezno-checker --no-default-features
- name: Build and test WASM
if: github.ref_name == 'main' || !github.event.pull_request.draft
timeout-minutes: 5
working-directory: src/js-cli-and-library
shell: bash
run: |
# TODO `cargo check --target wasm32-unknown-unknown --lib` might be good enough
rustup target add wasm32-unknown-unknown
npm ci
npm run build
node ./dist/cli.cjs info
deno run -A ./dist/cli.mjs info
npm run run-tests
# npx -p typescript tsc --strict --pretty ./build/ezno_lib.d.ts
# echo "debug checked with TSC"
# TEMP check
cargo run -p ezno-parser --example parse ./build/ezno_lib.d.ts --type-definition-module
# WIP
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.src == 'true' || github.ref_name == 'main'
with:
name: wasm-build
overwrite: true
path: src/js-cli-and-library/dist
retention-days: 90
fuzzing_parser:
if: ${{ github.ref == 'main' || !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'fuzz-me') }}
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
matrix:
fuzz-target: [module_roundtrip_naive, module_roundtrip_structured]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v4
with:
# TODO fuzz specific key & paths
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-fuzz
uses: kaleidawave/release-downloader@improvements
env: { GH_TOKEN: '${{ env.GH_TOKEN }}' }
# TODO this is temporary as cargo-fuzz releases are awaiting a fix
# https://github.com/rust-fuzz/cargo-fuzz/pull/365
# should do versioning etc
with: { items: 'kaleidave/experiments/cargo-fuzz@assets[cargo-fuzz-x86_64-unknown-linux]' }
- uses: dorny/paths-filter@v3
id: changes
with: { filters: "parser: ['parser/**']" }
- name: Run fuzzing
env:
SHORT_CIRCUIT: true
# CARGO_TARGET_DIR: ../../target
if: steps.changes.outputs.parser == 'true'
working-directory: parser/fuzz
run: |
cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=120
# if ${{ env.SHORT_CIRCUIT }}; then
# else
# CARGO_TARGET_DIR=../../target cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=300 -fork=1 -ignore_crashes=1
# if test -d fuzz/artifacts; then
# find fuzz/artifacts -type f -print -exec xxd {} \; -exec cargo fuzz fmt -s none module_roundtrip_structured {} \;; false;
# fi
# fi
fuzzing_checker:
if: ${{ github.ref == 'main' || !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'fuzz-me') }}
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 15
# TODO
continue-on-error: true
strategy:
matrix:
fuzz-target: [check_project_naive]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v4
with:
# TODO fuzz specific key & paths
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-fuzz
uses: kaleidawave/release-downloader@improvements
env: { GH_TOKEN: '${{ env.GH_TOKEN }}' }
# TODO this is temporary as cargo-fuzz releases are awaiting a fix
# https://github.com/rust-fuzz/cargo-fuzz/pull/365
# should do versioning etc
with: { items: 'kaleidave/experiments/cargo-fuzz@assets[cargo-fuzz-x86_64-unknown-linux]' }
- uses: dorny/paths-filter@v3
id: changes
with: { filters: "checker: ['checker/**']" }
- name: Run fuzzing
if: steps.changes.outputs.checker == 'true'
run: cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=120
working-directory: checker/fuzz
clippy:
if: github.ref_name == 'main' || !github.event.pull_request.draft
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Lint code with clippy
run: cargo clippy
publish-ability:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dorny/paths-filter@v3
id: changes
with: { filters: "manifests: ['*.toml']" }
- uses: kaleidawave/release-downloader@improvements
if: steps.changes.outputs.manifests == 'true'
env: { GH_TOKEN: '${{ env.GH_TOKEN }}' }
with: { items: 'kaleidawave/crates-release-gh-action@assets[crates-release]' }
- name: Check that it will publish to crates.io
if: steps.changes.outputs.manifests == 'true'
run: crates-release verify
performance:
runs-on: ubuntu-latest
needs: validity
steps:
- name: Kick off other workflow if main or a PR with 'compiler-performance' label
if: github.ref_name == 'main' || contains(github.event.pull_request.labels.*.name, 'compiler-performance')
run: gh workflow run performance.yml --ref "${{ github.head_ref }}" -R kaleidawave/ezno
env: { GH_TOKEN: '${{ github.token }}' }