Correct python/django versions #98
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: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
test: | |
name: "Python ${{ matrix.python-version }}, Django ${{ matrix.django-version}}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
django-version: ["4.1", "4.2", "5.0", "main"] | |
exclude: | |
- python-version: "3.9" | |
django-version: "5.0" | |
- python-version: "3.9" | |
django-version: "main" | |
- python-version: "3.12" | |
django-version: "4.1" | |
steps: | |
- name: Git clone | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache dir | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} | |
restore-keys: | | |
${{ matrix.python-version }}-v2- | |
- name: Install python packages | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade coverage[toml] tox tox-gh-actions | |
- name: Test with Tox | |
run: tox --verbose --parallel auto | |
env: | |
DJANGO: ${{ matrix.django-version }} | |
- name: Upload Coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
ruff: | |
name: "Run ruff: ${{ matrix.toxenv }}" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
toxenv: | |
- ruff | |
steps: | |
- name: Git clone | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Get pip cache dir | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} | |
restore-keys: | | |
${{ matrix.python-version }}-v2- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade tox tox-gh-actions | |
- name: Run ${{ matrix.toxenv }} | |
run: python -m tox -e ${{ matrix.toxenv }} | |
slack: | |
# https://github.com/8398a7/action-slack/issues/72#issuecomment-649910353 | |
name: Slack notification | |
runs-on: ubuntu-latest | |
needs: [test, ruff] | |
# this is required, otherwise it gets skipped if any needed jobs fail. | |
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds | |
if: always() # Pick up events even if the job fails or is cancelled. | |
steps: | |
- uses: technote-space/workflow-conclusion-action@v1 | |
- name: Send Slack notification | |
uses: 8398a7/action-slack@v3 | |
# if: env.WORKFLOW_CONCLUSION == 'failure' | |
with: | |
status: ${{ env.WORKFLOW_CONCLUSION }} | |
# fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message) | |
fields: repo,message,commit,author,action,took | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.ACTIONS_CI_SLACK_HOOK }} |