Add CI for linting, formatting & testing #1
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: Dev CI (lint, format, test) | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
CARGO_TERM_COLOR: always | |
RUSTUP_MAX_RETRIES: 10 | |
jobs: | |
# Rust linting / formatting. | |
cargo-fmt: | |
name: "cargo fmt" | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
profile: minimal | |
- run: cargo fmt --all --check | |
cargo-clippy: | |
name: "cargo clippy" | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
profile: minimal | |
- uses: Swatinem/rust-cache@v2 | |
- name: "Clippy" | |
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings | |
cargo-udeps: | |
name: "cargo udeps" | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
profile: minimal | |
- name: "Install cargo udeps" | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-udeps | |
- name: "Udeps release" | |
run: cargo +nightly udeps --workspace --all-features --release | |
# Rust tests for supported platforms. | |
test-rust: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- build: stable | |
os: ubuntu-latest | |
rust: stable | |
- build: nightly | |
os: ubuntu-latest | |
rust: nightly | |
- build: macos | |
os: macos-latest | |
rust: stable | |
- build: win | |
os: windows-latest | |
rust: stable | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
- name: Basic build | |
run: cargo build --verbose | |
- name: Build docs | |
run: cargo doc --verbose | |
- name: Tests with default features | |
run: cargo test -p sas-lexer --all-targets | |
- name: Tests with macro_sep, serde features | |
run: cargo test -p sas-lexer --all-targets --features macro_sep --features serde | |
# Python linting / formatting. | |
ruff: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lint with Ruff | |
uses: astral-sh/ruff-action@v1 | |
with: | |
version: 0.7.2 | |
src: "src" | |
- name: Check formatting with Ruff | |
uses: astral-sh/ruff-action@v1 | |
with: | |
version: 0.7.2 | |
args: format --check | |
src: "src" | |
# Python tests. | |
py-linux: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
python-version: | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
- "3.13" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --manifest-path crates/sas-lexer-py/Cargo.toml | |
sccache: 'true' | |
manylinux: auto | |
- name: pytest | |
shell: bash | |
run: | | |
set -e | |
uv sync --no-install-project --dev | |
uv pip install sas-lexer --find-links dist --force-reinstall | |
# do not use uv run which will install package as editable | |
source .venv/bin/activate | |
pytest | |
py-windows: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: windows-latest | |
target: x64 | |
- runner: windows-latest | |
target: x86 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: ${{ matrix.platform.target }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --find-interpreter --manifest-path crates/sas-lexer-py/Cargo.toml | |
sccache: 'true' | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: pytest | |
shell: bash | |
run: | | |
set -e | |
uv sync --no-install-project --dev | |
uv pip install sas-lexer --find-links dist --force-reinstall | |
# do not use uv run which will install package as editable | |
source .venv/Scripts/activate | |
pytest | |
py-macos: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: macos-12 | |
target: x86_64 | |
- runner: macos-14 | |
target: aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --find-interpreter --manifest-path crates/sas-lexer-py/Cargo.toml | |
sccache: 'true' | |
- name: pytest | |
run: | | |
set -e | |
uv sync --no-install-project --dev | |
uv pip install sas-lexer --find-links dist --force-reinstall | |
# do not use uv run which will install package as editable | |
source .venv/bin/activate | |
pytest |