Skip to content

Commit 591e97b

Browse files
committed
Adds backend tests to github actions
We're using github actions so we can conditionally skip it.
1 parent 2644ecc commit 591e97b

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Backend Test Workflow
2+
3+
on: [push, pull_request]
4+
5+
6+
jobs:
7+
check-changes:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
changes: ${{ steps.filter.outputs.changes }}
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 2 # fetch previous commit for comparison
15+
- id: filter
16+
run: |
17+
echo "Checking for changes in the backend directory and branch..."
18+
# Check if the current branch is not main
19+
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
20+
# Check for changes in the backend directory
21+
if git diff --quiet HEAD^ HEAD -- backend/; then
22+
echo "::set-output name=skip::true"
23+
echo "No changes in backend/ or not on main branch, skipping subsequent jobs."
24+
else
25+
echo "::set-output name=skip::false"
26+
echo "Changes detected in backend/ and not on main branch."
27+
fi
28+
else
29+
echo "::set-output name=skip::false"
30+
echo "On main branch, proceeding with subsequent jobs."
31+
fi
32+
test-backend:
33+
needs: check-changes
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
testdir: [test_lifecycle, test_db_methods] # Specify your test directories
38+
services:
39+
postgres:
40+
image: postgres:14
41+
env:
42+
POSTGRES_USER: postgres
43+
POSTGRES_DB: circleci_test
44+
ports:
45+
- 5432:5432
46+
options: >-
47+
--health-cmd pg_isready
48+
--health-interval 10s
49+
--health-timeout 5s
50+
--health-retries 5
51+
steps:
52+
- uses: actions/checkout@v3
53+
- name: Set up Python
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: '3.9'
57+
- name: Install dependencies
58+
run: |
59+
cd ui/backend/server
60+
pip install -r requirements-base.txt
61+
pip install -r requirements-test.txt
62+
- name: Run migrations
63+
run: |
64+
cd ui/backend/server
65+
python manage.py sqlcreate
66+
echo $(python manage.py sqlcreate) | psql -U postgres
67+
python manage.py migrate
68+
- name: Run tests
69+
env:
70+
DB_HOST: localhost
71+
DB_USER: postgres
72+
DB_PASSWORD: "postgres"
73+
DB_NAME: ${{ matrix.testdir }}
74+
DW_ENV: integration_tests
75+
DJANGO_SECRET_KEY: test
76+
PGPASSWORD: postgres
77+
PGHOST: localhost
78+
PGUSER: postgres
79+
HAMILTON_BLOB_STORE: local
80+
LOCAL_HAMILTON_BLOB_STORE: ./blob_data
81+
run: |
82+
cd backend/server
83+
python -m pytest tests/${{ matrix.testdir }} -vvvvv

0 commit comments

Comments
 (0)