-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (139 loc) · 4.39 KB
/
ci.yml
File metadata and controls
168 lines (139 loc) · 4.39 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
GO_VERSION: '1.23.4'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
- name: Run golangci-lint
run: golangci-lint run ./...
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go: ['1.22', '1.23.4']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.go == env.GO_VERSION
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
fail_ci_if_error: false
build-sharedlib:
name: Build Shared Libraries
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-amd64
output: signer-amd64.so
- os: macos-latest
target: darwin-arm64
output: signer-arm64.dylib
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Vendor dependencies
run: |
go mod download
go mod vendor
- name: Build shared library
run: |
mkdir -p build
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
else
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
fi
- name: Verify shared library
run: |
ls -la build/
file build/${{ matrix.output }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sharedlib-${{ matrix.target }}
path: build/${{ matrix.output }}
e2e-test:
name: End-to-End Test
needs: build-sharedlib
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Download Linux shared library
uses: actions/download-artifact@v4
with:
name: sharedlib-linux-amd64
path: build/
- name: Run E2E tests
run: |
chmod +x scripts/e2e-test.sh
./scripts/e2e-test.sh
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run gosec
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec -fmt=json -out=security-report.json ./... || true
- name: Upload security report
uses: actions/upload-artifact@v4
with:
name: security-report
path: security-report.json
build-cross-platform:
name: Cross-Platform Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build for multiple platforms
run: |
make build-cross || echo "No main binary to build"
docker-build:
name: Docker Build Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Docker build
run: |
if [ -f Dockerfile ]; then
docker build -t tmpl:test .
else
echo "No Dockerfile found, skipping Docker build"
fi