hatch-surf/.github/workflows/ci.yml
Riley Zhang 6f03ff2465 Add linting, formatting, and test infrastructure for Phase 1
- Add .golangci.yml with sensible linting rules
- Add Makefile with test, lint, fmt, vet, build targets
- Enhance CI pipeline with Go formatting check and golangci-lint job
- Create shared testutil.FakeRepository for handler tests
- Refactor handler tests to use shared FakeRepository
- Add data/ and coverage.out to .gitignore

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-24 04:59:52 +02:00

76 lines
1.5 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Files not formatted:"
gofmt -l .
exit 1
fi
- name: Vet
run: go vet ./...
- name: Test
run: go test ./... -v -race
- name: Build
run: CGO_ENABLED=0 go build -o /dev/null ./cmd/hatch
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t hatch:ci .
- name: Smoke test the Docker image
run: |
docker run --rm -d -p 8080:8080 --name hatch-ci hatch:ci
sleep 2
curl -fsS http://localhost:8080/healthz | grep -q 'ok'
docker stop hatch-ci
lint-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
lint-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check markdown formatting
uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: '**/*.md'
continue-on-error: true