add workflow engine unit tests with mock store #8
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: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: kronos | |
| POSTGRES_PASSWORD: kronos | |
| POSTGRES_DB: kronos | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U kronos" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| cache: true | |
| # go.sum is generated here and used for the rest of the job. | |
| # Developers should run `go mod tidy` locally before pushing. | |
| - name: Tidy and verify dependencies | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod || (echo "go.mod is not tidy — run 'go mod tidy'" && exit 1) | |
| - name: Build | |
| run: go build ./... | |
| - name: Unit tests (race detector) | |
| run: go test -race -count=1 ./... | |
| - name: Integration tests | |
| env: | |
| DATABASE_URL: postgres://kronos:kronos@localhost:5432/kronos?sslmode=disable | |
| run: go test -tags integration -race -count=1 -timeout 120s ./internal/integration/... | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| cache: true | |
| - run: go mod tidy | |
| - name: go vet | |
| run: go vet ./... | |
| - name: gofmt check | |
| run: | | |
| unformatted=$(gofmt -l .) | |
| if [ -n "$unformatted" ]; then | |
| echo "The following files need gofmt:" | |
| echo "$unformatted" | |
| exit 1 | |
| fi | |
| bench: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: kronos | |
| POSTGRES_PASSWORD: kronos | |
| POSTGRES_DB: kronos | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U kronos" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| cache: true | |
| - run: go mod tidy | |
| - name: Worker pool micro-benchmark | |
| run: go test -bench=BenchmarkPool_Throughput -benchtime=5s -count=1 ./internal/worker/ | tee bench.txt | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: bench-${{ github.sha }} | |
| path: bench.txt |