-
Notifications
You must be signed in to change notification settings - Fork 1k
113 lines (93 loc) · 2.46 KB
/
Copy pathci.yml
File metadata and controls
113 lines (93 loc) · 2.46 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
name: CI
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
env:
GO_VERSION: '1.20'
jobs:
test:
name: Test on Linux AMD64
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify dependencies
run: go mod verify
- name: Run vet
run: go vet ./...
- name: Run tests
run: make test
- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
# 多平台CLI编译
build-multi-platform:
name: Build CLI - ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
include:
- os: linux
arch: amd64
target: linux_amd64
- os: linux
arch: arm64
target: linux_arm64
- os: darwin
arch: amd64
target: darwin_amd64
- os: darwin
arch: arm64
target: darwin_arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install musl-gcc for static linking (Linux only)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build CLI for ${{ matrix.target }}
run: make ${{ matrix.target }} MODULES=cli
- name: Verify file format and structure
run: |
cd target/chaosblade-*-${{ matrix.target }}
# 校验文件格式
echo "Verifying file structure for ${{ matrix.target }}..."
ls -la
echo "Checking blade binary..."
file ./blade