Skip to content

Commit 0522f9b

Browse files
author
Pau Tena
committed
Add Makefiles and fix backend tests
1 parent 11f175a commit 0522f9b

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

.github/workflows/test-backend.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ on:
1212
jobs:
1313
test-backend:
1414
runs-on: ubuntu-latest
15+
env:
16+
ENVIRONMENT: local
1517
steps:
1618
- name: Checkout
1719
uses: actions/checkout@v4
20+
- name: Install 1Password CLI
21+
uses: 1password/install-cli-action@v1
22+
- name: Load secrets from 1Password
23+
uses: 1password/load-secrets-action/configure@v2
24+
with:
25+
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
1826
- name: Set up Python
1927
uses: actions/setup-python@v5
2028
with:
@@ -25,12 +33,12 @@ jobs:
2533
version: "0.4.15"
2634
enable-cache: true
2735
- run: docker compose down -v --remove-orphans
28-
- run: docker compose up -d db mailcatcher
36+
- run: op run --no-masking --env-file="./.env" -- docker compose up -d db mailcatcher
2937
- name: Migrate DB
30-
run: uv run bash scripts/prestart.sh
38+
run: op run --no-masking --env-file="../.env" -- uv run bash scripts/prestart.sh
3139
working-directory: backend
3240
- name: Run tests
33-
run: uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
41+
run: op run --no-masking --env-file="../.env" -- uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
3442
working-directory: backend
3543
- run: docker compose down -v --remove-orphans
3644
- name: Store coverage files

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export ENVIRONMENT=local
2+
3+
4+
watch:
5+
op run --env-file=".env" -- docker compose watch
6+
7+
up:
8+
op run --env-file=".env" -- docker compose up
9+
10+
build:
11+
op run --env-file=".env" -- docker compose build
12+
13+
.PHONY: watch up build

backend/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export ENVIRONMENT=local
2+
3+
test:
4+
docker compose down -v --remove-orphans; \
5+
op run --no-masking --env-file="../.env" -- docker compose up -d db mailcatcher; \
6+
op run --no-masking --env-file="../.env" -- uv run bash scripts/prestart.sh; \
7+
op run --no-masking --env-file="../.env" -- uv run bash scripts/tests-start.sh $(MSG); \
8+
docker compose down -v --remove-orphans;
9+
10+
lint:
11+
uv run bash scripts/lint.sh
12+
13+
.PHONY: test lint

backend/app/tests/api/routes/test_login.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def test_recovery_password_user_not_exits(
7272
def test_reset_password(
7373
client: TestClient, superuser_token_headers: dict[str, str], db: Session
7474
) -> None:
75-
token = generate_password_reset_token(email=settings.FIRST_SUPERUSER)
76-
data = {"new_password": "changethis", "token": token}
75+
token = generate_password_reset_token(email=settings.EMAIL_TEST_USER)
76+
data = {"new_password": "different pasasword", "token": token}
7777
r = client.post(
7878
f"{settings.API_V1_STR}/reset-password/",
7979
headers=superuser_token_headers,
@@ -82,7 +82,7 @@ def test_reset_password(
8282
assert r.status_code == 200
8383
assert r.json() == {"message": "Password updated successfully"}
8484

85-
user_query = select(User).where(User.email == settings.FIRST_SUPERUSER)
85+
user_query = select(User).where(User.email == settings.EMAIL_TEST_USER)
8686
user = db.exec(user_query).first()
8787
assert user
8888
assert verify_password(data["new_password"], user.hashed_password)
@@ -91,7 +91,7 @@ def test_reset_password(
9191
def test_reset_password_invalid_token(
9292
client: TestClient, superuser_token_headers: dict[str, str]
9393
) -> None:
94-
data = {"new_password": "changethis", "token": "invalid"}
94+
data = {"new_password": "different password", "token": "invalid"}
9595
r = client.post(
9696
f"{settings.API_V1_STR}/reset-password/",
9797
headers=superuser_token_headers,

docker-compose.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ services:
1111
timeout: 10s
1212
volumes:
1313
- app-db-data:/var/lib/postgresql/data/pgdata
14-
env_file:
15-
- .env
1614
environment:
1715
- PGDATA=/var/lib/postgresql/data/pgdata
1816
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
@@ -54,9 +52,8 @@ services:
5452
condition: service_healthy
5553
restart: true
5654
command: bash scripts/prestart.sh
57-
env_file:
58-
- .env
5955
environment:
56+
- PROJECT_NAME=${PROJECT_NAME}
6057
- DOMAIN=${DOMAIN}
6158
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
6259
- ENVIRONMENT=${ENVIRONMENT}
@@ -87,9 +84,8 @@ services:
8784
restart: true
8885
prestart:
8986
condition: service_completed_successfully
90-
env_file:
91-
- .env
9287
environment:
88+
- PROJECT_NAME=${PROJECT_NAME}
9389
- DOMAIN=${DOMAIN}
9490
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
9591
- ENVIRONMENT=${ENVIRONMENT}

0 commit comments

Comments
 (0)