Skip to content

Commit

Permalink
Replace CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Stormheg committed Jun 10, 2024
1 parent 01fa75a commit 740cebd
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 57 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/ci.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/publish-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish to PyPI
on:
workflow_dispatch:
release:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
types: [prereleased]
jobs:
test:
uses: ./.github/workflows/test.yml

build:
needs: ['test']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Hatch
run: pip install hatch

- name: Build package distributions
run: hatch build

- uses: actions/upload-artifact@v4
with:
path: ./dist

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

name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v4

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/
print-hash: true
repository-url: https://test.pypi.org/legacy/
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish to PyPI
on:
release:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
types: [released]
jobs:
test:
uses: ./.github/workflows/test.yml

build:
needs: ['test']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Hatch
run: pip install hatch

- name: Build package distributions
run: hatch build

- uses: actions/upload-artifact@v4
with:
path: ./dist

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

name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v4

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/
print-hash: true
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

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

defaults:
run:
working-directory: ./src

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install hatch
run: pip install hatch

- name: Run linting
run: hatch fmt --check

testing:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
python: ["3.9", "3.10", "3.11", "3.12"]
experimental: [false]
toxenv: ["py"]
include:
# Test against future django-crispy-forms. Allowed to fail.
- python: "3.12"
toxenv: crispymain
experimental: true
# Test against future django-tables2. Allowed to fail.
- python: "3.12"
toxenv: tables2main
experimental: true
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python }}'

- name: Install dependencies
run: |
python -m pip install tox coverage
- name: Run tox targets for Python ${{ matrix.python }}
run: |
# Run only the tox environments that match the Python version
tox run -f py$(echo ${{ matrix.python }} | tr -d .)
coverage combine
coverage report
# Codecov does not support the .coverage file generated by coverage, so we convert it to xml
coverage xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 740cebd

Please sign in to comment.