-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (119 loc) · 3.66 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
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
---
name: CI
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: '${{ github.head_ref || github.ref }}-${{ github.workflow }}'
cancel-in-progress: true
env:
POETRY_VERSION: '1.8.4' # keep in sync with pyproject.toml, Dockerfile
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry
- name: Install dependencies
run: make install-dev
- name: Lint Python
run: make lint-py
- name: Lint HTML
run: make lint-html
lint-front-end:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install npm dependencies
run: npm ci --no-audit
- name: CSS linting
run: npm run lint:css
- name: JS linting
run: npm run lint:js
- name: Prettier
run: npm run lint:format
compile_static:
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@v4
with:
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:prod
- uses: actions/upload-artifact@v4
with:
name: static
path: cms/static_compiled/
test-python:
runs-on: ubuntu-latest
needs:
- lint
- lint-front-end
- compile_static
env:
DJANGO_SETTINGS_MODULE: cms.settings.test
DATABASE_URL: postgres://postgres:postgres@localhost/postgres # pragma: allowlist secret
ENABLE_DJANGO_DEFENDER: 'false'
POSTGRES_HOST_AUTH_METHOD: trust
SECRET_KEY: fake_secret_key_to_run_tests # pragma: allowlist secret
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry
- name: Install dependencies
run: make install-dev
- uses: actions/download-artifact@v4
with:
name: static
path: cms/static_compiled/
- name: Fetch Design System templates
run: make load-design-system-templates
- name: collectstatic
run: poetry run ./manage.py collectstatic --verbosity 0 --noinput --clear
- name: System checks
run: poetry run ./manage.py check
- name: Check for missing migrations
run: poetry run ./manage.py makemigrations --check --noinput
- name: Create cache table
run: poetry run ./manage.py createcachetable
- name: Test
run: make test
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
run: docker build --target web -t ons .