From 7fccf3bf944d0fd805c1b52932b7cbf662ddd7b1 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Thu, 12 Nov 2026 11:23:19 -0800 Subject: [PATCH 1/2] Harden CI with zizmor and GitHub Actions lockfiles --- .github/dependabot.yml | 15 +++++++- .github/workflows/actions.lock | 66 ++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 42 +++++++++++++++++----- .github/workflows/pypi.yml | 19 +++++----- DEVELOPER.md | 9 +++++ lint.sh | 1 + pyproject.toml | 3 +- 7 files changed, 137 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/actions.lock diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 91abb11f..848c0961 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,20 @@ version: 2 updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "quarterly" + groups: + actions: + patterns: + - "*" + cooldown: + default-days: 14 + - package-ecosystem: "pip" # See documentation for possible values directory: "/" # Location of package manifests schedule: - interval: "weekly" + interval: "quarterly" + cooldown: + default-days: 14 diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 00000000..ab1f4cda --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,66 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/ci.yml': + - 'actions/checkout@v6.0.2' + - 'actions/setup-python@v6.2.0' + '.github/workflows/pypi.yml': + - 'actions/checkout@v6.0.2' + - 'actions/download-artifact@v8.0.1' + - 'actions/setup-python@v6.2.0' + - 'actions/upload-artifact@v7.0.1' + - 'pypa/gh-action-pypi-publish@v1.14.0' + - 'sigstore/gh-action-sigstore-python@v3.3.0' +dependencies: + 'actions/checkout@v6.0.2': + ref: 'v6.0.2' + commit: 'sha1-de0fac2e4500dabe0009e67214ff5f5447ce83dd' + owner_id: 44036562 + repo_id: 197814629 + 'actions/download-artifact@v8.0.1': + ref: 'v8.0.1' + commit: 'sha1-3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c' + owner_id: 44036562 + repo_id: 192626254 + 'actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065': + ref: 'v5.6.0' + commit: 'sha1-a26af69be951a213d495a4c3e4e4022e16d87065' + owner_id: 44036562 + repo_id: 192625525 + 'actions/setup-python@v6.2.0': + ref: 'v6.2.0' + commit: 'sha1-a309ff8b426b58ec0e2a45f0f869d46889d02405' + owner_id: 44036562 + repo_id: 192625525 + 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f': + ref: 'v7.0.0' + commit: 'sha1-bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' + owner_id: 44036562 + repo_id: 192625955 + 'actions/upload-artifact@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-043fb46d1a93c77aae656e7c1c64a875d1fc6a0a' + owner_id: 44036562 + repo_id: 192625955 + 'pypa/gh-action-pypi-publish@v1.14.0': + ref: 'v1.14.0' + commit: 'sha1-cef221092ed1bacb1cc03d23a2d87d1d172e277b' + owner_id: 647025 + repo_id: 178055147 + uses: + - 'actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065' + 'sigstore/gh-action-sigstore-python@v3.3.0': + ref: 'v3.3.0' + commit: 'sha1-04cffa1d795717b140764e8b640de88853c92acc' + owner_id: 71096353 + repo_id: 508560980 + uses: + - 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' + - 'softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe' + 'softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe': + ref: 'v2.6.1' + commit: 'sha1-153bb8e04406b158c6c84fc1615b65b24149a1fe' + owner_id: 2242 + repo_id: 204253808 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db65e57a..253acc0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,18 @@ name: ci branches: - main +permissions: + contents: read + jobs: lint: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - uses: actions/setup-python@v6.2.0 with: python-version: "3.11" cache: pip @@ -21,14 +27,30 @@ jobs: - name: Run lints run: ./lint.sh + lockfile: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - name: Verify workflow lockfile + env: + GH_TOKEN: ${{ github.token }} + run: | + gh extension install github/gh-actions-lock --pin v0.4.1 + gh actions-lock --verify + test: runs-on: ubuntu-latest strategy: matrix: python_version: ["3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - uses: actions/setup-python@v6.2.0 with: python-version: ${{ matrix.python_version }} cache: pip @@ -42,8 +64,10 @@ jobs: long_test_linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - uses: actions/setup-python@v6.2.0 with: python-version: 3.13 cache: pip @@ -57,8 +81,10 @@ jobs: long_test_windows: runs-on: windows-latest steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - uses: actions/setup-python@v6.2.0 with: python-version: 3.13 cache: pip diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index df42e84a..3c88c87f 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -7,17 +7,20 @@ on: tags: - 'v*.*.*' +permissions: + contents: read + jobs: build: name: Build distribution 📦 runs-on: ubuntu-latest steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@v6.0.2 with: persist-credentials: false - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v6.2.0 with: python-version: "3.x" - name: Install pypa/build @@ -27,7 +30,7 @@ jobs: run: | python3 -m build - name: Store the distribution packages - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.0 + uses: actions/upload-artifact@v7.0.1 with: name: python-package-distributions path: dist/ @@ -46,12 +49,12 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1 + uses: actions/download-artifact@v8.0.1 with: name: python-package-distributions path: dist/ - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b #v1.14.0 + uses: pypa/gh-action-pypi-publish@v1.14.0 github-release: name: >- @@ -67,12 +70,12 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1 + uses: actions/download-artifact@v8.0.1 with: name: python-package-distributions path: dist/ - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@04cffa1d795717b140764e8b640de88853c92acc # v3.3.0 + uses: sigstore/gh-action-sigstore-python@v3.3.0 with: inputs: >- ./dist/*.tar.gz @@ -94,4 +97,4 @@ jobs: run: >- gh release upload "$GITHUB_REF_NAME" dist/** - --repo "$GITHUB_REPOSITORY" \ No newline at end of file + --repo "$GITHUB_REPOSITORY" diff --git a/DEVELOPER.md b/DEVELOPER.md index 2fbe45e2..08d0d4a3 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -2,6 +2,15 @@ This repository contains a number of GitHub Actions workflows to run benchmarks on a set of private, self-hosted, bare metal machines. +## CI checks + +Install the test dependencies with `python -m pip install '.[test]'`, then run +`./lint.sh`, which includes zizmor checks for `.github`. + +After changing action references or adding workflows under `.github/workflows`, +run `gh actions-lock` and commit the updated lockfile with the workflow changes. +This requires the [gh-actions-lock extension](https://github.com/github/gh-actions-lock). + ## The workflows There is a single user-facing workflow, `benchmark.yml`, that [reuses](https://docs.github.com/en/actions/using-workflows/reusing-workflows) the other workflows, prefixed with `_`. diff --git a/lint.sh b/lint.sh index 01d914fa..728be1f3 100755 --- a/lint.sh +++ b/lint.sh @@ -3,3 +3,4 @@ set -e python -m black --check bench_runner tests python -m flake8 bench_runner tests python -m pyright bench_runner +zizmor --offline --strict-collection .github diff --git a/pyproject.toml b/pyproject.toml index d17c2ab1..2e7e7045 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ test = [ "pytest==9.2.0", "pytest-cov==6.2.1", "pytest-xdist==3.8.0", + "zizmor==1.32.0", ] [tool.setuptools_scm] @@ -54,4 +55,4 @@ source = [ "bench_runner", "/tmp/pytest-of-*/pytest-*/*/repo/outer_venv/lib/python*/site-packages/bench_runner", "/tmp/pytest-of-*/pytest-*/*/repo/venv/lib/python*/site-packages/bench_runner", -] \ No newline at end of file +] From 1992d248bdd3a63e3d63783c9e82f2e93b3a25b6 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 13 Nov 2026 10:37:45 -0800 Subject: [PATCH 2/2] Use ubuntu-slim and the official zizmor hook --- .github/workflows/ci.yml | 2 +- .pre-commit-config.yaml | 17 ++++++++++------- pyproject.toml | 1 - 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 867e5ae1..53a2cf0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ permissions: jobs: lockfile: - runs-on: ubuntu-latest + runs-on: ubuntu-slim timeout-minutes: 10 steps: - uses: actions/checkout@v6.0.2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a29f954..d7b3cfdf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,16 @@ repos: - id: ruff-format args: [--exit-non-zero-on-fix] + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: 06a39750ec31860bb44f2acf67182c40016cd1e7 # frozen: v1.32.0 + hooks: + - id: zizmor + args: [--offline, --strict-collection, .github] + pass_filenames: false + files: ^\.github/ + types: [file] # Include actions.lock. + stages: [pre-commit] + - repo: local hooks: - id: pyright @@ -16,10 +26,3 @@ repos: pass_filenames: false types: [python] stages: [pre-commit] - - id: zizmor - name: zizmor - entry: zizmor --offline --strict-collection .github - language: system - pass_filenames: false - files: ^\.github/ - stages: [pre-commit] diff --git a/pyproject.toml b/pyproject.toml index 91fae091..90ccf27c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ test = [ "pytest==9.2.0", "pytest-cov==6.2.1", "pytest-xdist==3.8.0", - "zizmor==1.32.0", ] [tool.setuptools_scm]