Skip to content

Commit 4b49c9a

Browse files
committed
add GitHub action for unit tests
1 parent 05627f9 commit 4b49c9a

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

.github/workflows/unittest.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: unit-test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: main
8+
tags: ['v*']
9+
10+
jobs:
11+
linux:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: conda-incubator/setup-miniconda@v2
19+
with:
20+
auto-update-conda: true
21+
channels: conda-forge,defaults
22+
mamba-version: "*"
23+
environment-file: environment.yml
24+
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
25+
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
26+
- name: Start docker containers
27+
run: |
28+
cp ./config/docker-compose.envlocal.yml docker-compose.yml
29+
docker compose up --build
30+
env:
31+
DATABASE_NAME: livedatadb
32+
DATABASE_USER: livedatauser
33+
DATABASE_PASS: livedatapass
34+
DATABASE_HOST: db
35+
DATABASE_PORT: 5432
36+
LIVE_PLOT_SECRET_KEY: "live_data_server_47352"
37+
DJANGO_SUPERUSER_USERNAME: ldsuser
38+
DJANGO_SUPERUSER_PASSWORD: ldspass
39+
- name: Sleep, wait for containers to start up
40+
run: sleep 20
41+
- name: Run unit tests
42+
run: |
43+
echo "running unit tests"
44+
export DJANGO_SUPERUSER_USERNAME=ldsuser DJANGO_SUPERUSER_PASSWORD=ldspass
45+
python -m pytest --cov=src --cov-report=xml --cov-report=term-missing tests/
46+
env:
47+
LIVE_PLOT_SECRET_KEY: "live_data_server_47352"
48+
DJANGO_SUPERUSER_USERNAME: ldsuser
49+
DJANGO_SUPERUSER_PASSWORD: ldspass
50+
# - name: upload coverage to codecov
51+
# uses: codecov/codecov-action@v4
52+
# with:
53+
# token: ${{ secrets.CODECOV_TOKEN }}

config/docker-compose.envlocal.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42

53
nginx:

0 commit comments

Comments
 (0)