Skip to content

New release workflow #1060

New release workflow

New release workflow #1060

Workflow file for this run

name: Continuous Integration
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
permissions: {}
env:
PYTHON_VERSION: "3.14"
BENCHMARK_PYTHON_VERSION: "3.13"
jobs:
determine_changes:
name: "determine changes"
runs-on: ubuntu-latest
outputs:
# Flag that is raised when any code is changed
code: ${{ steps.check_code.outputs.changed }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Determine merge base
id: merge_base
env:
BASE_REF: ${{ github.event.pull_request.base.ref || 'main' }}
run: |
sha=$(git merge-base HEAD "origin/${BASE_REF}")
echo "sha=${sha}" >> "$GITHUB_OUTPUT"
- name: Check if there was any code related change
id: check_code
env:
MERGE_BASE: ${{ steps.merge_base.outputs.sha }}
run: |
if git diff --quiet "${MERGE_BASE}...HEAD" -- \
. \
':!docs/' \
':!CODE_OF_CONDUCT.md' \
':!CONTRIBUTING.md' \
':!LICENSE' \
':!pyproject.toml' \
':!README.md' \
':!zensical.toml' \
; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
pre-commit:
name: "pre commit"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3.1.4
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: stable
override: true
- name: Install Rustfmt nightly
run: |
rustup component add rustfmt --toolchain nightly
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
cargo-test:
name: "cargo test (${{ matrix.os }} ${{ matrix.python-version }})"
runs-on: ${{ matrix.os }}
needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
strategy:
max-parallel: 18
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.14"]
env:
PYTHON_VERSION: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: Update Rust toolchain
run: rustup update
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
pip install pytest
- name: Build wheels
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
with:
command: build
- name: Run tests
env:
PYO3_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: |
cargo test -- --include-ignored
build-docs:
name: "Build docs"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Prepare docs
run: uv run --script scripts/prepare_docs.py
- name: Build docs
run: uv run --isolated --only-group docs zensical build
benchmarks:
name: Run benchmarks
runs-on: ubuntu-latest
needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
channel: stable
cache-target: release
bins: cargo-codspeed
- name: Setup Python
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1
with:
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
- name: Build wheels
run: |
pip install maturin pytest
maturin build
- name: Generate resources
run: python crates/karva_benchmark/resources/generate.py
- name: Build benchmarks
run: cargo codspeed build -p karva_benchmark
- name: Run benchmarks
uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: cargo codspeed run --bench karva
mode: simulation
generate-walltime-benchmarks-matrix:
name: "prepare walltime benchmarks"
runs-on: ubuntu-latest
needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
outputs:
projects: ${{ steps.list-projects.outputs.projects }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: List walltime benchmark projects
id: list-projects
run: |
projects=$(find crates/karva_benchmark/benches -name '*walltime*.rs' -type f -print0 | \
xargs -0 -n 1 basename -s .rs | \
jq -R -s -c 'split("\n")[:-1]')
echo "projects=${projects}" >> "$GITHUB_OUTPUT"
benchmarks-walltime:
name: "walltime benchmarks (${{ matrix.project }})"
runs-on: ubuntu-latest # This should be `codspeed-macro`
needs: [determine_changes, generate-walltime-benchmarks-matrix]
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
strategy:
matrix:
project: ${{ fromJson(needs.generate-walltime-benchmarks-matrix.outputs.projects) }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
channel: stable
cache-target: release
bins: cargo-codspeed
- name: Setup Python
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1
with:
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
- name: Build wheels
run: |
uv run --no-project --with maturin maturin build
- name: Build benchmarks
run: cargo codspeed build -m walltime
- name: Run benchmarks
uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: cargo codspeed run --bench ${{ matrix.project }}
mode: walltime
project-diff:
name: "run project diff"
needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true') }}
permissions:
pull-requests: write
uses: ./.github/workflows/diff.yml