Skip to content

Commit b9f283c

Browse files
feat: add unit testing workflow
1 parent 31a021c commit b9f283c

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
# Remove the line above to run when pushing to master
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
services:
15+
postgres:
16+
image: postgres:11
17+
env:
18+
POSTGRES_USER: postgres
19+
POSTGRES_PASSWORD: postgres
20+
POSTGRES_DB: postgres
21+
ports: [ '5432:5432' ]
22+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
23+
24+
steps:
25+
- uses: actions/checkout@v1
26+
with:
27+
fetch-depth: 1
28+
29+
- name: Set up Python 3.9
30+
uses: actions/setup-python@v1
31+
with:
32+
python-version: 3.9
33+
34+
- uses: actions/cache@v1
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install -r requirements.txt
44+
if: steps.cache.outputs.cache-hit != 'true'
45+
46+
- name: Test with black
47+
run: |
48+
python -m black --check .
49+
- name: Test with pytest
50+
env:
51+
DATABASE_URL: 'postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres'
52+
run: |
53+
python -m pytest

0 commit comments

Comments
 (0)