GitHub actions fork pr fix & Django 5.0.x
Added To Test Matrix
#104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests, Evaluate Coverage, Package & Release | |
on: | |
push: {} | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
branches: | |
- master | |
pull_request_target: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
branches: | |
- master | |
jobs: | |
run-tests: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
max-parallel: 5 | |
matrix: | |
os: [ubuntu-20.04] | |
python-version: [python3.9, python3.8] | |
django-version: [django5.0, django4.0, django3.2, django3.1, django3.0] | |
drf-version: [drf3.14] | |
name: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.drf-version }} | |
steps: | |
- name: "Set job environments" | |
run: | | |
matrix_python="${{ matrix.python-version }}" | |
matrix_django="${{ matrix.django-version }}" | |
matrix_drf="${{ matrix.drf-version }}" | |
python_v="${matrix_python//[a-zA-Z]}" | |
django_v="${matrix_django//[a-zA-Z\.]}" | |
drf_v="${matrix_drf//[a-zA-Z\.]}" | |
tox_env_name="py${python_v}-django${django_v}-drf${drf_v}" | |
echo "TOXENV=$tox_env_name" >> $GITHUB_ENV | |
echo "PYTHON_V=$python_v" >> $GITHUB_ENV | |
- name: "Installing non-python packages" | |
run: | | |
sudo apt-get update -qq | |
DEBIAN_FRONTEND=noninteractive | |
echo "Installing build tools" | |
sudo apt-get install -y build-essential | |
echo "Installing python Pillow library dependencies" | |
sudo apt-get install -y libraqm0 libfreetype6-dev libfribidi-dev libimagequant-dev libjpeg-dev liblcms2-dev libopenjp2-7-dev libtiff5-dev libwebp-dev libxcb1-dev | |
- name: Checkout code (Push) | |
uses: actions/checkout@v4 | |
if: github.event_name == 'push' | |
- name: Checkout code (Pull Request) | |
uses: actions/checkout@v4 | |
if: github.event_name == 'pull_request_target' || github.event_name == 'pull_request' | |
with: | |
# Assume PRs are less than 50 commits | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 50 | |
- name: Set up Python "${{ env.PYTHON_V }}" | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_V }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade 'tox>=3,<4' tox-gh-actions testfixtures | |
- name: Tox tests | |
run: | | |
tox -e $TOXENV | |
- name: Upload coverage | |
uses: codecov/codecov-action@v1 | |
with: | |
name: Python ${{ env.PYTHON_V }} | |
finish-coverage-upload: | |
needs: run-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel-finished: true | |
publish-to-pypi: | |
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI | |
runs-on: ubuntu-latest | |
needs: run-tests | |
steps: | |
- uses: actions/checkout@master | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Install pypa/build | |
run: >- | |
python -m | |
pip install | |
build | |
--user | |
- name: Build a binary wheel and a source tarball | |
run: >- | |
python -m | |
build | |
--sdist | |
--wheel | |
--outdir dist/ | |
. | |
- name: Publish distribution 📦 to Test PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
if: github.ref == 'refs/heads/master' | |
continue-on-error: true | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ | |
- name: Publish distribution 📦 to PyPI | |
if: startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |