-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (147 loc) · 4.79 KB
/
backend.yml
File metadata and controls
156 lines (147 loc) · 4.79 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
name: Backend CI
on:
workflow_dispatch:
inputs:
run-tests:
description: 'Run all backend tests'
required: false
default: true
type: boolean
generate-emails:
description: 'Generate downloadable test e-mails'
required: false
default: false
type: boolean
pull_request:
push:
branches: [main]
paths:
- 'backend/**'
- '.github/workflows/backend.yml'
permissions:
contents: read
jobs:
generate-lockfile:
name: Generate lockfile
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request'}}
outputs:
files_changed: ${{ steps.verify-changed-files.outputs.files_changed }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Install Poetry
run: pipx install poetry
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: 3.14
cache: 'poetry'
cache-dependency-path: backend/poetry.lock
- name: Generate lockfile
working-directory: backend
run: poetry lock
- name: Verify lockfile has changed
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files
with:
files: |
**/poetry.lock
- name: Push lockfile changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add backend/poetry.lock
git commit -m "Update poetry.lock"
git push
run-tests:
name: Run tests
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
needs: generate-lockfile
if: ${{ always() && (needs.generate-lockfile.result == 'skipped' ||
(needs.generate-lockfile.result == 'success' && needs.generate-lockfile.outputs.files_changed == 'false'))}}
strategy:
fail-fast: false
matrix:
include:
- python-version: '3.14'
experimental: false
defaults:
run:
working-directory: backend
env:
DJANGO_SETTINGS_MODULE: core.settings.ci
services:
postgres:
image: postgres:18
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:8
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
cache-dependency-path: backend/poetry.lock
- name: Install dependencies
run: poetry install --with ci
- name: Check for model changes without migration
run: poetry run python manage.py makemigrations --check
- name: Synchronize database state and collect static files
run: |
poetry run python manage.py migrate --no-input
poetry run python manage.py collectstatic --no-input --clear --link
- name: Run tests
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }}
run: poetry run pytest
- name: Upload coverage to Codecov
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }}
uses: codecov/codecov-action@v6
with:
directory: backend/
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Archive code coverage results
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }}
uses: actions/upload-artifact@v7
with:
name: code-coverage-report
path: backend/htmlcov/
- name: Generate e-mail artifacts
if: ${{ github.event.inputs.generate-emails == 'true' }}
env:
BASE_URL_DOMAIN: felkeres.bsstudio.hu
EMAIL_FILE: True
run: poetry run python manage.py test tests.email_sending_tests
- name: Archive sent e-mails
if: ${{ github.event.inputs.generate-emails == 'true' }}
uses: actions/upload-artifact@v7
with:
name: emails
path: backend/logs/emails/