Skip to content

Commit 5edc29d

Browse files
aksOpsclaude
andcommitted
ci: add build/test pipeline and local pre-commit hook
- .github/workflows/ci.yml: runs on every push/PR to main (CGO_ENABLED=0 build → vet → race-detector tests) - Makefile: build / vet / test / check / setup-hooks targets - scripts/pre-commit: tracked hook script; run `make setup-hooks` to install into .git/hooks (already installed locally) Note: race detector runs in CI only (requires CGO, unavailable on Windows) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 621ca8d commit 5edc29d

3 files changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: go.mod
23+
cache: true
24+
25+
- name: Build
26+
run: CGO_ENABLED=0 go build ./...
27+
28+
- name: Vet
29+
run: go vet ./...
30+
31+
- name: Test
32+
run: CGO_ENABLED=0 go test -race -timeout 120s ./...

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: build test vet check setup-hooks
2+
3+
build:
4+
CGO_ENABLED=0 go build ./...
5+
6+
vet:
7+
go vet ./...
8+
9+
test:
10+
CGO_ENABLED=0 go test -race -timeout 120s ./...
11+
12+
## check runs the same steps as CI: build → vet → test
13+
check: build vet test
14+
15+
## setup-hooks installs the pre-commit hook into .git/hooks
16+
setup-hooks:
17+
cp scripts/pre-commit .git/hooks/pre-commit
18+
chmod +x .git/hooks/pre-commit
19+
@echo "✅ pre-commit hook installed"

scripts/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
echo "🔨 [pre-commit] Building..."
5+
CGO_ENABLED=0 go build ./...
6+
7+
echo "🔍 [pre-commit] Vetting..."
8+
go vet ./...
9+
10+
echo "🧪 [pre-commit] Testing..."
11+
CGO_ENABLED=0 go test -timeout 120s ./...
12+
13+
echo "✅ [pre-commit] All checks passed"

0 commit comments

Comments
 (0)