diff --git a/.github/workflows/tests-go.yaml b/.github/workflows/tests-go.yaml new file mode 100644 index 0000000..c27ab8f --- /dev/null +++ b/.github/workflows/tests-go.yaml @@ -0,0 +1,45 @@ +name: Go Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres-test: + image: postgres:17.2 + ports: + - "5432:5432" + env: + POSTGRES_DB: maek_test + POSTGRES_USER: maek + POSTGRES_PASSWORD: passwd + options: >- + --health-cmd "pg_isready -U maek -d maek_test" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.1' + - run: go version + + - name: Install Go modules + run: go mod download + + - name: Run Go tests with coverage + run: | + export SQL_CONN_TEST="postgres://maek:passwd@localhost:5432/maek_test?sslmode=disable" + export CGO_ENABLED=0 + + go test -v -coverprofile=coverage.out -covermode=atomic $(go list ./... | grep -v /vendor/)