-
Notifications
You must be signed in to change notification settings - Fork 47
232 lines (193 loc) · 6.37 KB
/
ci.yml
File metadata and controls
232 lines (193 loc) · 6.37 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: CI
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
go-version: ['1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install ast-grep
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
pip install ast-grep-cli
elif [ "$RUNNER_OS" = "macOS" ]; then
brew install ast-grep
fi
shell: bash
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run go vet
run: go vet ./...
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Enforce coverage floor
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23'
run: |
total=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}')
# Current enforced coverage floor. Codex PRs raise this incrementally toward 90%.
min=50.0
awk -v t="$total" -v m="$min" 'BEGIN {
if (t+0 < m+0) {
printf "Coverage %.1f%% is below floor %.1f%%\n", t, m
exit 1
}
printf "Coverage %.1f%% meets floor %.1f%%\n", t, m
}'
# Export for badge step
echo "COVERAGE=$(printf '%.0f' "$total")" >> "$GITHUB_ENV"
- name: Update coverage badge
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23' && github.ref == 'refs/heads/main'
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 6ffe3276ddb8a7a7f08d50d649e567bd
filename: codemap-coverage.json
label: coverage
message: ${{ env.COVERAGE }}%
valColorRange: ${{ env.COVERAGE }}
minColorRange: 45
maxColorRange: 90
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23'
uses: codecov/codecov-action@v4
with:
files: coverage.out
fail_ci_if_error: false
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Build binary
run: go build -v -o codemap${{ matrix.os == 'windows-latest' && '.exe' || '' }} .
- name: Test binary runs
shell: bash
run: ./codemap${{ matrix.os == 'windows-latest' && '.exe' || '' }} --help
- name: Test basic tree output
shell: bash
run: ./codemap${{ matrix.os == 'windows-latest' && '.exe' || '' }} .
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Go files are not formatted:"
gofmt -d .
exit 1
fi
- name: Run staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...
- name: Run go vet
run: go vet ./...
homebrew-audit:
name: Homebrew Formula Audit
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Audit formula syntax
run: |
# Install homebrew-core tap for comparison
brew tap homebrew/core --force 2>/dev/null || true
# Run basic Ruby syntax check on formula
ruby -c codemap.rb
# Check formula follows Homebrew style guidelines
brew style --formula codemap.rb || true
# Validate required formula components
echo "Checking formula has required components..."
grep -q 'class Codemap < Formula' codemap.rb
grep -q 'desc' codemap.rb
grep -q 'homepage' codemap.rb
grep -q 'url' codemap.rb
grep -q 'sha256' codemap.rb
grep -q 'license' codemap.rb
grep -q 'def install' codemap.rb
grep -q 'test do' codemap.rb
echo "Formula has all required components"
integration:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Install ast-grep
run: pip install ast-grep-cli
- name: Build binary
run: go build -o codemap .
- name: Test tree mode
run: |
output=$(./codemap .)
if [ -z "$output" ]; then
echo "Tree mode produced no output"
exit 1
fi
echo "Tree mode output:"
echo "$output" | head -20
- name: Test help flag
run: |
output=$(./codemap --help)
echo "$output" | grep -q "codemap"
echo "$output" | grep -q "Usage:"
echo "$output" | grep -q "\-\-skyline"
echo "$output" | grep -q "\-\-deps"
echo "$output" | grep -q "\-\-diff"
- name: Test JSON output
run: |
output=$(./codemap --json .)
echo "$output" | python3 -c "import sys, json; json.load(sys.stdin)"
echo "JSON output is valid"
- name: Test diff mode (should work in git repo)
run: |
# This should either show changes or say "No files changed"
./codemap --diff . || true
- name: Test deps mode
run: |
output=$(./codemap --deps .)
echo "$output"
echo "$output" | grep -q "Dependency Flow"
- name: Test with subdirectory
run: |
./codemap scanner
./codemap render
- name: Test nonexistent path handling
run: |
# Should fail gracefully
if ./codemap /nonexistent/path 2>&1; then
echo "Should have failed for nonexistent path"
exit 1
fi
echo "Correctly failed for nonexistent path"