1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ env :
10+ GO_VERSION : ' 1.23.4'
11+
12+ jobs :
13+ lint :
14+ name : Lint
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - uses : actions/setup-go@v5
20+ with :
21+ go-version : ${{ env.GO_VERSION }}
22+
23+ - name : Install golangci-lint
24+ run : |
25+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
26+
27+ - name : Run golangci-lint
28+ run : golangci-lint run ./...
29+
30+ test :
31+ name : Test
32+ strategy :
33+ matrix :
34+ os : [ubuntu-latest, macos-latest]
35+ go : ['1.22', '1.23.4']
36+ runs-on : ${{ matrix.os }}
37+ steps :
38+ - uses : actions/checkout@v4
39+
40+ - uses : actions/setup-go@v5
41+ with :
42+ go-version : ${{ matrix.go }}
43+
44+ - name : Run tests
45+ run : |
46+ go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
47+
48+ - name : Upload coverage
49+ if : matrix.os == 'ubuntu-latest' && matrix.go == env.GO_VERSION
50+ uses : codecov/codecov-action@v4
51+ with :
52+ file : ./coverage.out
53+ fail_ci_if_error : false
54+
55+ build-sharedlib :
56+ name : Build Shared Libraries
57+ strategy :
58+ matrix :
59+ include :
60+ - os : ubuntu-latest
61+ target : linux-amd64
62+ output : signer-amd64.so
63+ - os : macos-latest
64+ target : darwin-arm64
65+ output : signer-arm64.dylib
66+ runs-on : ${{ matrix.os }}
67+ steps :
68+ - uses : actions/checkout@v4
69+
70+ - uses : actions/setup-go@v5
71+ with :
72+ go-version : ${{ env.GO_VERSION }}
73+
74+ - name : Vendor dependencies
75+ run : |
76+ go mod download
77+ go mod vendor
78+
79+ - name : Build shared library
80+ run : |
81+ mkdir -p build
82+ if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
83+ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
84+ else
85+ CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
86+ fi
87+
88+ - name : Verify shared library
89+ run : |
90+ ls -la build/
91+ file build/${{ matrix.output }}
92+
93+ - name : Upload artifact
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : sharedlib-${{ matrix.target }}
97+ path : build/${{ matrix.output }}
98+
99+ e2e-test :
100+ name : End-to-End Test
101+ needs : build-sharedlib
102+ runs-on : ubuntu-latest
103+ steps :
104+ - uses : actions/checkout@v4
105+
106+ - uses : actions/setup-go@v5
107+ with :
108+ go-version : ${{ env.GO_VERSION }}
109+
110+ - name : Download Linux shared library
111+ uses : actions/download-artifact@v4
112+ with :
113+ name : sharedlib-linux-amd64
114+ path : build/
115+
116+ - name : Run E2E tests
117+ run : |
118+ chmod +x scripts/e2e-test.sh
119+ ./scripts/e2e-test.sh
120+
121+ security-scan :
122+ name : Security Scan
123+ runs-on : ubuntu-latest
124+ steps :
125+ - uses : actions/checkout@v4
126+
127+ - uses : actions/setup-go@v5
128+ with :
129+ go-version : ${{ env.GO_VERSION }}
130+
131+ - name : Run gosec
132+ run : |
133+ go install github.com/securego/gosec/v2/cmd/gosec@latest
134+ gosec -fmt=json -out=security-report.json ./... || true
135+
136+ - name : Upload security report
137+ uses : actions/upload-artifact@v4
138+ with :
139+ name : security-report
140+ path : security-report.json
141+
142+ build-cross-platform :
143+ name : Cross-Platform Build
144+ runs-on : ubuntu-latest
145+ steps :
146+ - uses : actions/checkout@v4
147+
148+ - uses : actions/setup-go@v5
149+ with :
150+ go-version : ${{ env.GO_VERSION }}
151+
152+ - name : Build for multiple platforms
153+ run : |
154+ make build-cross || echo "No main binary to build"
155+
156+ docker-build :
157+ name : Docker Build Test
158+ runs-on : ubuntu-latest
159+ steps :
160+ - uses : actions/checkout@v4
161+
162+ - name : Test Docker build
163+ run : |
164+ if [ -f Dockerfile ]; then
165+ docker build -t tmpl:test .
166+ else
167+ echo "No Dockerfile found, skipping Docker build"
168+ fi
0 commit comments