-
Notifications
You must be signed in to change notification settings - Fork 8
134 lines (109 loc) · 3.93 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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", "3.13-dev"]
django-version: ["3.2", "4.1", "4.2", "5.0", "main"]
exclude:
# Django 5.0 isn't compatible with python < 3.10
- python-version: "3.9"
django-version: "5.0"
- python-version: "3.9"
django-version: "main"
- python-version: "3.11"
django-version: "3.2"
- python-version: "3.12"
django-version: "3.2"
- python-version: "3.12"
django-version: "4.1"
- python-version: "3.13-dev"
django-version: "3.2"
- python-version: "3.13-dev"
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 }}