-
Notifications
You must be signed in to change notification settings - Fork 104
118 lines (98 loc) · 3.15 KB
/
ci.yml
File metadata and controls
118 lines (98 loc) · 3.15 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
name: CI
on:
pull_request:
branches: [main, dev]
push:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test-and-build:
name: Test & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache-dependency-path: go.sum
- name: Prepare desktop embed placeholder
run: |
mkdir -p desktop/frontend/dist
printf 'ci placeholder\n' > desktop/frontend/dist/.ci-placeholder
- name: Check go mod tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum || (echo "go.mod/go.sum not tidy — run 'go mod tidy'" && exit 1)
- name: Run race tests
run: |
packages=$(go list ./... | grep -v /desktop)
while IFS= read -r pkg; do
echo "::group::go test -race $pkg"
go test -v -race "$pkg"
echo "::endgroup::"
done <<EOF
$packages
EOF
- name: Collect coverage
run: |
packages=$(go list ./... | grep -v /desktop)
profile=coverage.out
tmp_profile=$(mktemp)
found_test_package=false
echo 'mode: set' > "$profile"
while IFS= read -r pkg; do
dir=$(go list -f '{{.Dir}}' "$pkg")
if ! find "$dir" -maxdepth 1 -name '*_test.go' | grep -q .; then
continue
fi
go test -v -coverprofile="$tmp_profile" "$pkg"
tail -n +2 "$tmp_profile" >> "$profile"
found_test_package=true
done <<EOF
$packages
EOF
if [ "$found_test_package" = false ]; then
echo "no test packages found for coverage collection" >&2
exit 1
fi
- name: Build binary
run: go build -o haft -trimpath ./cmd/haft/
- name: Smoke test — binary starts and responds to MCP initialize
run: |
RESPONSE=$(echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{}}' | timeout 5 ./haft serve 2>/dev/null || true)
if echo "$RESPONSE" | grep -q '"protocolVersion"'; then
echo "Smoke test passed: MCP server responds correctly"
else
echo "Smoke test FAILED: no valid MCP response"
echo "Response was: $RESPONSE"
exit 1
fi
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
file: coverage.out
fail_ci_if_error: false
continue-on-error: true
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache-dependency-path: go.sum
- name: Prepare desktop embed placeholder
run: |
mkdir -p desktop/frontend/dist
printf 'ci placeholder\n' > desktop/frontend/dist/.ci-placeholder
- uses: golangci/golangci-lint-action@v7
with:
version: v2.11.4
args: --timeout=5m