Skip to content

Checks

Checks #568

Workflow file for this run

name: Checks
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
test-rust:
name: Test Rust (internal tests)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.86"
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build and test
run: |
cargo test
test-rust-ext:
name: Test ubuntu, ${{ matrix.python-version }} Rust extension
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [
"3.9",
"3.10",
"3.11",
"3.12",
# NOTE: 3.13 is absent since we test it in the OS job matrix
"3.14",
]
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.86"
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
# NOTE: We test multiple times in different dependency configurations
- name: Test (no extra deps)
shell: bash
run: |
pip install -r requirements/test.txt
pip install build
# ensure isolated build
python -m build
pip install dist/*.whl
pytest tests/ -s -v
env:
RUST_BACKTRACE: 1
# Pydantic doesn't support 3.14 yet
- if: ${{ matrix.python-version != '3.14' }}
run: pip install pydantic
- name: Test (all deps)
shell: bash
run: |
pip install tzdata
pytest tests/ -s -v
env:
RUST_BACKTRACE: 1
# Debug mode sometimes surfaces issues not seen in release mode
- name: Test (debug mode)
shell: bash
run: |
pip install -e .
pytest tests/ -s -v
env:
RUST_BACKTRACE: 1
test-os:
name: Test ${{ matrix.os }}, 3.13 ${{ matrix.no_build_ext && 'pure Python' || 'Rust extension' }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
no_build_ext: ["", "1"]
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.86"
- name: Add win32 target
if: ${{ matrix.os == 'windows' }}
run: rustup target add i686-pc-windows-msvc
- uses: actions/setup-python@v5
if: ${{ !(matrix.os == 'windows') }}
with:
python-version: '3.13'
# ensure 32-bit target is tested
# FUTURE: Add a linux 32-bit target
- uses: actions/setup-python@v5
if: ${{ matrix.os == 'windows' }}
with:
python-version: '3.13'
architecture: x86
- name: Install and test
shell: bash
run: |
pip install -r requirements/test.txt
pip install build
# ensure isolated build
python -m build
pip install dist/*.whl
pytest tests/ -s -v
# NOTE: yes, we test twice: once with optional deps, once without
pip install tzdata pydantic
pytest tests/ -s -v
env:
WHENEVER_NO_BUILD_RUST_EXT: ${{ matrix.no_build_ext }}
RUST_BACKTRACE: 1
test-pure-python:
name: Test ubuntu, ${{ matrix.python-version }} pure Python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [
"3.9",
"3.10",
"3.11",
"3.12",
# NOTE: 3.13 is absent since we test it in the OS job matrix
# NOTE: If pypy/pytest fails, if could be due to
# https://github.com/pypy/pypy/issues/3959
"3.14",
"pypy3.9",
"pypy3.10"
]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- run: |
pip install -r requirements/test.txt
pip install build
python -m build
pip install dist/*.whl
env:
WHENEVER_NO_BUILD_RUST_EXT: "1"
# NOTE: we end up running pytest twice in the following sections.
# This is because we want to test the code with and without optional dependencies.
- run: pytest tests/
- run: pip install tzdata
# Pydantic doesn't support 3.14 yet
- if: ${{ matrix.python-version != '3.14' }}
run: pip install pydantic
# NOTE: we only care about coverage once. We arbitrarily choose 3.12 for that
- if: ${{ matrix.python-version == '3.12' }}
run: |
pytest tests/ --cov=whenever --cov-report term-missing
- if: ${{ matrix.python-version != '3.12' }}
run: |
pytest tests/
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.86"
components: "clippy, rustfmt"
- run: |
pip install .
pip install -r requirements/lint.txt
make ci-lint
env:
WHENEVER_NO_BUILD_RUST_EXT: "1"
check-docstrings:
name: Ensure docstrings in Rust/Python are synced
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: |
pip install .
python generate_docstrings.py > fresh_docstrings.rs
if diff -q fresh_docstrings.rs src/docstrings.rs > /dev/null; then
echo "OK"
else
echo "Rust docstrings are stale. Please run 'python generate_docstrings.py > src/docstrings.rs'";
# output the actual diff
diff -u fresh_docstrings.rs src/docstrings.rs
exit 1
fi
env:
WHENEVER_NO_BUILD_RUST_EXT: "1"
typecheck:
name: Typecheck Python code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: |
pip install .
pip install -r requirements/typecheck.txt
pip install -r requirements/test.txt
make typecheck
env:
WHENEVER_NO_BUILD_RUST_EXT: "1"
# https://github.com/marketplace/actions/alls-green#why
all-green:
name: Are all checks green?
if: always()
needs:
- test-rust-ext
- test-rust
- test-os
- test-pure-python
- lint
- check-docstrings
- typecheck
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}