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
5 changes: 5 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# act configuration
# See: https://github.com/nektos/act

# Mount project directory into containers (faster, uses host files)
--bind
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish to PyPI

on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Build sdist
run: python setup.py sdist

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
gh release create "$TAG_NAME" \
--title "Release $TAG_NAME" \
--generate-notes \
dist/*.tar.gz

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Add next version template to CHANGES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Extract version from tag (v2.0.1 -> 2.0.1)
TAG_NAME=${GITHUB_REF#refs/tags/v}

# Increment patch version (2.0.1 -> 2.0.2)
IFS='.' read -r MAJOR MINOR PATCH <<< "$TAG_NAME"
NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"

# Add template for next version at the top (after # CHANGELOG)
awk -v version="$NEXT_VERSION" '
/^# CHANGELOG/ {
print;
print "";
print "## " version " (development) [SUPERSEDED]";
print "";
print "- nothing changed yet";
print "";
next
}
{print}
' CHANGES.md > CHANGES.md.tmp && mv CHANGES.md.tmp CHANGES.md

# Commit and push
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGES.md
git commit -m "Prepare CHANGES.md for v$NEXT_VERSION [skip ci]"
git push origin HEAD:master
95 changes: 95 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10.x", "3.11.x", "3.12.x"]
django-version:
- "Django>=4.2,<5.0"
- "Django>=5.0,<5.1"
- "Django>=5.1,<6.0"
- "git+https://github.com/django/django.git@main"
exclude:
# Django 7.0 dev requires Python >= 3.12
- python-version: "3.10.x"
django-version: "git+https://github.com/django/django.git@main"
- python-version: "3.11.x"
django-version: "git+https://github.com/django/django.git@main"

steps:
- uses: actions/checkout@v4
if: ${{ !env.ACT }}

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

- name: Create isolated virtualenv
run: |
python -m venv /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}

- name: Install dependencies
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
pip install -q --upgrade pip
pip install -q "${{ matrix.django-version }}"
pip install -q -e ".[test]"

- name: Lint with flake8
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
flake8 django_permanent

- name: Run tests with coverage
continue-on-error: ${{ contains(matrix.django-version, 'git+https://') }}
env:
COVERAGE_FILE: /tmp/.coverage-${{ github.run_id }}-${{ strategy.job-index }}
TEST_VERBOSITY: 2
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
coverage run runtests.py

- name: Coverage report (CI)
if: matrix.python-version == '3.12' && matrix.django-version == 'Django>=5.2' && !env.ACT
continue-on-error: true
env:
COVERAGE_FILE: /tmp/.coverage-${{ github.run_id }}-${{ strategy.job-index }}
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
if [ -f "$COVERAGE_FILE" ]; then
coverage report --skip-covered --skip-empty --precision=1
else
echo "No coverage file found at $COVERAGE_FILE"
fi

- name: Coverage report (act - detailed)
if: matrix.python-version == '3.12' && matrix.django-version == 'Django>=5.2' && env.ACT
continue-on-error: true
env:
COVERAGE_FILE: /tmp/.coverage-${{ github.run_id }}-${{ strategy.job-index }}
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
if [ -f "$COVERAGE_FILE" ]; then
coverage report -m --skip-covered --skip-empty --precision=2
else
echo "No coverage file found at $COVERAGE_FILE"
fi

- name: Upload coverage to Coveralls
if: matrix.python-version == '3.12' && matrix.django-version == 'Django>=5.2' && !env.ACT
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERAGE_FILE: /tmp/.coverage-${{ github.run_id }}-${{ strategy.job-index }}
run: |
source /tmp/venv-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}/bin/activate
pip install -q coveralls
coveralls
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ MANIFEST
*.egg*
build/
src/
.coverage
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

Loading