Skip to content

Commit 3e3f801

Browse files
committed
ci: add GitHub Actions workflow for testing
Add a CI workflow that runs on every push and pull request to main: gofmt verification, go vet, race-enabled tests with coverage, library and example builds, and a benchmark smoke run. The job matrix covers the module's minimum Go version (1.24.3) and the latest stable release. Also gofmt-format examples/db-explorer/main.go so the new gofmt gate passes against the existing tree. https://claude.ai/code/session_015dqx2yBNNyyfgznEV36bHe
1 parent 5d49ea3 commit 3e3f801

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
test:
14+
name: Test (Go ${{ matrix.go-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
# Test against the module's minimum supported version and the latest
20+
# stable release to catch version-specific regressions.
21+
go-version: ['1.24.3', 'stable']
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
31+
- name: Verify gofmt
32+
run: |
33+
unformatted=$(gofmt -l .)
34+
if [ -n "$unformatted" ]; then
35+
echo "The following files are not gofmt-formatted:"
36+
echo "$unformatted"
37+
exit 1
38+
fi
39+
40+
- name: Vet
41+
run: go vet ./...
42+
43+
- name: Test (race + coverage)
44+
run: go test ./gomcp/ -race -count=1 -coverprofile=coverage.out -covermode=atomic
45+
46+
- name: Coverage summary
47+
run: go tool cover -func=coverage.out
48+
49+
- name: Build
50+
run: go build ./...
51+
52+
- name: Build examples
53+
# Mirrors the Makefile `examples` target. db-explorer is intentionally
54+
# omitted: it is gated behind a build constraint and is not part of the
55+
# default build.
56+
run: |
57+
go build -o /dev/null ./examples/greet/
58+
go build -o /dev/null ./examples/sys-monitor/
59+
go build -o /dev/null ./examples/fs-navigator/
60+
61+
- name: Benchmarks (compile + smoke run)
62+
run: go test ./gomcp/ -run '^$' -bench . -benchmem -benchtime 10x

examples/db-explorer/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
//
1010
// Requires: github.com/lib/pq driver
1111
// Build: go build -tags ignore -o db-explorer .
12-
// or remove the build tag and: go get github.com/lib/pq
12+
//
13+
// or remove the build tag and: go get github.com/lib/pq
14+
//
1315
// Test: echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | ./db-explorer
1416
package main
1517

@@ -21,8 +23,8 @@ import (
2123
"os"
2224
"strings"
2325

24-
_ "github.com/lib/pq"
2526
"github.com/BackendStack21/go-mcp/gomcp"
27+
_ "github.com/lib/pq"
2628
)
2729

2830
func main() {

0 commit comments

Comments
 (0)