From 1860115710fe3980e2cc892ddf17a95802e1b99d Mon Sep 17 00:00:00 2001 From: Markus Wieland Date: Fri, 10 Oct 2025 16:05:51 +0200 Subject: [PATCH] Refactor test workflow to use Makefile for faster testing without Docker --- .github/workflows/test.yaml | 20 +------------------- Makefile | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b2cfbbd9..825207bb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,25 +20,7 @@ jobs: with: go-version-file: 'lib/go.mod' - name: Test quickly without Docker - run: | - echo "Testing lib module..." - cd lib && go test -v ./... - echo "Testing reservations module..." - cd ../reservations && go test -v ./... - echo "Testing machines module..." - cd ../machines && go test -v ./... - echo "Testing decisions module..." - cd ../decisions && go test -v ./... - echo "Testing scheduler module..." - cd ../scheduler && go test -v ./... - echo "Testing descheduler module..." - cd ../descheduler && go test -v ./... - echo "Testing extractor module..." - cd ../extractor && go test -v ./... - echo "Testing kpis module..." - cd ../kpis && go test -v ./... - echo "Testing sync module..." - cd ../sync && go test -v ./... + run: make test-fast test-with-docker: # We don't need to run this longer test if the previous one already failed. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..62d0106e --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +# Declare test targets as phony targets (not file names) +.PHONY: test test-fast test-full + +# Default test command - runs without Docker (fast) +test: test-fast + +# Run tests without Docker/PostgreSQL container (faster, but some tests may be skipped) +test-fast: + @echo "Running tests without PostgreSQL container..." + @for dir in */; do \ + if [ -f "$$dir/go.mod" ]; then \ + echo "Testing in $$dir..."; \ + cd "$$dir" && POSTGRES_CONTAINER=0 go test ./... && cd ..; \ + fi; \ + done + +# Run tests with Docker/PostgreSQL container (slower, but runs all tests) +test-full: + @echo "Running tests with PostgreSQL container..." + @for dir in */; do \ + if [ -f "$$dir/go.mod" ]; then \ + echo "Testing in $$dir..."; \ + cd "$$dir" && POSTGRES_CONTAINER=1 go test ./... && cd ..; \ + fi; \ + done \ No newline at end of file