Skip to content

Commit 90ed875

Browse files
authored
Makefile for testing all go modules (#336)
`test` -> `test-fast` `test-fast` -> `POSTGRES_CONTAINER=0` `test-full` -> `POSTGRES_CONTAINER=1` The command iterates through all our top level directories and checks if there is a go module inside. If so it runs `go test ./...` Adjusted test-without-docker workflow as well to use this.
1 parent 3dab2c9 commit 90ed875

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,7 @@ jobs:
2222
with:
2323
go-version-file: 'lib/go.mod'
2424
- name: Test quickly without Docker
25-
run: |
26-
echo "Testing lib module..."
27-
cd lib && go test -v ./...
28-
echo "Testing reservations module..."
29-
cd ../reservations && go test -v ./...
30-
echo "Testing machines module..."
31-
cd ../machines && go test -v ./...
32-
echo "Testing decisions module..."
33-
cd ../decisions && go test -v ./...
34-
echo "Testing scheduler module..."
35-
cd ../scheduler && go test -v ./...
36-
echo "Testing descheduler module..."
37-
cd ../descheduler && go test -v ./...
38-
echo "Testing extractor module..."
39-
cd ../extractor && go test -v ./...
40-
echo "Testing kpis module..."
41-
cd ../kpis && go test -v ./...
42-
echo "Testing sync module..."
43-
cd ../sync && go test -v ./...
25+
run: make test-fast
4426

4527
test-with-docker:
4628
# We don't need to run this longer test if the previous one already failed.

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Declare test targets as phony targets (not file names)
2+
.PHONY: test test-fast test-full
3+
4+
# Default test command - runs without Docker (fast)
5+
test: test-fast
6+
7+
# Run tests without Docker/PostgreSQL container (faster, but some tests may be skipped)
8+
test-fast:
9+
@echo "Running tests without PostgreSQL container..."
10+
@for dir in */; do \
11+
if [ -f "$$dir/go.mod" ]; then \
12+
echo "Testing in $$dir..."; \
13+
cd "$$dir" && POSTGRES_CONTAINER=0 go test ./... && cd ..; \
14+
fi; \
15+
done
16+
17+
# Run tests with Docker/PostgreSQL container (slower, but runs all tests)
18+
test-full:
19+
@echo "Running tests with PostgreSQL container..."
20+
@for dir in */; do \
21+
if [ -f "$$dir/go.mod" ]; then \
22+
echo "Testing in $$dir..."; \
23+
cd "$$dir" && POSTGRES_CONTAINER=1 go test ./... && cd ..; \
24+
fi; \
25+
done

0 commit comments

Comments
 (0)