-
Notifications
You must be signed in to change notification settings - Fork 0
335 lines (292 loc) · 9.58 KB
/
Copy pathci.yml
File metadata and controls
335 lines (292 loc) · 9.58 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
name: CI
on:
pull_request:
branches: [main, develop]
workflow_call:
permissions:
contents: write
pull-requests: write
checks: write
security-events: write
actions: read
pages: write
id-token: write
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
cache-dependency-path: go.sum
- name: Go Lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.10.1
args: --timeout=5m --config=.golangci.yml ./cmd/... ./internal/... ./pkg/...
only-new-issues: ${{ github.event_name == 'pull_request' }}
skip-cache: false
test-core:
name: Test Core
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
cache-dependency-path: go.sum
- name: Cache Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
- name: Run Core Tests
run: |
CORE_PKGS="./internal/... ./pkg/store/... ./pkg/log/... ./pkg/ui/component/... ./pkg/ui/theme/..."
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "Running tests with race detector (main/develop branch)"
go test -race -coverprofile=coverage-core.txt -covermode=atomic $CORE_PKGS
else
echo "Running tests without race detector (PR - faster feedback)"
go test -coverprofile=coverage-core.txt -covermode=atomic $CORE_PKGS
fi
- name: Upload Core Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-core
path: coverage-core.txt
test-cli:
name: Test CLI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
cache-dependency-path: go.sum
- name: Cache Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
- name: Run CLI Tests
run: |
CLI_PKGS="./pkg/cli/..."
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "Running tests with race detector (main/develop branch)"
go test -race -p 1 -coverprofile=coverage-cli.txt -covermode=atomic $CLI_PKGS
else
echo "Running tests without race detector (PR - faster feedback)"
go test -p 1 -coverprofile=coverage-cli.txt -covermode=atomic $CLI_PKGS
fi
- name: Upload CLI Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-cli
path: coverage-cli.txt
coverage:
name: Upload Coverage
needs: [test-core, test-cli]
runs-on: ubuntu-latest
steps:
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
path: coverage
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage/coverage-core/coverage-core.txt,coverage/coverage-cli/coverage-cli.txt
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
cache-dependency-path: go.sum
- name: Build
run: go build -v ./cmd/arc
benchmark:
name: Benchmark
needs: [test-core, test-cli]
uses: ./.github/workflows/benchmark.yml
secrets: inherit
permissions:
contents: write
pull-requests: write
pr_size:
name: PR Size Label
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Check PR Size
uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: "size/XS"
xs_max_size: 10
s_label: "size/S"
s_max_size: 50
m_label: "size/M"
m_max_size: 200
l_label: "size/L"
l_max_size: 500
xl_label: "size/XL"
fail_if_xl: false
message_if_xl: >
⚠️ This PR is very large (500+ lines). Consider breaking it into smaller PRs for easier review.
files_to_ignore: "go.sum"
spellcheck:
name: Spell Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Spell Check in docs/
uses: crate-ci/typos@master
with:
config: .typos.toml
files: "docs/ README.md"
link_check:
name: Link Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Links in docs/
uses: lycheeverse/lychee-action@v2
with:
args: >-
--verbose --no-progress
--exclude-path '.github'
--exclude-path 'specs'
--exclude 'conventionalcommits\.org'
--exclude 'github\.com/arc-framework/arc-cli/releases'
'docs/**/*.md' 'README.md'
fail: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
binary_size:
name: Binary Size Tracker
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- name: Build PR Binary
run: |
go build -ldflags="-s -w" -o arc-pr ./cmd/arc
PR_SIZE=$(stat -f%z arc-pr 2>/dev/null || stat -c%s arc-pr)
echo "pr_size=$PR_SIZE" >> $GITHUB_OUTPUT
id: pr
- name: Checkout Base
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Build Base Binary
run: |
go build -ldflags="-s -w" -o arc-base ./cmd/arc
BASE_SIZE=$(stat -f%z arc-base 2>/dev/null || stat -c%s arc-base)
echo "base_size=$BASE_SIZE" >> $GITHUB_OUTPUT
id: base
- name: Compare Sizes
uses: actions/github-script@v7
with:
script: |
const prSize = ${{ steps.pr.outputs.pr_size }};
const baseSize = ${{ steps.base.outputs.base_size }};
const diff = prSize - baseSize;
const diffPercent = ((diff / baseSize) * 100).toFixed(2);
const formatSize = (bytes) => {
const kb = bytes / 1024;
const mb = kb / 1024;
return mb >= 1 ? `${mb.toFixed(2)} MB` : `${kb.toFixed(2)} KB`;
};
let emoji = '📊';
let status = 'No significant change';
if (Math.abs(diffPercent) > 5) {
emoji = diff > 0 ? '📈' : '📉';
status = diff > 0 ? 'Size increased' : 'Size decreased';
}
const comment = `${emoji} **Binary Size ${status}**
| Metric | Size |
|--------|------|
| Base | ${formatSize(baseSize)} |
| PR | ${formatSize(prSize)} |
| Diff | ${diff > 0 ? '+' : ''}${formatSize(Math.abs(diff))} (${diff > 0 ? '+' : ''}${diffPercent}%) |
${Math.abs(diffPercent) > 10 ? '⚠️ **Warning**: Binary size changed by more than 10%' : ''}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Enforce size limit
shell: bash
run: |
PR_SIZE="${{ steps.pr.outputs.pr_size }}"
MAX_SIZE=20971520 # 20 MB hard limit
echo "Binary size: $(( PR_SIZE / 1024 / 1024 )) MB (${PR_SIZE} bytes)"
if [ "${PR_SIZE}" -gt "${MAX_SIZE}" ]; then
echo "::error::Binary exceeds 20 MB hard limit. Current: ${PR_SIZE} bytes."
exit 1
fi
echo "Size OK ✓"
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
cache-dependency-path: go.sum
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Run Gosec
uses: securego/gosec@master
with:
args: "-exclude=G304,G301,G306,G703 -confidence=high -severity=high -fmt text ./..."
- name: Dependency Review
if: github.event_name == 'pull_request'
uses: actions/dependency-review-action@v4
continue-on-error: true
with:
fail-on-severity: high