diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 4e52245..6f1dc37 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,6 +12,21 @@ jobs: integration-test: runs-on: ubuntu-latest + services: + postgres: + image: postgres:13 + env: + POSTGRES_DB: broker_test + POSTGRES_USER: user + POSTGRES_PASSWORD: password + ports: + - 5433:5432 + options: >- + --health-cmd="pg_isready -U user" + --health-interval=5s + --health-timeout=5s + --health-retries=10 + steps: - name: Checkout code uses: actions/checkout@v4 @@ -22,13 +37,5 @@ jobs: go-version: '1.25' cache: true - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install podman-compose - run: pip install podman-compose - - name: Run all tests - run: make test-all + run: make test-ci diff --git a/Makefile b/Makefile index 4880d0d..36f596a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build clean test test-all test-integration-go test-unit-go test-connection schema-install broker-start broker-stop install deps docker-up docker-down docker-build release help +.PHONY: all build clean test test-all test-ci test-integration-go test-unit-go test-connection schema-install broker-start broker-stop install deps docker-up docker-down docker-build release help # Build variables BINARY_NAME=pgsql-broker @@ -63,7 +63,9 @@ test-local-unit: deps ## Run local unit tests @echo "Running local unit tests..." @$(GO) test -v -race -cover $(shell $(GO) list ./... | grep -v /tests/integration) -test-all: test-teardown test-setup test-connection schema-install broker-start test-local-unit test-integration-go broker-stop test-teardown ## Run all unit and integration tests +test-all: test-teardown test-setup test-connection schema-install broker-start test-local-unit test-integration-go broker-stop test-teardown ## Run all unit and integration tests (starts its own Postgres via docker-compose) + +test-ci: test-connection schema-install broker-start test-local-unit test-integration-go broker-stop ## Run all unit and integration tests against an externally-provided Postgres (CI services: block) test-connection: deps ## Test database connection with retry @echo "Testing database connection..."