refactor: Use enum dispatch #446
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
pull_request: {} | |
push: | |
branches: | |
- master | |
jobs: | |
commitsar: | |
name: Verify commit messages | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: aevea/[email protected] | |
msrv: | |
name: MSRV | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: "1.70" | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo build -p jsonschema | |
test-stable: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-15, windows-2022] | |
name: Test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: "true" | |
key: ${{ matrix.os }} | |
- run: cargo test --no-fail-fast | |
test-wasm: | |
name: Test on WASM | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup `wasmtime` | |
uses: bytecodealliance/actions/wasmtime/setup@v1 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: 'wasm32-wasip1' | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: "true" | |
- run: cargo test --target wasm32-wasip1 --no-default-features -p jsonschema | |
coverage: | |
name: Run test coverage | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: "true" | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Run tests | |
run: cargo llvm-cov --no-report --all-features | |
- name: Generate coverage reports | |
run: cargo llvm-cov report --lcov --output-path lcov.info | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: coverage | |
files: lcov.info | |
fail_ci_if_error: true | |
lints-python: | |
name: Python lints | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hynek/setup-cached-uv@v2 | |
- run: uvx ruff check python tests-py | |
working-directory: crates/jsonschema-py | |
- run: uvx mypy python | |
working-directory: crates/jsonschema-py | |
test-python: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-15, windows-2022] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: hynek/setup-cached-uv@v2 | |
- run: uv python install ${{ matrix.python-version }} | |
- run: uvx --with=".[tests]" --python='${{ matrix.python-version }}' pytest tests-py | |
working-directory: crates/jsonschema-py | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- run: cargo fmt --all -- --check | |
lints-rust: | |
name: Rust lints | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo clippy --all-targets --all-features -- -D warnings | |
- run: cargo clippy --all-targets --all-features -- -D warnings | |
working-directory: profiler | |
- run: cargo clippy --all-targets --all-features -- -D warnings | |
working-directory: fuzz | |
lints-wasm: | |
name: Rust lints on WASM | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
targets: 'wasm32-wasip1' | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: "true" | |
- run: cargo clippy --target wasm32-wasip1 --no-default-features --all-targets -p jsonschema | |
check-releases-rust: | |
name: Check Rust releases | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo publish --dry-run -p referencing | |
- run: cargo publish --dry-run -p jsonschema | |
- run: cargo publish --dry-run -p jsonschema-cli | |
check-releases-python: | |
name: Check Python releases | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- uses: hynek/setup-cached-uv@v2 | |
- run: uv python install "3.12" | |
- run: uv build --sdist --wheel --out-dir dist | |
working-directory: crates/jsonschema-py | |
- run: uv venv | |
working-directory: crates/jsonschema-py | |
- name: Install sdist | |
run: | | |
uv pip install dist/*.tar.gz --force-reinstall | |
working-directory: crates/jsonschema-py | |
- name: Install wheel | |
run: | | |
uv pip install dist/*.whl --force-reinstall | |
working-directory: crates/jsonschema-py | |
features: | |
name: Check features | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- uses: taiki-e/install-action@cargo-hack | |
- run: cargo hack check --feature-powerset | |
fuzz: | |
name: Fuzzing ${{ matrix.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ["builder", "validation", "referencing"] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@nightly | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo install cargo-fuzz | |
- run: cargo +nightly fuzz run --release ${{ matrix.target }} fuzz/seeds -- -dict=fuzz/dict -max_total_time=60 | |
spell-check: | |
name: Spell Check | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: crate-ci/typos@master |