From dfffdc73afc0f44d22c07ea03d61a45c1da29051 Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:03:41 +0000 Subject: [PATCH 1/4] Determine changes in ci --- .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a82d3119..ea848669 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 @@ -84,6 +132,8 @@ jobs: cargo test -- --include-ignored build-docs: + name: "Build docs" + runs-on: ubuntu-latest steps: @@ -106,6 +156,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: @@ -140,19 +193,39 @@ 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=$(ls crates/karva_benchmark/benches/*walltime*.rs | xargs -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.prepare-walltime-benchmarks.outputs.projects) }} steps: - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -189,8 +262,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 From 695c47035ce1ff63af9c93e8ee9f619478727de6 Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:08:05 +0000 Subject: [PATCH 2/4] Run build binaries through ci --- .github/workflows/build.yml | 17 ++++++----------- .github/workflows/ci.yml | 8 ++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6852954c..16944af8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,19 +2,14 @@ name: Build / Release PyPI on: push: - branches: - - main - tags: - v[0-9]*.[0-9]*.[0-9]* - pull_request: - permissions: {} jobs: linux: - name: Build wheels (Linux, ${{ matrix.platform.target }}) + name: build wheels (Linux, ${{ matrix.platform.target }}) runs-on: ubuntu-latest strategy: matrix: @@ -49,7 +44,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: @@ -83,7 +78,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: @@ -115,7 +110,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: @@ -148,7 +143,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 @@ -173,7 +168,7 @@ jobs: path: dist release: - name: Release + name: "release" runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea848669..f4d23af5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,6 +131,14 @@ 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" From ccfe5a7899cd91bc24171ca00d1040a4a7c76f03 Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:13:02 +0000 Subject: [PATCH 3/4] Update workflows --- .github/workflows/build.yml | 2 ++ .github/workflows/ci.yml | 2 +- .github/workflows/diff.yml | 2 +- .github/workflows/release-drafter.yml | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16944af8..d5f4dbf6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,8 @@ on: tags: - v[0-9]*.[0-9]*.[0-9]* + workflow_call: + permissions: {} jobs: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4d23af5..39b81ffd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -233,7 +233,7 @@ jobs: strategy: matrix: - project: ${{ fromJson(needs.prepare-walltime-benchmarks.outputs.projects) }} + project: ${{ fromJson(needs.generate-walltime-benchmarks-matrix.outputs.projects) }} steps: - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 diff --git a/.github/workflows/diff.yml b/.github/workflows/diff.yml index 6667e5c4..d43bbe75 100644 --- a/.github/workflows/diff.yml +++ b/.github/workflows/diff.yml @@ -1,4 +1,4 @@ -name: Project Diff +name: Diff on: pull_request: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e32bda58..51238353 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -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 From ecf1fa95cba4e3b62eaa3b3ffe573be0fa3bb7ca Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:18:11 +0000 Subject: [PATCH 4/4] Fix pre-commit --- .github/workflows/ci.yml | 4 +++- .pre-commit-config.yaml | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39b81ffd..ef427e3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -220,7 +220,9 @@ jobs: - name: List walltime benchmark projects id: list-projects run: | - projects=$(ls crates/karva_benchmark/benches/*walltime*.rs | xargs -n 1 basename -s .rs | jq -R -s -c 'split("\n")[:-1]') + 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: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6020afd7..0a36e61f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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