-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
128 lines (103 loc) · 3.01 KB
/
Copy pathjustfile
File metadata and controls
128 lines (103 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
set quiet := true
set shell := ["bash", "-cu"]
export GOCACHE := justfile_directory() + "/.cache/go-build"
export GOLANGCI_LINT_CACHE := justfile_directory() + "/.cache/golangci-lint"
export GOFLAGS := "-buildvcs=false"
export GOROOT := ""
oapi_codegen_version := env("OAPI_CODEGEN_VERSION", "v2.7.0")
git_sha := `git rev-parse HEAD 2>/dev/null || echo unknown`
git_short_sha := `git rev-parse --short=12 HEAD 2>/dev/null || echo dev`
version_ldflags := "-s -w -X github.com/garrettladley/pkgsite-mcp/internal/version.Version=sha-" + git_short_sha + " -X github.com/garrettladley/pkgsite-mcp/internal/version.Commit=" + git_sha
[private]
default:
just --list
# install go dependencies
[group('dev')]
install:
go mod download
# tidy go modules
[group('dev')]
tidy:
go mod tidy
# generate pkgsite API client
[group('codegen')]
generate:
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@{{ oapi_codegen_version }} -config internal/pkgsiteapi/oapi-codegen.yaml internal/pkgsiteapi/openapi.json
# verify generated code is up to date
[group('ci')]
generate-verify: generate
git diff --exit-code -- internal/pkgsiteapi/client.gen.go
# format code
[group('dev')]
fmt:
golangci-lint fmt
# modernize Go code
[group('dev')]
go-fix:
go fix ./...
# verify go fix does not produce changes
[group('ci')]
go-fix-verify:
#!/usr/bin/env bash
set -euo pipefail
go fix ./...
git diff --exit-code || (echo "go fix produced changes - run 'go fix ./...' locally and commit" && exit 1)
# run linter
[group('dev')]
lint:
go fix ./...
golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
# run linter with auto-fix
[group('dev')]
lint-fix:
go fix ./...
golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
# build the MCP server
[group('build')]
build:
go build -ldflags="{{ version_ldflags }}" -o .cache/bin/pkgsite-mcp ./cmd/pkgsite-mcp
# run Go vet
[group('ci')]
vet:
go vet ./...
# build the Docker image
[group('docker')]
docker-build:
docker build --build-arg VERSION=sha-{{ git_short_sha }} --build-arg COMMIT={{ git_sha }} -t pkgsite-mcp:local .
# deploy to Fly
[group('deploy')]
deploy:
flyctl deploy --remote-only
# start local Redis
[group('docker')]
up:
docker compose up
# start local Redis in the background
[group('docker')]
up-detached:
docker compose up -d
# stop local Redis
[group('docker')]
down:
docker compose down
# show Redis logs
[group('docker')]
logs:
docker compose logs -f redis
# run the HTTP MCP server locally
[group('dev')]
serve-http: build
KV_REDIS_URL="${KV_REDIS_URL:-redis://localhost:9736/0}" .cache/bin/pkgsite-mcp serve --transport http --addr :8080
# run tests
[group('dev')]
test:
go test -v -race ./...
# run tests with coverage output for CI
[group('ci')]
test-ci:
go test -v -json -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... -timeout 5m
# run local verification
[group('dev')]
check: generate fmt lint vet test build
alias b := build
alias t := test