Skip to content

Commit 54af3f1

Browse files
Merge pull request #4 from piyush-jaiswal/ci/add-tests-workflow
Introduce CI via automated tests
2 parents 82bb87a + c6ff8d2 commit 54af3f1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
id: cp312
21+
with:
22+
python-version-file: ".python-version"
23+
cache: "pip"
24+
cache-dependency-path: "requirements-test.txt"
25+
26+
# for testing
27+
- name: Check cache hit
28+
run: echo "${{ steps.cp312.outputs.cache-hit }}" # true if cache-hit occurred on the primary key
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -r requirements-test.txt
34+
35+
- name: Run tests
36+
run: |
37+
pytest --disable-warnings -q -rA

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# TODO: Fix hack. Changes the env var before initializing the db for testing
66
os.environ["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
7+
os.environ["JWT_SECRET_KEY"] = os.urandom(24).hex()
78

89
from app import app, db
910

0 commit comments

Comments
 (0)