-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (51 loc) · 2.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
name: Test
on:
push:
paths:
- 'backend/*'
- '.github/workflows/test.yml'
branches:
- 'main'
tags-ignore:
- '**'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mirromutth/mysql-action@v1.1
with:
mysql database: "hermadata_test" # Optional, default value is "test". The specified database which will be create
mysql root password: "dev"
- name: Set up Python
# This is the version of the action for setting up Python, not the Python version.
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: "3.x"
# Optional - x64 or x86 architecture, defaults to x64
architecture: "x64"
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install .
pip install pytest httpx pytest-env pytest-dotenv pytest-cov
- name: Database migrations
run: |
cd backend
alembic -c tests/alembic.ini upgrade head
- name: Run tests
run: |
cd backend
mkdir tests/storage
pytest --cov=hermadata --cov-report json
mv coverage.json ../
- name: Update Coverage Badge
# GitHub actions: default branch variable
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: we-cli/coverage-badge-action@main