ci: update ci workflow #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| workflow_call: | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| GO_VERSION: '1.25' | |
| jobs: | |
| lint: | |
| name: Lint Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Check formatting | |
| run: gofmt -l . | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run unit tests | |
| run: go test -v -race ./internal/... | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_DB: echobase_test | |
| POSTGRES_USER: user | |
| POSTGRES_PASSWORD: pass | |
| ports: | |
| - 5433:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Install sql-migrate | |
| run: go install github.com/rubenv/sql-migrate/sql-migrate@latest | |
| - name: Wait for PostgreSQL | |
| run: | | |
| until pg_isready -h localhost -p 5433 -U user; do | |
| echo "Waiting for PostgreSQL..." | |
| sleep 2 | |
| done | |
| - name: Run database migrations | |
| run: sql-migrate up -env=test | |
| env: | |
| DATABASE_URL: postgresql://user:pass@localhost:5433/echobase_test?sslmode=disable | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run integration tests | |
| run: go test -v -race -tags=integration ./test/integration/... | |
| env: | |
| EB_DSN: postgresql://user:pass@localhost:5433/echobase_test?sslmode=disable |