-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (77 loc) · 2.06 KB
/
Copy pathci.yml
File metadata and controls
89 lines (77 loc) · 2.06 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: 安装 mise 工具链
uses: jdx/mise-action@v2
with:
experimental: true
cache: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 校验 go.mod
shell: bash
run: |
mise exec -- go mod download
mise exec -- go mod tidy
changed=$(git status --porcelain -- go.mod go.sum)
if [ -n "$changed" ]; then
echo "go.mod / go.sum 存在未提交的变更:"
echo "$changed"
git --no-pager diff -- go.mod go.sum || true
exit 1
fi
- name: 单元测试
shell: bash
run: mise run test
- name: Lint
if: runner.os == 'Linux'
shell: bash
run: mise run lint
- name: 上传覆盖率
if: runner.os == 'Linux'
uses: actions/upload-artifact@v5
with:
name: coverage
path: coverage.out
if-no-files-found: ignore
build-matrix:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: 交叉编译
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
ext=""
if [ "$GOOS" = "windows" ]; then ext=".exe"; fi
go build -trimpath -ldflags="-s -w" -o "bin/stdagent-${GOOS}-${GOARCH}${ext}" ./cmd/stdagent