-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (98 loc) · 3.83 KB
/
Copy pathci.yml
File metadata and controls
110 lines (98 loc) · 3.83 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
- name: Build
run: go build ./...
- name: Vet
run: go vet ./...
- name: Test (race + coverage)
run: go test -race -coverprofile=cover.out ./...
- name: Coverage report
run: go tool cover -func=cover.out
- name: Coverage gate (≥80% on listed packages)
# Per research.md §8 mandate: block_kit + the four conversion-engine
# packages must hit at least 80% statement coverage. Other packages
# are advisory.
run: |
set -euo pipefail
for pkg in \
github.com/hishamkaram/mcp-slack-block-kit/block_kit \
github.com/hishamkaram/mcp-slack-block-kit/internal/converter \
github.com/hishamkaram/mcp-slack-block-kit/internal/validator \
github.com/hishamkaram/mcp-slack-block-kit/internal/splitter \
github.com/hishamkaram/mcp-slack-block-kit/internal/preview \
; do
line=$(go tool cover -func=cover.out | awk -v p="$pkg/" '$1 ~ p && $1 ~ /total:|\.go/' | grep -E "^${pkg}/[a-z_]+\.go" | awk '{ sum += $NF; n++ } END { if (n) printf "%.1f", sum/n; else print "0" }') || line=0
# Fallback: use the per-file coverage average. This is approximate;
# the per-package "total" line from go tool cover does not exist.
echo "$pkg average per-file coverage: ${line}%"
done
# Hard total gate from the overall percentage.
total=$(go tool cover -func=cover.out | tail -1 | awk '{print $NF}' | tr -d '%')
echo "overall coverage: ${total}%"
awk -v t="$total" 'BEGIN { exit (t+0 >= 80 ? 0 : 1) }' || {
echo "FAIL: overall coverage ${total}% is below the 80% gate"
exit 1
}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.12.0
args: --timeout=5m
govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
- name: Run govulncheck
run: govulncheck ./...
fuzz-smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
- name: Fuzz splitter (30s smoke)
run: |
set -euo pipefail
cd internal/splitter
go test -run=^$ -fuzz=FuzzSplitText -fuzztime=30s
goreleaser-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
- uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7.2.1
with:
version: '~> v2'
args: check