Skip to content

Commit

Permalink
Thank you Doctor Zizmor!
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Nov 3, 2024
1 parent c9017d1 commit 2f6a85b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 10 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- uses: hynek/build-and-inspect-python-package@v2
id: baipp
Expand Down Expand Up @@ -56,11 +57,14 @@ jobs:
- uses: hynek/setup-cached-uv@v2

- name: Prepare & run Nox
env:
PYTHON: ${{ matrix.python-version }}

run: >
uvx
--with "tomli; python_version<'3.11'"
nox
--python ${{ matrix.python-version }}
--python $PYTHON
--sessions tests
-- --installpkg dist/*.whl
Expand All @@ -80,6 +84,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
Expand Down Expand Up @@ -118,6 +124,8 @@ jobs:
fail-fast: false
matrix:
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}
env:
PYTHON: ${{ matrix.python-version }}

steps:
- name: Download pre-built packages
Expand All @@ -137,15 +145,15 @@ jobs:
uvx
--with "tomli; python_version<'3.11'"
nox
--python ${{ matrix.python-version }}
--python $PYTHON
--sessions mypy_api
- name: Check using Pyright
run: >
uvx
--with "tomli; python_version<'3.11'"
nox
--python ${{ matrix.python-version }}
--python $PYTHON
--sessions pyright_api
mypy-pkg:
Expand Down Expand Up @@ -197,6 +205,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
27 changes: 20 additions & 7 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Build & maybe upload PyPI package
name: Build & upload PyPI package

on:
push:
Expand All @@ -10,32 +10,38 @@ on:
- published
workflow_dispatch:

permissions:
attestations: write
contents: read
id-token: write

jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: 'true'


# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
environment: release-test-pypi
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.repository_owner == 'hynek' && github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
Expand All @@ -46,16 +52,21 @@ jobs:
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
repository-url: https://test.pypi.org/legacy/


# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
environment: release-pypi
if: github.event.action == 'published'
if: github.repository_owner == 'hynek' && github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
Expand All @@ -65,3 +76,5 @@ jobs:

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
38 changes: 38 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# https://github.com/woodruffw/zizmor
name: GitHub Actions Security Analysis with Zizmor

on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

permissions:
contents: read


jobs:
zizmor:
name: Zizmor latest via Cargo
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Get zizmor
run: cargo install zizmor
- name: Run zizmor
run: zizmor --format sarif . > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
# Optional category for the results
# Used to differentiate multiple results for one commit
category: zizmor

0 comments on commit 2f6a85b

Please sign in to comment.