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
70 changes: 54 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,40 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
build:
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: read # to fetch code (actions/checkout)

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
objects.githubusercontent.com:443
github.com:443
pypi.org:443
api.github.com:443

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false

- uses: actions/setup-python@v5
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.13'
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
python-version: '3.14'

- name: ⬇️ Install build dependencies
run: |
Expand All @@ -27,25 +46,44 @@ jobs:
- name: 🏗️ Build
run: python -m flit build

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: ./dist

# https://docs.pypi.org/trusted-publishers/using-a-publisher/
pypi-publish:
needs: build
environment: 'publish'

publish-py:
name: ⬆️ Upload release to PyPI
environment: 'publish'
if: github.repository_owner == 'torchbox' && github.event.action == 'published'
runs-on: ubuntu-latest
needs: build

permissions:
# Mandatory for trusted publishing
id-token: write
id-token: write # Mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
- github.com:443
- api.github.com:443
- ghcr.io:443
- pkg-containers.githubusercontent.com:443
- pypi.org:443
- upload.pypi.org:443
- files.pythonhosted.org:443
- fulcio.sigstore.dev:443
- rekor.sigstore.dev:443
- tuf-repo-cdn.sigstore.dev:443

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist

- name: 🚀 Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
with:
packages-dir: artifact/
print-hash: true
attestations: true
35 changes: 29 additions & 6 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,39 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
ruff:
name: Ruff
runs-on: ubuntu-latest
permissions:
contents: read # to fetch code (actions/checkout)

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
objects.githubusercontent.com:443
github.com:443
pypi.org:443
api.github.com:443

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

# Keep in sync with .pre-commit-config.yaml
- run: python -Im pip install --user ruff==0.15.14
# Keep in sync with .pre-commit-config.yaml
- run: python -Im pip install --user ruff==0.15.22

- name: Run ruff
working-directory: ./src
run: ruff check --output-format=github wagtail_bynder
- name: Run ruff
working-directory: ./src
run: ruff check --output-format=github wagtail_bynder
67 changes: 56 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
Expand All @@ -25,6 +25,7 @@ env:

jobs:
test-latest:
name: Test on latest versions (and postgres)
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -43,10 +44,24 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
objects.githubusercontent.com:443
github.com:443
pypi.org:443
api.github.com:443

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -64,25 +79,41 @@ jobs:
run: tox --installpkg ./dist/*.whl

- name: ⬆️ Upload coverage data
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-data-${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-postgres
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
retention-days: 1

test:
name: Test (sqlite)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
db: ["sqlite"]
steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
objects.githubusercontent.com:443
github.com:443
pypi.org:443
api.github.com:443

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -97,7 +128,7 @@ jobs:
run: tox --installpkg ./dist/*.whl

- name: ⬆️ Upload coverage data
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-data-${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite
path: .coverage.*
Expand All @@ -106,22 +137,36 @@ jobs:
retention-days: 1

coverage:
name: Combine & check coverage.
runs-on: ubuntu-latest
needs:
- test-latest
- test

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
objects.githubusercontent.com:443
github.com:443
pypi.org:443
api.github.com:443
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}

- run: python -Im pip install --upgrade coverage

- name: ⬇️ Download coverage data
uses: actions/download-artifact@v4
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: coverage-data-*
merge-multiple: true
Expand All @@ -134,7 +179,7 @@ jobs:
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: 📈 Upload HTML report
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: html-report
path: htmlcov
31 changes: 31 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# https://github.com/woodruffw/zizmor
name: Zizmor 🌈

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

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
zizmor:
name: Run zizmor 🌈
runs-on: ubuntu-latest
permissions:
security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Run zizmor 🌈
uses: zizmorcore/zizmor-action@6599ee8b7a49aef6a770f63d261d214911a7ce02 # v0.6.0
with:
persona: pedantic
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
autoupdate_schedule: 'quarterly'

default_language_version:
python: python3.13
python: python3.14

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -21,8 +21,8 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# keep in sync with .github/workflows/ruff.yml
rev: 'v0.15.14'
rev: 'v0.15.22'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [ --fix ]
- id: ruff-format