name: Backend CI on: pull_request: branches: [main] push: branches: [main] jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.22' cache-dependency-path: backend/go.sum - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: version: latest working-directory: backend test: name: Test runs-on: ubuntu-latest services: postgres: image: postgres:16-alpine env: POSTGRES_DB: cupoints_test POSTGRES_USER: dev POSTGRES_PASSWORD: dev ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.22' cache-dependency-path: backend/go.sum - name: Run migrations env: GOOSE_DRIVER: postgres GOOSE_DBSTRING: postgres://dev:dev@localhost:5432/cupoints_test?sslmode=disable run: | go install github.com/pressly/goose/v3/cmd/goose@latest goose -dir migrations up - name: go test working-directory: backend env: DATABASE_URL: postgres://dev:dev@localhost:5432/cupoints_test?sslmode=disable REDIS_URL: redis://localhost:6379 JWT_SECRET: test-secret-key-minimum-32-characters-long JWT_ACCESS_TTL: 15m JWT_REFRESH_TTL: 168h PORT: 8080 ENV: test run: go test -race -coverprofile=coverage.out ./... - name: Upload coverage uses: actions/upload-artifact@v4 with: name: backend-coverage path: backend/coverage.out