Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ name: Build / Release PyPI

on:
push:
branches:
- main

tags:
- v[0-9]*.[0-9]*.[0-9]*

pull_request:
workflow_call:

permissions: {}

jobs:
linux:
name: Build wheels (Linux, ${{ matrix.platform.target }})
name: build wheels (Linux, ${{ matrix.platform.target }})
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -49,7 +46,7 @@ jobs:
path: dist

musllinux:
name: Build wheels (Linux Musl, ${{ matrix.platform.target }})
name: build wheels (Linux Musl, ${{ matrix.platform.target }})
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -83,7 +80,7 @@ jobs:
path: dist

windows:
name: Build wheels (Windows, ${{ matrix.platform.target }})
name: build wheels (Windows, ${{ matrix.platform.target }})
runs-on: windows-latest
strategy:
matrix:
Expand Down Expand Up @@ -115,7 +112,7 @@ jobs:
path: dist

macos:
name: Build wheels (macOS, ${{ matrix.platform.target }})
name: build wheels (macOS, ${{ matrix.platform.target }})
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand Down Expand Up @@ -148,7 +145,7 @@ jobs:
path: dist

sdist:
name: Build source distribution
name: build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
Expand All @@ -173,7 +170,7 @@ jobs:
path: dist

release:
name: Release
name: "release"

runs-on: ubuntu-latest

Expand Down
101 changes: 94 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,50 @@ env:
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' \
; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

pre-commit:
name: "pre commit"

runs-on: ubuntu-latest

steps:
Expand All @@ -38,8 +81,13 @@ jobs:
- 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
Expand Down Expand Up @@ -83,7 +131,17 @@ jobs:
run: |
cargo test -- --include-ignored

build-binaries:
name: "build binaries"

needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}

uses: ./.github/workflows/build.yml

build-docs:
name: "Build docs"

runs-on: ubuntu-latest

steps:
Expand All @@ -106,6 +164,9 @@ jobs:

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:
Expand Down Expand Up @@ -140,19 +201,41 @@ jobs:
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: Run walltime benchmarks
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:
- affect_walltime
- pydantic_settings_walltime
- pydantic_walltime
- sqlmodel_walltime
- typer_walltime
project: ${{ fromJson(needs.generate-walltime-benchmarks-matrix.outputs.projects) }}

steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
Expand Down Expand Up @@ -189,8 +272,12 @@ jobs:
mode: walltime

coverage:
name: "coverage"
runs-on: ubuntu-latest

needs: determine_changes
if: ${{ (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}

env:
CARGO_TERM_COLOR: always

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/diff.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Project Diff
name: Diff

on:
pull_request:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
pull-requests: write

steps:
- name: Wait for labels to be added
# Don't shout at the PR author right away
run: sleep 20

- uses: mheap/github-action-required-labels@8afbe8ae6ab7647d0c9f0cfa7c2f939650d22509 # v5.5.1
with:
mode: minimum
Expand Down
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,3 @@ repos:
rev: v1.18.0
hooks:
- id: zizmor

- repo: https://github.com/rhysd/actionlint
rev: v1.7.9
hooks:
- id: actionlint
Loading