-
-
Notifications
You must be signed in to change notification settings - Fork 536
177 lines (154 loc) · 4.63 KB
/
test.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: 🔂 Unit tests
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "strawberry/**"
- "tests/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/test.yml"
jobs:
generate-jobs-tests:
name: 💻 Generate test matrix
runs-on: ubuntu-latest
outputs:
sessions: ${{ steps.set-matrix.outputs.sessions }}
steps:
- uses: actions/checkout@v3
- uses: wntrblm/nox@main
- run: pipx install poetry
- run: pipx inject nox nox-poetry
- id: set-matrix
shell: bash
run: |
echo sessions=$(
nox --json -t tests -l |
jq 'map(
{
session,
name: "\( .name ) on \( .python )\( if .call_spec != {} then " (\(.call_spec | to_entries | map("\(.key)=\(.value)") | join(", ")))" else "" end )"
}
)'
) | tee --append $GITHUB_OUTPUT
unit-tests:
name: 🔬 ${{ matrix.session.name }}
needs: [generate-jobs-tests]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }}
steps:
- uses: actions/checkout@v3
- uses: wntrblm/nox@main
with:
python-versions: "3.7, 3.8, 3.9, 3.10, 3.11"
- name: Pip and nox cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.cache
~/.nox
.nox
key:
${{ runner.os }}-nox-${{ matrix.session.session }}-${{
hashFiles('**/poetry.lock') }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-nox-${{ matrix.session.session }}-
${{ runner.os }}-nox-
- run: pipx install coverage
- run: pipx install poetry
- run: pipx inject nox nox-poetry
- run: nox -r -t tests -s "${{ matrix.session.session }}"
- name: coverage xml
run: coverage xml -i
if: ${{ always() }}
- uses: codecov/codecov-action@v3
if: ${{ always() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
benchmarks:
name: 📈 Benchmarks
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- run: pipx install poetry
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: "3.11"
architecture: x64
cache: "poetry"
- run: poetry env use 3.11
- run: poetry install
if: steps.setup-python.outputs.cache-hit != 'true'
- name: Run benchmarks
uses: CodSpeedHQ/action@v1
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: poetry run pytest tests/benchmarks --codspeed
lint:
name: ✨ Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: wntrblm/nox@main
with:
python-versions: "3.7, 3.8, 3.9, 3.10, 3.11"
- name: Pip and nox cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.cache
~/.nox
.nox
key:
${{ runner.os }}-nox-lint-${{ matrix.session.session }}-${{
hashFiles('**/poetry.lock') }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-lint-nox-${{ matrix.session.session }}-
${{ runner.os }}-lint-nox-
- run: pipx install poetry
- run: pipx inject nox nox-poetry
- run: nox -r -t lint
unit-tests-on-windows:
name: 🪟 Tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- run: pipx install poetry
- run: pipx install coverage
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: "3.11"
cache: "poetry"
- run: poetry install --with integrations
if: steps.setup-python.outputs.cache-hit != 'true'
# we use poetry directly instead of nox since we want to
# test all integrations at once on windows
- run: |
poetry run pytest --cov=. --cov-append --cov-report=xml -n auto --showlocals -vv
- name: coverage xml
run: coverage xml -i
if: ${{ always() }}
- uses: codecov/codecov-action@v3
if: ${{ always() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true