-
Notifications
You must be signed in to change notification settings - Fork 8
138 lines (107 loc) · 3.38 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
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Lint and test
on:
push:
branches:
- main
- dev
pull_request:
types: [opened, reopened, synchronize]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install backend dependencies
run: pip install -r ./backend/requirements.txt -r ./backend/requirements-dev.txt
- name: Lint backend
run: ruff check ./backend
- name: Black format check
uses: psf/black@stable
with:
options: '--check --verbose'
src: './backend'
version: '24.3.0'
- name: Install frontend packages
working-directory: ./frontend
run: npm ci
- name: Run tests on frontend
working-directory: ./frontend
run: npm run test
- name: Lint frontend
working-directory: ./frontend
run: npm run lint
test:
runs-on: ubuntu-latest
env:
DB_USER: dirtviz
DB_PASS: password
DB_HOST: localhost
DB_PORT: 5432
DB_DATABASE: dirtviz
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install backend dependencies
run: pip install -r ./backend/requirements.txt -r ./backend/requirements-dev.txt
- name: Install frontend packages
working-directory: ./frontend
run: npm ci
- name: Install k6
run: |
curl https://github.com/loadimpact/k6/releases/download/v0.26.2/k6-v0.26.2-linux64.tar.gz -L | tar xvz --strip-components 1
- name: Start services
run: docker compose up -d
- name: Wait for services to start
run: sleep 10s
- name: Save timestamp
id: timestamp
run: echo "start_time=$(date -Is)" >> $GITHUB_OUTPUT
- name: Apply migrations
run: flask --app backend.api db upgrade -d ./backend/api/migrations
- name: Import example data
run: python import_example_data.py
- name: Run smoke test
run: ./k6 run tests/basic.js
- name: Run backend tests
run: pytest --cov
- name: Run frontend tests + coverage
working-directory: ./frontend
run: npm run coverage
- name: Save all logs
if: always()
run: docker compose logs -t > dirtviz.log
- name: Save short logs
if: always()
run: docker compose logs -t --since ${{ steps.timestamp.outputs.start_time }} > dirtviz_short.log
- name: Check for errors
run: "! grep -i 'error' dirtviz_short.log"
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: DirtViz Logs
path: |
dirtviz.log
dirtviz_short.log
- name: Upload backend coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: backend
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload frontend coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
files: ./frontend/coverage/coverage-final.json
flags: frontend
token: ${{ secrets.CODECOV_TOKEN }}