-
Notifications
You must be signed in to change notification settings - Fork 34
125 lines (102 loc) · 3.1 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
114
115
116
117
118
119
120
121
122
123
124
125
name: Test
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
# Replace pull_request with pull_request_target if you
# plan to use this action with forks, see the Limitations section
pull_request:
branches:
- main
env: # environment variables (available in any part of the action)
NODE_VERSION: 21
PYTHON_VERSION: 3.12
MONGODB_VERSION: 8.0
jobs:
run-js-linters:
name: Run JS linters
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install Node.js dependencies
run: npm ci
- name: Run eslint
run: npm run lint
run-python-linters:
name: Run Python linters
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Run black
uses: psf/black@stable
with:
options: "--config ./pyproject.toml"
test-backend:
name: Run backend unit tests
runs-on: ubuntu-latest
needs: run-python-linters
defaults:
run:
working-directory: ./backend
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ env.MONGODB_VERSION }}
# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- name: Install dependencies
run: poetry install --no-interaction --no-root --with dev
- name: Test with pytest
run: poetry run pytest --cov=app tests --cov-report html
# upload-artifact action does not take into account working-directory default
# see https://github.com/actions/upload-artifact/issues/232
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: backend/htmlcov
test-frontend:
name: Run frontend unit tests
runs-on: ubuntu-latest
needs: run-js-linters
defaults:
run:
working-directory: ./frontend
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Node.js dependencies
run: npm ci
- name: Run tests
run: npm run test