-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathproj_main.yml
More file actions
180 lines (155 loc) · 6.72 KB
/
proj_main.yml
File metadata and controls
180 lines (155 loc) · 6.72 KB
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
178
179
180
name: main
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build {{ project_name }}
strategy:
matrix:
python: [3.12]
node: [22.20]
env:
DATABASE_URL: "sqlite:///"
REDIS_URL: "redis://"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Store branch and latest SHA
id: git
shell: bash
run: |
echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Setup Python ${% templatetag openvariable %} matrix.python {% templatetag closevariable %}
uses: actions/setup-python@v5
with:
python-version: ${% templatetag openvariable %} matrix.python {% templatetag closevariable %}
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
run_install: false
- name: Verify pnpm is available
shell: bash
run: |
which pnpm
pnpm --version
- name: Setup Node ${% templatetag openvariable %} matrix.node {% templatetag closevariable %}
uses: actions/setup-node@v4
with:
node-version: ${% templatetag openvariable %} matrix.node {% templatetag closevariable %}
cache: "pnpm"
cache-dependency-path: **/pnpm-lock.yaml # ← ensures cache is invalidated when lockfile changes
- name: Compute lockfile hash
id: lockhash
shell: bash
run: |
set -euo pipefail
files=$(git ls-files '**/pnpm-lock.yaml' || true)
if [ -z "$files" ]; then
echo "hash=none" >> "$GITHUB_OUTPUT"
else
hash=$(cat $files | sha256sum | cut -d' ' -f1)
echo "hash=$hash" >> "$GITHUB_OUTPUT"
fi
- name: Cache pnpm store
uses: actions/cache@v4
env:
cache_name: pnpm-store-cache
with:
path: ~/.pnpm-store
key: build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.sha_short {% templatetag closevariable %}-${% templatetag openvariable %} steps.lockhash.outputs.hash {% templatetag closevariable %}
restore-keys: |
build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.sha_short {% templatetag closevariable %}
build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.branch {% templatetag closevariable %}
build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}
- name: Cache pip
uses: actions/cache@v4
env:
cache_name: pip-cache
with:
path: ~/.cache/pip
key: build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.sha_short {% templatetag closevariable %}
restore-keys: |
build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable %} steps.git.outputs.branch {% templatetag closevariable %}
build-${% templatetag openvariable %} env.cache_name {% templatetag closevariable %}
- run: python -m pip install --upgrade pip
shell: bash
- run: python -m pip install poetry==2.0.1
shell: bash
- run: curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
shell: bash
- run: sudo apt-get install git-lfs --upgrade
shell: bash
- name: Poetry install (backend & deps)
run: poetry install --with dev --no-root --no-interaction --no-ansi
shell: bash
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
shell: bash
- name: Build frontend
run: pnpm run build
shell: bash
- name: Lint frontend
run: pnpm run lint
shell: bash
- name: Generate secret key
id: secret_id_generator
shell: bash
run: |
secret=$(python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)")
echo "SECRET_KEY=$secret" >> $GITHUB_OUTPUT
- name: Linting backend
run: poetry run ruff check ./backend/
env:
DJANGO_SETTINGS_MODULE: "{{ project_name }}.settings.local_base"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
shell: bash
- run: poetry run pre-commit run --all-files
env:
SKIP: ruff,eslint,missing-migrations,backend-schema
shell: bash
- name: Check migrations (dry-run)
run: |
poetry run python manage.py makemigrations --check --dry-run
working-directory: backend
env:
DJANGO_SETTINGS_MODULE: "{{ project_name }}.settings.production"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
shell: bash
- name: Django deploy checks
run: |
poetry run python manage.py check --deploy
working-directory: backend
env:
DJANGO_SETTINGS_MODULE: "{{ project_name }}.settings.production"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
shell: bash
- name: Run backend tests with coverage
run: |
poetry run coverage run manage.py test
mkdir -p junit
poetry run coverage xml -o junit/test-results.xml
working-directory: backend
shell: bash
- name: Run frontend tests
run: pnpm run test
shell: bash