11name : 💣 ClickBOM Tests
2- on : [push]
2+ on : [push, pull_request ]
33
44jobs :
5- test_clickbom_github :
6- name : 💣 ClickBOM Tests
5+ # Unit tests
6+ test_unit :
7+ name : 🧪 Unit Tests
78 runs-on : ubuntu-latest
9+
10+ steps :
11+ - name : 🧾 Checkout
12+ uses : actions/checkout@v5
13+
14+ - name : 🔧 Setup Go
15+ uses : actions/setup-go@v5
16+ with :
17+ go-version : ' 1.21'
18+ cache : true
19+
20+ - name : 📦 Download dependencies
21+ run : go mod download
22+
23+ - name : 🧪 Run unit tests
24+ run : go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
25+
26+ - name : 📊 Upload coverage to Codecov
27+ uses : codecov/codecov-action@v4
28+ with :
29+ files : ./coverage.out
30+ flags : unittests
31+ name : codecov-umbrella
32+
33+ # Integration tests
34+ test_integration :
35+ name : 🔗 Integration Tests
36+ runs-on : ubuntu-latest
37+
38+ services :
39+ # Mock S3 using LocalStack
40+ localstack :
41+ image : localstack/localstack:latest
42+ env :
43+ SERVICES : s3
44+ DEFAULT_REGION : us-east-1
45+ ports :
46+ - 4566:4566
47+ options : >-
48+ --health-cmd "awslocal s3 ls"
49+ --health-interval 10s
50+ --health-timeout 5s
51+ --health-retries 5
52+
53+ # Mock ClickHouse
54+ clickhouse :
55+ image : clickhouse/clickhouse-server:latest
56+ ports :
57+ - 8123:8123
58+ options : >-
59+ --health-cmd "wget --spider -q localhost:8123/ping"
60+ --health-interval 10s
61+ --health-timeout 5s
62+ --health-retries 5
63+
64+ steps :
65+ - name : 🧾 Checkout
66+ uses : actions/checkout@v5
67+
68+ - name : 🔧 Setup Go
69+ uses : actions/setup-go@v5
70+ with :
71+ go-version : ' 1.21'
72+ cache : true
73+
74+ - name : 📦 Install AWS CLI
75+ run : |
76+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
77+ unzip awscliv2.zip
78+ sudo ./aws/install
79+ rm -rf awscliv2.zip aws/
880
81+ - name : 📦 Install CycloneDX CLI
82+ run : |
83+ wget -O /tmp/cyclonedx "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.27.2/cyclonedx-linux-x64"
84+ sudo mv /tmp/cyclonedx /usr/local/bin/cyclonedx
85+ sudo chmod +x /usr/local/bin/cyclonedx
86+
87+ - name : ⚙️ Setup LocalStack S3
88+ run : |
89+ aws --endpoint-url=http://localhost:4566 s3 mb s3://test-bucket
90+ env :
91+ AWS_ACCESS_KEY_ID : test
92+ AWS_SECRET_ACCESS_KEY : test
93+ AWS_DEFAULT_REGION : us-east-1
94+
95+ - name : 🧪 Run integration tests
96+ run : go test -v -tags=integration ./test/integration/...
97+ env :
98+ AWS_ENDPOINT_URL : http://localhost:4566
99+ CLICKHOUSE_URL : http://localhost:8123
100+ AWS_ACCESS_KEY_ID : test
101+ AWS_SECRET_ACCESS_KEY : test
102+ AWS_DEFAULT_REGION : us-east-1
103+
104+ # Lint and format checks
105+ test_lint :
106+ name : 🔍 Lint & Format
107+ runs-on : ubuntu-latest
108+
109+ steps :
110+ - name : 🧾 Checkout
111+ uses : actions/checkout@v5
112+
113+ - name : 🔧 Setup Go
114+ uses : actions/setup-go@v5
115+ with :
116+ go-version : ' 1.21'
117+ cache : true
118+
119+ - name : 🔍 Run golangci-lint
120+ uses : golangci/golangci-lint-action@v4
121+ with :
122+ version : latest
123+ args : --timeout=5m
124+
125+ - name : 📝 Check formatting
126+ run : |
127+ if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
128+ echo "Code is not formatted. Run 'gofmt -s -w .'"
129+ gofmt -s -l .
130+ exit 1
131+ fi
132+
133+ - name : 🔒 Run gosec security scanner
134+ uses : securego/gosec@master
135+ with :
136+ args : ' -no-fail -fmt sarif -out results.sarif ./...'
137+
138+ - name : 📤 Upload SARIF file
139+ uses : github/codeql-action/upload-sarif@v3
140+ with :
141+ sarif_file : results.sarif
142+
143+ # Build tests
144+ test_build :
145+ name : 🏗️ Build Tests
146+ runs-on : ubuntu-latest
147+ strategy :
148+ matrix :
149+ goos : [linux, darwin, windows]
150+ goarch : [amd64, arm64]
151+ exclude :
152+ - goos : windows
153+ goarch : arm64
154+
155+ steps :
156+ - name : 🧾 Checkout
157+ uses : actions/checkout@v5
158+
159+ - name : 🔧 Setup Go
160+ uses : actions/setup-go@v5
161+ with :
162+ go-version : ' 1.21'
163+ cache : true
164+
165+ - name : 🏗️ Build for ${{ matrix.goos }}/${{ matrix.goarch }}
166+ run : |
167+ GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
168+ go build -v -o clickbom-${{ matrix.goos }}-${{ matrix.goarch }} \
169+ ./cmd/clickbom
170+
171+ - name : 📤 Upload artifacts
172+ uses : actions/upload-artifact@v4
173+ with :
174+ name : clickbom-${{ matrix.goos }}-${{ matrix.goarch }}
175+ path : clickbom-${{ matrix.goos }}-${{ matrix.goarch }}*
176+
177+ # Docker build test
178+ test_docker :
179+ name : 🐳 Docker Build
180+ runs-on : ubuntu-latest
181+
182+ steps :
183+ - name : 🧾 Checkout
184+ uses : actions/checkout@v5
185+
186+ - name : 🔧 Set up Docker Buildx
187+ uses : docker/setup-buildx-action@v3
188+
189+ - name : 🏗️ Build Docker image
190+ uses : docker/build-push-action@v5
191+ with :
192+ context : .
193+ push : false
194+ tags : clickbom:test
195+ cache-from : type=gha
196+ cache-to : type=gha,mode=max
197+ build-args : |
198+ VERSION=test
199+ BUILD_DATE=${{ github.event.head_commit.timestamp }}
200+ VCS_REF=${{ github.sha }}
201+
202+ - name : 🧪 Test Docker image
203+ run : |
204+ docker run --rm clickbom:test --version || true
205+ docker run --rm clickbom:test --help || true
206+
207+ # End-to-end tests with real GitHub API
208+ test_e2e :
209+ name : 🎯 E2E Tests
210+ runs-on : ubuntu-latest
211+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
212+
213+ steps :
214+ - name : 🧾 Checkout
215+ uses : actions/checkout@v5
216+
217+ - name : 🔧 Setup Go
218+ uses : actions/setup-go@v5
219+ with :
220+ go-version : ' 1.21'
221+ cache : true
222+
223+ - name : 🏗️ Build
224+ run : go build -v -o clickbom ./cmd/clickbom
225+
226+ - name : 📦 Install dependencies
227+ run : |
228+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
229+ unzip awscliv2.zip
230+ sudo ./aws/install
231+ wget -O /tmp/cyclonedx "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.27.2/cyclonedx-linux-x64"
232+ sudo mv /tmp/cyclonedx /usr/local/bin/cyclonedx
233+ sudo chmod +x /usr/local/bin/cyclonedx
234+
235+ - name : 🧪 Run E2E test with GitHub
236+ run : ./clickbom
237+ env :
238+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
239+ REPOSITORY : ${{ github.repository }}
240+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
241+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
242+ S3_BUCKET : ${{ secrets.TEST_S3_BUCKET }}
243+ S3_KEY : test-e2e-${{ github.sha }}.json
244+ SBOM_SOURCE : github
245+ SBOM_FORMAT : cyclonedx
246+
247+ # Benchmarks
248+ benchmark :
249+ name : ⚡ Benchmarks
250+ runs-on : ubuntu-latest
251+ if : github.event_name == 'push'
252+
253+ steps :
254+ - name : 🧾 Checkout
255+ uses : actions/checkout@v5
256+
257+ - name : 🔧 Setup Go
258+ uses : actions/setup-go@v5
259+ with :
260+ go-version : ' 1.21'
261+ cache : true
262+
263+ - name : ⚡ Run benchmarks
264+ run : go test -bench=. -benchmem -run=^$ ./... | tee benchmark.txt
265+
266+ - name : 📊 Store benchmark result
267+ uses : benchmark-action/github-action-benchmark@v1
268+ with :
269+ tool : ' go'
270+ output-file-path : benchmark.txt
271+ github-token : ${{ secrets.GITHUB_TOKEN }}
272+ auto-push : true
273+
274+ # Dependency vulnerability scan
275+ test_security :
276+ name : 🔒 Security Scan
277+ runs-on : ubuntu-latest
278+
9279 steps :
10280 - name : 🧾 Checkout
11281 uses : actions/checkout@v5
12282
13- - name : ⚙️ Setup BATS
14- run : ./setup-bats.sh
283+ - name : 🔧 Setup Go
284+ uses : actions/setup-go@v5
285+ with :
286+ go-version : ' 1.21'
287+ cache : true
15288
16- - name : 📋 Check Tests
17- run : ./run-tests.sh --setup
289+ - name : 🔍 Run Trivy vulnerability scanner
290+ uses : aquasecurity/trivy-action@master
291+ with :
292+ scan-type : ' fs'
293+ scan-ref : ' .'
294+ format : ' sarif'
295+ output : ' trivy-results.sarif'
18296
19- - name : 🧪 Run Simple Tests
20- run : ./run-tests.sh --simple
297+ - name : 📤 Upload Trivy results to GitHub Security
298+ uses : github/codeql-action/upload-sarif@v3
299+ with :
300+ sarif_file : ' trivy-results.sarif'
21301
22- - name : 🧪 Run Advanced Tests
23- run : ./run-tests.sh --advanced
302+ - name : 🔍 Run govulncheck
303+ run : |
304+ go install golang.org/x/vuln/cmd/govulncheck@latest
305+ govulncheck ./...
0 commit comments