feat(observability): LLM token-usage recorder interface (issue #168) #185
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Purpose: Go CI for the sin-code binary: build, vet, tests, and benchmarks. | |
| # Docs: .github/workflows/go-ci.yml.doc.md | |
| name: go-ci | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| concurrency: | |
| group: go-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: go test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.11" | |
| - name: Install gopls (for lsp_live test) | |
| run: go install golang.org/x/tools/gopls@latest | |
| - name: Build | |
| run: go build ./cmd/sin-code | |
| - name: Vet | |
| run: go vet ./cmd/sin-code/... ./cmd/sin-code/internal/... | |
| - name: Setup Python for skill validation | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Validate bundled skills | |
| run: | | |
| pip install pyyaml | |
| python3 scripts/validate_skill.py --all-bundled --strict | |
| - name: Test | |
| run: go test ./cmd/sin-code/ ./cmd/sin-code/internal/ -count=1 -v 2>&1 | tail -50 | |
| - name: Test LSP live (build tag, opt-in) | |
| run: go test -tags lsp_live ./cmd/sin-code/ -run TestLspLive -count=1 -v 2>&1 | tail -20 | |
| benchmark: | |
| name: benchmark | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.11" | |
| - name: Run benchmarks | |
| run: | | |
| set -euo pipefail | |
| go test ./cmd/sin-code/internal/ \ | |
| -run='^$' \ | |
| -bench='Benchmark' \ | |
| -benchmem \ | |
| -count=3 \ | |
| -timeout=300s \ | |
| 2>&1 | tee benchmark.out | |
| - name: Check indexed vs fullscan speedup | |
| run: | | |
| set -euo pipefail | |
| # Extract median latencies and fail if indexed is not at least 3x faster. | |
| # CI runners have 2-4 cores and slower I/O; the 5x+ target is verified | |
| # locally via benchmark.sh. We use float-safe awk and median, not min. | |
| median() { | |
| grep "BenchmarkComparisonTable/$1" benchmark.out \ | |
| | awk '{print $3}' | sort -n \ | |
| | awk '{a[NR]=$1} END { | |
| if (NR==0) exit 1 | |
| if (NR%2) print a[(NR+1)/2] | |
| else print (a[NR/2]+a[NR/2+1])/2 | |
| }' | |
| } | |
| fullscan=$(median fullscan) | |
| indexed=$(median indexed) | |
| echo "FullScan median: $fullscan ns/op" | |
| echo "Indexed median: $indexed ns/op" | |
| if [ -z "$fullscan" ] || [ -z "$indexed" ]; then | |
| echo "Missing benchmark results" | |
| exit 1 | |
| fi | |
| awk -v fs="$fullscan" -v idx="$indexed" 'BEGIN { | |
| speedup = fs / idx | |
| printf "Speedup: %.1fx\n", speedup | |
| if (speedup < 3.0) { | |
| print "ERROR: Indexed search is not at least 3x faster than full scan" | |
| exit 1 | |
| } | |
| printf "PASS: Indexed search is %.1fx faster\n", speedup | |
| }' | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmark.out |