name: Go tests on: push: branches: [main] paths: - 'app/**' - '.github/workflows/go-tests.yml' pull_request: branches: [main] paths: - 'app/**' - '.github/workflows/go-tests.yml' permissions: contents: read jobs: test: name: Test Go app runs-on: ubuntu-latest services: postgres: image: postgres:17-alpine env: POSTGRES_DB: todo_test POSTGRES_USER: todo_test POSTGRES_PASSWORD: test-password ports: - 5432:5432 options: >- --health-cmd "pg_isready -U todo_test -d todo_test" --health-interval 10s --health-timeout 5s --health-retries 5 defaults: run: working-directory: app env: TEST_DATABASE_URL: postgres://todo_test:test-password@127.0.0.1:5432/todo_test?sslmode=disable steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Go uses: actions/setup-go@v6 with: go-version-file: app/go.mod cache-dependency-path: app/go.sum - name: Run tests run: go test ./... - name: Run vet run: go vet ./...