Skip to content

Commit a485188

Browse files
authored
chore: add go mod tidy check (#99)
Signed-off-by: bitliu <[email protected]>
1 parent 464ed6c commit a485188

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

.github/workflows/test-and-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
~/go/pkg/mod
5252
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
5353

54+
- name: Check go mod tidy
55+
run: make check-go-mod-tidy
56+
5457
- name: Build Rust library
5558
run: make rust
5659

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ pre-commit run --all-files
222222
- Use meaningful variable and function names
223223
- Add comments for exported functions and types
224224
- Write unit tests for new functionality
225+
- **Keep Go modules tidy:** Run `go mod tidy` in the appropriate directory after adding or removing dependencies
226+
- For `candle-binding`: `cd candle-binding && go mod tidy`
227+
- For `src/semantic-router`: `cd src/semantic-router && go mod tidy`
228+
- The CI will automatically check that `go.mod` and `go.sum` files are tidy using `make check-go-mod-tidy`
225229

226230
### Rust Code
227231
- Follow Rust formatting (`cargo fmt`)
@@ -242,6 +246,11 @@ pre-commit run --all-files
242246
python e2e-tests/run_all_tests.py
243247
```
244248

249+
The `make test` command includes:
250+
- `go vet` for static analysis
251+
- `check-go-mod-tidy` for Go module dependency verification
252+
- Unit tests for all components
253+
245254
2. **Create a pull request** with:
246255
- Clear description of changes
247256
- Reference to any related issues

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ vet:
6161
@cd candle-binding && go vet ./...
6262
@cd src/semantic-router && go vet ./...
6363

64+
# Check go mod tidy for all Go modules
65+
check-go-mod-tidy:
66+
@echo "Checking go mod tidy for all Go modules..."
67+
@echo "Checking candle-binding..."
68+
@cd candle-binding && go mod tidy && \
69+
(git diff --exit-code go.mod 2>/dev/null || (echo "ERROR: go.mod file is not tidy in candle-binding. Please run 'go mod tidy' in candle-binding directory and commit the changes." && git diff go.mod && exit 1)) && \
70+
(test ! -f go.sum || git diff --exit-code go.sum 2>/dev/null || (echo "ERROR: go.sum file is not tidy in candle-binding. Please run 'go mod tidy' in candle-binding directory and commit the changes." && git diff go.sum && exit 1))
71+
@echo "✅ candle-binding go mod tidy check passed"
72+
@echo "Checking src/semantic-router..."
73+
@cd src/semantic-router && go mod tidy && \
74+
if ! git diff --exit-code go.mod go.sum; then \
75+
echo "ERROR: go.mod or go.sum files are not tidy in src/semantic-router. Please run 'go mod tidy' in src/semantic-router directory and commit the changes."; \
76+
git diff go.mod go.sum; \
77+
exit 1; \
78+
fi
79+
@echo "✅ src/semantic-router go mod tidy check passed"
80+
@echo "✅ All go mod tidy checks passed"
81+
6482
# Test the Rust library
6583
test-binding: rust
6684
@echo "Running Go tests with static library..."
@@ -92,7 +110,7 @@ test-semantic-router: build-router
92110
cd src/semantic-router && CGO_ENABLED=1 go test -v ./...
93111

94112
# Test the Rust library and the Go binding
95-
test: vet download-models test-binding test-semantic-router
113+
test: vet check-go-mod-tidy download-models test-binding test-semantic-router
96114

97115
# Clean built artifacts
98116
clean:

src/semantic-router/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ replace (
1010

1111
require (
1212
github.com/envoyproxy/go-control-plane/envoy v1.32.4
13+
github.com/fsnotify/fsnotify v1.7.0
1314
github.com/onsi/ginkgo/v2 v2.23.4
1415
github.com/onsi/gomega v1.38.0
1516
github.com/openai/openai-go v1.12.0
1617
github.com/prometheus/client_golang v1.23.0
1718
github.com/vllm-project/semantic-router/candle-binding v0.0.0-00010101000000-000000000000
19+
go.uber.org/zap v1.27.0
1820
google.golang.org/grpc v1.71.1
1921
gopkg.in/yaml.v3 v3.0.1
2022
)
@@ -24,7 +26,6 @@ require (
2426
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2527
github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3 // indirect
2628
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
27-
github.com/fsnotify/fsnotify v1.7.0 // indirect
2829
github.com/go-logr/logr v1.4.2 // indirect
2930
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3031
github.com/google/go-cmp v0.7.0 // indirect
@@ -41,7 +42,6 @@ require (
4142
github.com/tidwall/sjson v1.2.5 // indirect
4243
go.uber.org/automaxprocs v1.6.0 // indirect
4344
go.uber.org/multierr v1.10.0 // indirect
44-
go.uber.org/zap v1.27.0 // indirect
4545
golang.org/x/net v0.41.0 // indirect
4646
golang.org/x/sys v0.33.0 // indirect
4747
golang.org/x/text v0.26.0 // indirect

0 commit comments

Comments
 (0)