General internal project improvements #24
Workflow file for this run
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: Tests | |
# Run when a new PR is created for main branch: | |
on: | |
pull_request: | |
branches: | |
- "main" | |
jobs: | |
# This can be used as the status check for branch protection, saves added each and every actual test job to the rules. | |
# https://github.com/marketplace/actions/alls-green | |
check_all_passed: # This job does nothing and is only used for the branch protection | |
if: always() | |
runs-on: ubuntu-latest | |
needs: | |
- qa | |
- tests_docs | |
- tests_py_rust | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
id: all-green | |
with: | |
jobs: ${{ toJSON(needs) }} | |
# Everything but qa might be skipped if nothing's changed in its folder: | |
allowed-skips: tests_docs, tests_py_rust, | |
qa: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
cache: pip | |
- uses: ./.github/actions/install-pre-commit | |
# Formatting and checking uses nightly rather than stable: | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt, clippy | |
- name: Run QA | |
run: | | |
./dev_scripts/test.sh qa | |
whos_changed: | |
uses: ./.github/workflows/whos-changed.yml | |
tests_docs: | |
name: Test documentation build | |
needs: whos_changed | |
# Only run if applicable things have changed: | |
if: needs.whos_changed.outputs.docs-changed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
python-version: "3.12" | |
cache: true | |
cache-dependency-path: 'docs/pdm.lock' | |
- name: Install dependencies | |
run: | | |
pdm sync -p ./docs | |
- name: Test docs | |
run: | | |
./dev_scripts/test.sh docs | |
tests_py_rust: | |
needs: whos_changed | |
# Only run if applicable things have changed: | |
if: needs.whos_changed.outputs.py-rust-changed == 'true' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Ubuntu test on all versions: | |
- {python: "3.8", os: "ubuntu-latest"} | |
- {python: "3.9", os: "ubuntu-latest"} | |
- {python: "3.10", os: "ubuntu-latest"} | |
- {python: "3.11", os: "ubuntu-latest"} | |
- {python: "3.12", os: "ubuntu-latest"} | |
# Make sure other os types work on newest version: | |
# - { python: "3.12", os: "macOS-latest" } # Mac uses 10x minutes, skipping for now considering devs usually use mac and v similar to linux | |
- {python: "3.12", os: "windows-latest",} # 2x minutes, most different architecture so worth testing | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "./py_rust -> target" | |
cache-on-failure: "true" | |
cache-all-crates: "true" | |
- name: Install nextest | |
uses: taiki-e/install-action@nextest | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ matrix.python }}" | |
- name: Setup venv (problems with the automatic creating in scripts as it uses pipx and for some | |
reason ends with wrong py version) | |
run: | | |
pip install virtualenv | |
python -m virtualenv ./py_rust/.venv | |
- name: Run tests (linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
./dev_scripts/test.sh py_rust | |
- name: Run tests (windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
bash ./dev_scripts/test.sh py_rust | |