Skip to content

Commit aa53b81

Browse files
committed
Refactor test infrastructure to use Docker-based testing workflow
- Update Makefile to use Docker for backend and frontend testing - Modify GitHub Actions workflow to use Docker-based test commands - Simplify test execution and improve consistency across environments
1 parent 9bc41d3 commit aa53b81

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

.github/workflows/tests.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ jobs:
1111
runs-on: ubuntu-latest
1212
defaults:
1313
run:
14-
working-directory: ./frontend
14+
working-directory: .
1515

1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Set up Node.js
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: '20'
23-
cache: 'npm'
24-
cache-dependency-path: './frontend/package-lock.json'
25-
26-
- name: Install frontend dependencies
27-
run: npm ci
19+
- name: Set up Docker
20+
uses: docker/setup-buildx-action@v3
2821

2922
- name: Run frontend tests
30-
run: npm test -- --ci
23+
run: make frontend-test
3124

3225
backend-tests:
3326
runs-on: ubuntu-latest
@@ -38,18 +31,15 @@ jobs:
3831
steps:
3932
- uses: actions/checkout@v4
4033

41-
- name: Set up Python
42-
uses: actions/setup-python@v5
43-
with:
44-
python-version: '3.11'
45-
cache: 'pip'
34+
- name: Set up Docker
35+
uses: docker/setup-buildx-action@v3
4636

47-
- name: Install backend dependencies
48-
run: |
49-
python -m pip install --upgrade pip
50-
pip install -r requirements.txt
51-
pip install -r requirements-test.txt
37+
- name: Clean up any existing test containers
38+
run: make test-clean
5239

5340
- name: Run backend tests
54-
run: |
55-
PYTHONPATH=$PYTHONPATH:$(pwd) pytest tests/
41+
run: make backend-test
42+
43+
- name: Clean up test containers
44+
if: always()
45+
run: make test-clean

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
.PHONY: test test-build test-clean test-network test-postgres frontend-test frontend-test-build
1+
.PHONY: backend-test backend-test-build test-clean test-network test-postgres frontend-test frontend-test-build
22

33
# Default target
4-
all: test
4+
all: backend-test
55

66
# Create Docker network if it doesn't exist
77
test-network:
88
docker network create amazeeai_default 2>/dev/null || true
99

10-
# Build the test container
11-
test-build:
10+
# Build the backend test container
11+
backend-test-build:
1212
docker build -t amazee-backend-test -f Dockerfile.test .
1313

1414
# Start PostgreSQL container for testing
@@ -22,8 +22,8 @@ test-postgres: test-network
2222
postgres:14 && \
2323
sleep 5
2424

25-
# Run tests in a new container
26-
test: test-build test-postgres
25+
# Run backend tests in a new container
26+
backend-test: backend-test-build test-postgres
2727
docker run --rm \
2828
--network amazeeai_default \
2929
-e DATABASE_URL="postgresql://postgres:postgres@amazee-test-postgres/postgres_service" \
@@ -39,8 +39,8 @@ test: test-build test-postgres
3939
-v $(PWD)/tests:/app/tests \
4040
amazee-backend-test
4141

42-
# Run tests with coverage report
43-
test-cov: test-build test-postgres
42+
# Run backend tests with coverage report
43+
backend-test-cov: backend-test-build test-postgres
4444
docker run --rm \
4545
--network amazeeai_default \
4646
-e DATABASE_URL="postgresql://postgres:postgres@amazee-test-postgres/postgres_service" \
@@ -67,7 +67,7 @@ frontend-test: frontend-test-build
6767
amazeeai-frontend-test npm test -- --ci
6868

6969
# Run all tests (backend and frontend)
70-
test-all: test frontend-test
70+
test-all: backend-test frontend-test
7171

7272
# Clean up test containers and images
7373
test-clean:

0 commit comments

Comments
 (0)