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 <[email protected]>
  • Loading branch information
Stranger6667 committed Sep 13, 2024
1 parent e9d1f60 commit feefcc9
Show file tree
Hide file tree
Showing 193 changed files with 5,327 additions and 5,866 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"
91 changes: 33 additions & 58 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/[email protected]

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.65"

- 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 -p jsonschema

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,32 +107,42 @@ 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
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- 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
- run: cargo hack check --feature-powerset
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
67 changes: 25 additions & 42 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 @@ -49,24 +47,19 @@ jobs:
runs-on: macos-12
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
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 @@ -80,23 +73,18 @@ jobs:
runs-on: macos-12
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
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 @@ -110,25 +98,20 @@ jobs:
runs-on: windows-2022
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
target: [ x64, x86 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
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 @@ -143,7 +126,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
target: [ x86_64, i686, aarch64 ]
steps:
- uses: actions/checkout@v4
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
Loading

0 comments on commit feefcc9

Please sign in to comment.