Skip to content

Commit 0cca530

Browse files
Make test env var setup self-contained for CI
1 parent 0c37c36 commit 0cca530

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ SECRET_KEY=
55
BASE_URL=http://localhost:8000
66

77
# Database
8-
DB_USER=
9-
DB_PASSWORD=
10-
DB_HOST=localhost
8+
DB_USER=postgres
9+
DB_PASSWORD=postgres
10+
DB_HOST=127.0.0.1
1111
DB_PORT=5432
1212
DB_NAME=
1313

.github/workflows/test.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515
os: [ubuntu-latest]
1616

1717
runs-on: ${{ matrix.os }}
@@ -20,7 +20,7 @@ jobs:
2020
postgres:
2121
image: postgres:latest
2222
env:
23-
POSTGRES_DB: test_db
23+
POSTGRES_DB: db
2424
POSTGRES_USER: postgres
2525
POSTGRES_PASSWORD: postgres
2626
ports:
@@ -45,21 +45,6 @@ jobs:
4545
- name: Install project
4646
run: uv sync --all-extras --dev
4747

48-
- name: Set env variables for pytest
49-
run: |
50-
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
51-
echo "DB_PORT=5432" >> $GITHUB_ENV
52-
echo "DB_USER=postgres" >> $GITHUB_ENV
53-
echo "DB_PASSWORD=postgres" >> $GITHUB_ENV
54-
55-
- name: Verify environment variables
56-
run: |
57-
echo "Checking if required environment variables are set..."
58-
[ -n "$DB_HOST" ] && \
59-
[ -n "$DB_PORT" ] && \
60-
[ -n "$DB_USER" ] && \
61-
[ -n "$DB_PASSWORD" ]
62-
6348
- name: Run type checking with mypy
6449
run: uv run mypy .
6550

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def env_vars(monkeypatch):
2525
# monkeypatch remaining env vars
2626
with monkeypatch.context() as m:
2727
# Get valid db user, password, host, and port from env
28-
m.setenv("DB_HOST", os.getenv("DB_HOST", "localhost"))
28+
m.setenv("DB_HOST", os.getenv("DB_HOST", "127.0.0.1"))
2929
m.setenv("DB_PORT", os.getenv("DB_PORT", "5432"))
30-
m.setenv("DB_USER", os.getenv("DB_USER", "appuser"))
31-
m.setenv("DB_PASSWORD", os.getenv("DB_PASSWORD", "testpassword"))
30+
m.setenv("DB_USER", os.getenv("DB_USER", "postgres"))
31+
m.setenv("DB_PASSWORD", os.getenv("DB_PASSWORD", "postgres"))
3232
m.setenv("SECRET_KEY", "testsecretkey")
3333
m.setenv("HOST_NAME", "Test Organization")
3434
m.setenv("DB_NAME", "qual2db4-test-db")

0 commit comments

Comments
 (0)