-
Notifications
You must be signed in to change notification settings - Fork 46
102 lines (102 loc) · 3.86 KB
/
ci.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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx install "poetry>=1.1.12,<2"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'poetry'
- run: pip install tox
- run: tox -e lint,py312-dj50
test_compatibility:
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Test with all supported Django versions, for all compatible Python versions.
# See https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django for the official matrix.
# Additionally test on Django’s main branch with the most recent Python version.
- python: "3.8"
toxenv: py38-dj32,py38-dj41,py38-dj42
- python: "3.9"
toxenv: py39-dj32,py39-dj41,py39-dj42
- python: "3.10"
toxenv: py310-dj32,py310-dj41,py310-dj42,py310-djmain
- python: "3.11"
toxenv: py311-dj41,py311-dj42,py311-djmain
- python: "3.12"
toxenv: py312-dj42,py312-djmain
steps:
- uses: actions/checkout@v4
- run: pipx install "poetry>=1.1.12,<2"
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- run: pip install tox
- run: tox -q
env:
TOXENV: ${{ matrix.toxenv }}
build_site:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- id: node-cache
uses: actions/cache@v3
with:
# Cache node_modules rather than the npm cache, as we rarely update npm packages.
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci --no-audit
- run: npm run build
- run: pipx install "poetry>=1.1.12,<2"
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
cache: 'poetry'
- run: poetry install
- run: poetry run django-admin runserver --settings=tests.settings.production --pythonpath=. &
# Docs website build.
- run: poetry run mkdocs build --strict
# Demo website build.
- run: wget --mirror --page-requisites --no-parent --no-verbose http://localhost:8000/django-pattern-library/demo/
- run: mv localhost:8000/django-pattern-library/demo site
# Demo render_patterns.
- run: poetry run django-admin render_patterns --settings=tests.settings.production --pythonpath=. --wrap-fragments --output=site/dpl-rendered-patterns 2>&1 >/dev/null | tee dpl-list.txt
# Create an archive of render_patterns output so the build artifacts can be inspected easily.
- run: mv dpl-list.txt site/dpl-rendered-patterns && tar -czvf site/dpl-rendered-patterns.tar.gz site/dpl-rendered-patterns
# Package build, incl. publishing an experimental pre-release via GitHub Pages for builds on `main`.
- run: cat pyproject.toml | awk '{sub(/^version = .+/,"version = \"0.0.0.dev\"")}1' > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml
- run: poetry build
- run: mv dist site
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: site
deploy_site:
needs: build_site
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/deploy-pages@v4