-
Notifications
You must be signed in to change notification settings - Fork 12
143 lines (118 loc) · 3.64 KB
/
test.yaml
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
---
name: Linting and Testing
on:
push:
branches:
- master
pull_request:
jobs:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --frozen
- name: Run ruff check
run: uv run ruff check --output-format=github
- name: Run ruff format
run: uv run ruff format --check
tests:
name: Django Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: thalia
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
env:
DJANGO_ENV: testing
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --frozen
- name: Run checks
run: |
uv run website/manage.py check
uv run website/manage.py templatecheck --project-only
uv run website/manage.py makemigrations --no-input --check --dry-run
- name: Run tests
run: uv run coverage run website/manage.py test website/
- name: Report coverage
run: |
uv run coverage report --fail-under=100 --omit "website/registrations/urls.py" website/registrations/**.py
uv run coverage report --fail-under=100 --omit "website/payments/urls.py" website/payments/**.py
uv run coverage report
- name: Create coverage report
run: uv run coverage html --directory=covhtml --no-skip-covered --title="Coverage Report"
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: covhtml
run-fixtures:
name: Run fixtures
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: thalia
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
env:
DJANGO_ENV: testing
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --frozen
- name: Migrate
run: |
uv run website/manage.py migrate
uv run website/manage.py createcachetable
- name: Run create fixtures
run: uv run website/manage.py createfixtures -a
upload-coverage:
name: Deploy Coverage Report
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/download-artifact@v4
with:
name: coverage-html
path: html
- name: Create URL safe version of GITHUB_REF
run: echo "GITHUB_REF_SLUG=$(echo \"${GITHUB_REF#refs/heads/}\"| iconv -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)" >> "${GITHUB_ENV}"
- name: Sync files to S3
run: aws s3 sync html "s3://thalia-coverage/${GITHUB_REF_SLUG}/"
env:
AWS_DEFAULT_REGION: eu-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}