forked from Dicklesworthstone/beads_viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (112 loc) · 3.92 KB
/
ci.yml
File metadata and controls
126 lines (112 loc) · 3.92 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
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.5'
- name: Build
run: go build -v ./cmd/bv
- name: Test with Coverage
run: go test -v -covermode=atomic -coverprofile=coverage.out ./pkg/... ./cmd/bv
- name: E2E Tests
run: go test -v ./tests/e2e -count=1
- name: Enforce Coverage Threshold (project, pkg/* only)
run: |
total=$(awk '
NR == 1 { next } # mode line
{
file = $1
sub(/:.*/, "", file)
if (file !~ /^github.com\/Dicklesworthstone\/beads_viewer\/pkg\//) next
stmts = $2
count = $3
all += stmts
if (count > 0) hit += stmts
}
END {
if (all == 0) { printf("0.00"); exit 0 }
printf("%.2f", (hit / all) * 100)
}
' coverage.out)
echo "pkg/* coverage: ${total}% (threshold 71%)"
awk -v c="$total" 'BEGIN { if (c < 71.0) { printf("pkg/* coverage %.2f%% is below 71%%\n", c); exit 1 } }'
- name: Enforce Coverage Thresholds (per-package, statement-weighted)
run: |
set -euo pipefail
awk '
NR == 1 { next } # mode line
{
file = $1
sub(/:.*/, "", file) # strip :line.col,line.col
pkg = file
sub(/\/[^\/]+$/, "", pkg) # strip /file.go
stmts = $2
count = $3
total[pkg] += stmts
if (count > 0) covered[pkg] += stmts
}
END {
for (pkg in total) {
pct = (covered[pkg] / total[pkg]) * 100
printf "%s %.2f\n", pkg, pct
}
}
' coverage.out | sort > pkgcov.txt
# Enforce thresholds for key packages.
while read -r pkg pct; do
req=
case "$pkg" in
github.com/Dicklesworthstone/beads_viewer/pkg/analysis) req=75 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/export) req=69 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/recipe) req=90 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/ui) req=55 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/loader) req=80 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/updater) req=55 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/watcher) req=60 ;;
github.com/Dicklesworthstone/beads_viewer/pkg/workspace) req=85 ;;
esac
if [ -z "$req" ]; then
continue
fi
if awk -v p="$pct" -v r="$req" 'BEGIN { exit !(p < r) }'; then
echo "Coverage for $pkg is ${pct}% (< ${req}%)"
exit 1
fi
done < pkgcov.txt
echo "Per-package thresholds OK"
- name: Coverage Report Artifact
run: |
go tool cover -html=coverage.out -o coverage.html
- name: Upload Coverage Artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.html
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage.out
flags: unittests
name: codecov-coverage
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run Quick Benchmarks
run: |
echo "Running critical benchmarks to catch performance regressions..."
go test -bench='BenchmarkFullAnalysis_(Sparse100|Dense100|ManyCycles20)' \
-benchmem -count=1 ./pkg/analysis/...
- name: Verify Timeout Protection
run: |
echo "Verifying timeout protection prevents hangs..."
go test -v -run='TestTimeoutProtection' ./pkg/analysis/... -timeout 30s