name: build

on:
  push:
    branches:
      - "main"
  pull_request:

jobs:
  build:
    uses: charmbracelet/meta/.github/workflows/build.yml@main

  snapshot:
    uses: charmbracelet/meta/.github/workflows/snapshot.yml@main
    secrets:
      goreleaser_key: ${{ secrets.GORELEASER_KEY }}

  test_postgres:
    services:
      postgres:
        image: postgres
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Install Go
        uses: actions/setup-go@v5
        with:
          go-version: ^1
          cache: true
      - name: Download Go modules
        run: go mod download
      - name: Test
        run: go test ./...
        env:
          SOFT_SERVE_DB_DRIVER: postgres
          SOFT_SERVE_DB_DATA_SOURCE: postgres://postgres:postgres@localhost/postgres?sslmode=disable
