-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.6 KB
/
Copy pathci.yml
File metadata and controls
46 lines (44 loc) · 1.6 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
name: CI
on:
push:
branches: [main, master]
pull_request:
jobs:
pytest:
name: Backend tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: requirements.txt
- name: Install dependencies
# requirements.txt lives at the repo root (shared by backend and
# scripts); the step overrides the default working-directory.
working-directory: .
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
env:
# conftest.py also sets a throwaway value via setdefault; this just
# makes it explicit. Never use a real production secret here.
JWT_SECRET: ci-throwaway-not-a-real-secret-AAAAAAAAAAAA
APP_ENV: test
# Surface the pytest failure tail as a GitHub annotation (readable
# from the check-run annotations API without the logs page).
# `python -m pytest` (not bare `pytest`): the -m form puts CWD on
# sys.path, so `import app...` in the tests resolves. Bare pytest
# fails collection with ModuleNotFoundError: No module named 'app'.
run: |
python -m pytest tests/ -q 2>&1 | tee /tmp/pytest.log || true
RC=${PIPESTATUS[0]}
if [ "$RC" -ne 0 ]; then
echo "::error::$(tail -25 /tmp/pytest.log | sed 's/%/%25/g; s/\r//g' | tr '\n' '%0A')"
fi
exit "$RC"