Skip to content

add nox and test against different Python and Django versions #276

add nox and test against different Python and Django versions

add nox and test against different Python and Django versions #276

Workflow file for this run

name: test
on:
pull_request:
push:
branches: [main]
workflow_call:
inputs:
os:
default: "ubuntu-latest"
description: "Comma-delineated list of OS targets to run tests on"
required: false
type: string
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
FORCE_COLOR: "1"
PYTHONUNBUFFERED: "1"
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-version-matrix.outputs.include }}
os: ${{ steps.set-os-matrix.outputs.os }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
pyproject-file: pyproject.toml
- id: set-version-matrix
run: |
uv run noxfile.py --session gha_matrix
- id: set-os-matrix
run: |
os_input="${{ inputs.os || 'ubuntu-latest' }}"
# -R reads raw string, split(",") creates array, map(gsub(...)) trims whitespace, -c outputs compact JSON
echo "os=$(echo '${{ inputs.os || 'ubuntu-latest' }}' | jq -R -c 'split(",") | map(gsub("^ *| *$"; ""))')" >> "$GITHUB_OUTPUT"
test:
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: generate-matrix
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.generate-matrix.outputs.os) }}
include: ${{ fromJSON(needs.generate-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
pyproject-file: pyproject.toml
- name: Run tests
run: |
uv run noxfile.py --session "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')"