Skip to content

Commit 3c6cc5d

Browse files
committed
Backport CI and test modernization
1 parent 2554f51 commit 3c6cc5d

File tree

57 files changed

+13610
-2006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+13610
-2006
lines changed

.github/workflows/test.yml

Lines changed: 106 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,28 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
python-version: ["3.7", "3.8", "3.9", "3.10"]
11-
django-version: ["2.2", "3.2", "4.0"]
12-
grappelli: ["0"]
10+
grappelli: ["0", "1"]
11+
python-version: ["3.11"]
12+
django-version: ["4.2"]
1313
exclude:
14-
- python-version: "3.7"
15-
django-version: "4.0"
16-
- python-version: "3.10"
17-
django-version: "2.2"
18-
# Exclude some version combos that don't need to be tested (since
19-
# the combination of python and django versions is unlikely to
20-
# be germane to django-nested-admin)
21-
- python-version: "3.8"
22-
django-version: "3.2"
23-
- python-version: "3.9"
24-
django-version: "4.0"
14+
- python-version: "3.11"
15+
grappelli: "1"
2516
include:
26-
- grappelli: "0"
27-
name-suffix: ""
28-
- grappelli: "1"
29-
name-suffix: " + grappelli"
30-
python-version: "3.7"
31-
django-version: "2.2"
32-
- grappelli: "1"
33-
name-suffix: " + grappelli"
34-
python-version: "3.10"
35-
django-version: "3.2"
17+
- python-version: "3.9"
18+
django-version: "4.2"
19+
grappelli: "1"
20+
- python-version: "3.9"
21+
django-version: "5.0"
22+
grappelli: "0"
23+
- python-version: "3.10"
24+
django-version: "5.0"
25+
grappelli: "1"
26+
- python-version: "3.12"
27+
django-version: "5.1"
28+
grappelli: "0"
3629

3730
runs-on: ubuntu-latest
38-
name: Django ${{ matrix.django-version }} (Python ${{ matrix.python-version }})${{ matrix.name-suffix }}
31+
name: Django ${{ matrix.django-version }} (Python ${{ matrix.python-version }})${{ matrix.grappelli == '1' && ' + grappelli' || '' }}
3932

4033
env:
4134
DJANGO: ${{ matrix.django-version }}
@@ -45,47 +38,49 @@ jobs:
4538
NODE_ENV: test
4639

4740
steps:
48-
- uses: actions/checkout@v2
41+
- uses: actions/checkout@v3
4942

5043
- name: Set up Python ${{ matrix.python-version }}
51-
uses: actions/setup-python@v2
44+
uses: actions/setup-python@v4
5245
with:
5346
python-version: ${{ matrix.python-version }}
5447

5548
- name: Setup chromedriver
56-
uses: nanasess/setup-chromedriver@v1.0.5
49+
# uses: nanasess/setup-chromedriver@v2.2.2
50+
uses: nanasess/setup-chromedriver@42cc2998329f041de87dc3cfa33a930eacd57eaa
5751

5852
- name: Install tox
5953
run: |
6054
python3 -m pip install tox tox-gh-actions
6155
6256
- name: Cache instrumented static files
6357
id: cache-test-dist
64-
uses: actions/cache@v2
58+
uses: actions/cache@v3
6559
with:
6660
path: nested_admin/tests/static
67-
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'frontend/**') }}
61+
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'nested_admin/static/nested_admin/src/**/*.*s') }}
6862

6963
- name: Cache node_modules
7064
id: cache-node_modules
71-
uses: actions/cache@v2
65+
uses: actions/cache@v3
7266
with:
7367
path: node_modules
7468
key: node_modules-${{ hashFiles('package-lock.json') }}
7569

76-
- name: Setup nodejs 12
77-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
78-
uses: actions/setup-node@v2
70+
- name: Setup nodejs
71+
if: steps.cache-test-dist.outputs.cache-hit != 'true'
72+
uses: actions/setup-node@v3
7973
with:
80-
node-version: '12'
74+
node-version: '16'
75+
cache: 'npm'
8176

8277
- name: npm ci
83-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
78+
if: steps.cache-test-dist.outputs.cache-hit != 'true' && steps.cache-node_modules.outputs.cache-hit != 'true'
8479
run: |
8580
npm ci || npm ci || npm ci
8681
8782
- name: Build instrumented static files
88-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
83+
if: steps.cache-test-dist.outputs.cache-hit != 'true'
8984
run: |
9085
npm run build
9186
@@ -98,7 +93,7 @@ jobs:
9893

9994
- name: Upload junit xml
10095
if: always()
101-
uses: actions/upload-artifact@v2
96+
uses: actions/upload-artifact@v3
10297
with:
10398
name: junit-reports
10499
path: reports/*.xml
@@ -115,27 +110,96 @@ jobs:
115110
env:
116111
CODECOV_NAME: ${{ github.workflow }}
117112

113+
lint:
114+
runs-on: ubuntu-latest
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
tool: ["flake8", "black", "eslint", "stylelint"]
119+
include:
120+
- tool: flake8
121+
language: python
122+
- tool: black
123+
language: python
124+
- tool: eslint
125+
language: javascript
126+
- tool: stylelint
127+
language: javascript
128+
129+
steps:
130+
- uses: actions/checkout@v3
131+
132+
- uses: actions/setup-python@v4
133+
if: matrix.language == 'python'
134+
with:
135+
python-version: 3.9
136+
137+
- name: Cache node_modules
138+
if: matrix.language == 'javascript'
139+
id: cache-node_modules
140+
uses: actions/cache@v3
141+
with:
142+
path: node_modules
143+
key: node_modules-${{ hashFiles('package-lock.json') }}-lint
144+
restore-keys: |
145+
node_modules-${{ hashFiles('package-lock.json') }}
146+
147+
- name: Setup nodejs
148+
if: matrix.language == 'javascript'
149+
uses: actions/setup-node@v3
150+
with:
151+
node-version: '16'
152+
cache: 'npm'
153+
154+
- name: npm ci
155+
if: matrix.language == 'javascript' && steps.cache-node_modules.outputs.cache-hit != 'true'
156+
run: |
157+
npm ci || npm ci || npm ci
158+
159+
- name: Run black
160+
if: matrix.tool == 'black'
161+
uses: psf/black@stable
162+
with:
163+
src: "nested_admin docs setup.py"
164+
version: "22.8.0"
165+
166+
- name: Install flake8
167+
if: matrix.tool == 'flake8'
168+
run: pip install flake8
169+
170+
- name: Run flake8
171+
if: matrix.tool == 'flake8'
172+
uses: suo/flake8-github-action@releases/v1
173+
with:
174+
checkName: 'lint'
175+
env:
176+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
178+
- name: Run ${{ matrix.tool }}
179+
if: matrix.language == 'javascript'
180+
run: |
181+
npm run lint:${{ matrix.tool }}
182+
118183
report:
119184
if: always()
120185
needs: build
121186
runs-on: ubuntu-latest
122187
name: "Report Test Results"
123188
steps:
124-
- uses: actions/download-artifact@v2
189+
- uses: actions/download-artifact@v3
125190
with:
126191
name: junit-reports
127192

128193
- name: Publish tests report
129-
uses: mikepenz/action-junit-report@5703ba1461f35871cde0208140d737d3e1eef38f
194+
uses: mikepenz/action-junit-report@1a91e26932fb7ba410a31fab1f09266a96d29971
130195
with:
131196
report_paths: ./*.xml
132-
github_token: ${{ secrets.GITHUB_TOKEN }}
133197
require_tests: true
134198
fail_on_failure: true
135199
check_name: Test Report
136200

137201
success:
138-
needs: report
202+
needs: [lint, report]
139203
runs-on: ubuntu-latest
140204
name: Test Successful
141205
steps:

0 commit comments

Comments
 (0)