Skip to content

Commit

Permalink
refactor: Rework test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
  • Loading branch information
Stranger6667 committed Sep 13, 2024
1 parent e9d1f60 commit c933efb
Show file tree
Hide file tree
Showing 192 changed files with 5,321 additions and 5,804 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,3 @@ updates:
directory: "/jsonschema"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/bindings/python"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/bench_helpers"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/perf-helpers"
schedule:
interval: "daily"
87 changes: 31 additions & 56 deletions .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,27 @@ jobs:
fetch-depth: 0
- uses: aevea/commitsar@v0.20.2

pre-commit:
name: Generic pre-commit checks
msrv:
name: MSRV
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-python@v5
- uses: dtolnay/rust-toolchain@stable
with:
python-version: 3.11
toolchain: "1.56.1"

- uses: Swatinem/rust-cache@v2

- run: pip install pre-commit
- run: pre-commit run --all-files
working-directory: ./bindings/python
- run: cargo build

test-stable:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
draft: [draft201909, draft202012]

name: Test ${{ matrix.draft }} (stable) on ${{ matrix.os}}
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -51,12 +48,10 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
workspaces: jsonschema
cache-all-crates: "true"
key: ${{ matrix.os }}-${{ matrix.draft }}
key: ${{ matrix.os }}

- run: cargo test --no-fail-fast --features ${{ matrix.draft }}
working-directory: ./jsonschema
- run: cargo test --no-fail-fast

build-wasm32:
strategy:
Expand All @@ -77,11 +72,9 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
workspaces: jsonschema
cache-all-crates: "true"

- run: cargo build --target ${{ matrix.target }} --no-default-features --features=cli
working-directory: ./jsonschema
- run: cargo build --target ${{ matrix.target }} --no-default-features

coverage:
name: Run test coverage
Expand All @@ -95,19 +88,16 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
workspaces: jsonschema
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
working-directory: ./jsonschema

- name: Generate coverage reports
run: cargo llvm-cov report --lcov --output-path lcov.info
working-directory: ./jsonschema

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand All @@ -117,6 +107,20 @@ jobs:
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
Expand All @@ -130,19 +134,15 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- run: python -m pip install tox
working-directory: ./bindings/python

- uses: dtolnay/rust-toolchain@stable

- name: Run ${{ matrix.python }} tox job
run: tox -e py
working-directory: ./bindings/python
- uses: hynek/setup-cached-uv@v2

- run: uv python install ${{ matrix.python-version }}

- run: uvx --with="tox" --with="tox-gh-actions" --with="tox-uv" tox -e py
working-directory: crates/jsonschema-py

fmt:
name: Rustfmt
Expand All @@ -155,19 +155,6 @@ jobs:
components: rustfmt

- run: cargo fmt --all -- --check
working-directory: ./jsonschema

- run: cargo fmt --all -- --check
working-directory: ./bindings/python

- run: cargo fmt --all -- --check
working-directory: ./bench_helpers

- run: cargo fmt --all -- --check
working-directory: ./perf-helpers

- run: cargo fmt --all -- --check
working-directory: ./jsonschema-test-suite

clippy:
name: Clippy
Expand All @@ -182,16 +169,8 @@ jobs:
components: clippy

- uses: Swatinem/rust-cache@v2
with:
workspaces: |
jsonschema
bindings/python

- run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: ./jsonschema

- run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: ./bindings/python

features:
name: Check features
Expand All @@ -204,11 +183,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
with:
workspaces: jsonschema
cache-all-crates: "true"

- uses: taiki-e/install-action@cargo-hack

- run: cargo hack check --feature-powerset --lib
working-directory: ./jsonschema
7 changes: 2 additions & 5 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ jobs:
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
with:
workspaces: jsonschema

- run: cargo install cargo-codspeed

- run: cargo codspeed build
working-directory: ./jsonschema
- run: cargo codspeed build -p jsonschema jsonschema

- uses: CodSpeedHQ/action@v3
with:
run: cargo codspeed run jsonschema
run: cargo codspeed run -p jsonschema jsonschema
token: ${{ secrets.CODSPEED_TOKEN }}
working-directory: ./jsonschema
59 changes: 21 additions & 38 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.7"
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build sdist
uses: messense/maturin-action@v1
with:
command: sdist
args: -m bindings/python/Cargo.toml --out dist

- 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 --out-dir dist
working-directory: crates/jsonschema-py

- name: Install sdist
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall
uv pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
Expand All @@ -56,17 +54,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
with:
target: x86_64
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
args: --release -m crates/jsonschema-py/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel - x86_64
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
Expand All @@ -87,16 +80,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release -m bindings/python/Cargo.toml --target universal2-apple-darwin --out dist --interpreter ${{ matrix.python-version }}
args: --release -m crates/jsonschema-py/Cargo.toml --target universal2-apple-darwin --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel - universal2
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
Expand All @@ -118,17 +106,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
args: --release -m crates/jsonschema-py/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel
shell: bash
run: |
Expand All @@ -155,7 +138,7 @@ jobs:
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
args: --release -m crates/jsonschema-py/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel on native architecture
if: matrix.target == 'x86_64'
run: |
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ on:

jobs:
rust-release:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: dtolnay/rust-toolchain@stable

- run: cargo login ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- run: cargo publish
working-directory: ./jsonschema

- run: cargo publish --manifest-path crates/Cargo.toml
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Rust
/jsonschema/target
/bindings/*/target
/bench_helpers/target
/jsonschema-test-suite/target
/crates/*/target
/target/
.hypothesis
.benchmarks
/jsonschema/Cargo.lock
/jsonschema-test-suite/Cargo.lock

# IDEs
/.idea
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "jsonschema/tests/suite"]
path = jsonschema/tests/suite
[submodule "testsuite"]
path = crates/jsonschema/tests/suite
url = https://github.com/json-schema-org/JSON-Schema-Test-Suite.git
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

### Added

- `jsonschema::compile` shortcut.

### Deprecated

- `cli` feature in favor of a separate `jsonschema-cli` crate.
- `draft201909` and `draft202012` features. The relevant functionality is now enabled by default.

## [0.18.3] - 2024-09-12

### Fixed
Expand Down
Loading

0 comments on commit c933efb

Please sign in to comment.