Repository navigation
101 lines (84 loc) · 2.75 KB
/
Copy pathci.yml
File metadata and controls
101 lines (84 loc) · 2.75 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
# SPDX-License-Identifier: AGPL-3.0
name: CI
# 只做测试与验证:不发布、不推送镜像、不上传构建产物(coverage 除外)。
# 触发条件与 Release 互斥:分支/PR 触发,显式排除 tag。
on:
workflow_dispatch:
push:
branches: [main]
tags-ignore: ['**']
pull_request:
branches: [main]
# 与 Release 使用不同的 concurrency group,避免互相阻塞。
concurrency: ci-${{ github.ref }}
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.27.x'
cache: true
- name: Cache go build
uses: actions/cache@v5
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ hashFiles('**/*.go', 'go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
- name: gofmt
run: test -z "$(gofmt -l .)"
- name: go vet
run: go vet ./...
- name: go test
run: go test ./... -race -coverprofile=coverage.out
- name: Upload coverage
uses: actions/upload-artifact@v5
with:
name: coverage
path: coverage.out
retention-days: 7
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: '20'
cache: npm
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Verify committed dist matches source
run: |
# web/dist is embedded in the binary, so a stale commit silently ships
# old UI code. Fail loudly when npm run build produced different files.
if ! git diff --quiet -- web/dist; then
echo "web/dist is out of date; run 'cd web && npm run build' and commit the result"
git --no-pager diff --stat -- web/dist
exit 1
fi
- name: Build (verify embed)
run: CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o gitli .
- name: Cross-compile check (linux/arm64)
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o /dev/null .
- name: Verify static
run: |
file gitli
if ldd gitli 2>&1 | grep -q "not a dynamic executable\|statically linked\|不是动态可执行文件"; then
echo "static OK"
else
echo "binary is dynamic"; exit 1
fi
- name: golangci-lint
if: hashFiles('.golangci.yml') != ''
uses: golangci/golangci-lint-action@v7
with:
version: v2.14.0