-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (95 loc) · 3.06 KB
/
test.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
name: Test
on:
push:
jobs:
generate_assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Node dependencies
id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install JS dependencies
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Generate assets
run: npm run-script build-development
- name: Store assets for testing
uses: actions/upload-artifact@v4
with:
name: generated
path: assets/generated
retention-days: 1
test:
runs-on: ubuntu-latest
needs: generate_assets
strategy:
max-parallel: 4
matrix:
python-version: [3.11]
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: hunter2
POSTGRES_DB: postgres
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports:
- 6379/tcp
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v2
- name: Install libpq-dev
run: sudo apt-get -y install libpq-dev
- name: Download and install chromedriver
uses: nanasess/setup-chromedriver@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python dependencies
id: py-cache
uses: actions/cache@v4
with:
path: ~/.local/lib/
key: ${{ runner.OS }}-pip${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.OS }}-pip${{ matrix.python-version }}-
- name: Install Python dependencies
if: steps.py-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install --user -r requirements.txt
pip install --user -r tests/requirements.txt
- name: Get assets
uses: actions/download-artifact@v4
with:
name: generated
path: assets/generated
- name: Test with pytest
env:
TESTING: true
SECRET_KEY: fake
EMAIL_ASYNC: false
RQ_ASYNC: false
DIRECTORY_ENABLED: true
CONTACT_EMAILS: [email protected]
RECAPTCHA_ENABLED: false
DATABASE_URL: postgres://postgres:hunter2@localhost:${{ job.services.postgres.ports['5432'] }}/postgres
CACHE_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/1
SITE_URL: test
run: |
python -m pytest