Skip to content

Commit 1736028

Browse files
committed
Add GitLab CI/CD pipeline
Comprehensive pipeline with: - Multi-mode builds (default, debug, release) - Full test suite (unit, debug, release, asan, ubsan) - Static analysis (clang-tidy, cppcheck) - Coverage reporting - Artifact deployment - Release management with glab CLI - GitLab integration testing Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent ceb019b commit 1736028

1 file changed

Lines changed: 295 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
# GitLab CI/CD Pipeline for libbin
2+
# A comprehensive pipeline that builds, tests, analyzes, and deploys the library
3+
4+
stages:
5+
- build
6+
- test
7+
- analyze
8+
- coverage
9+
- deploy
10+
11+
variables:
12+
# Use clang as the primary compiler
13+
CC: "clang"
14+
# C standard
15+
CSTD: "c23"
16+
17+
# =============================================================================
18+
# Build Stage
19+
# =============================================================================
20+
21+
build:default:
22+
stage: build
23+
image: debian:bookworm
24+
before_script:
25+
- apt-get update -qq
26+
- apt-get install -y -qq build-essential clang llvm
27+
script:
28+
- make clean
29+
- make default
30+
artifacts:
31+
paths:
32+
- build/lib*.so
33+
- bin/
34+
expire_in: 1 hour
35+
name: "libbin-build-${CI_COMMIT_SHORT_SHA}"
36+
37+
build:debug:
38+
stage: build
39+
image: debian:bookworm
40+
before_script:
41+
- apt-get update -qq
42+
- apt-get install -y -qq build-essential clang llvm
43+
script:
44+
- make clean
45+
- make debug
46+
artifacts:
47+
paths:
48+
- build/lib*_debug.so
49+
expire_in: 1 hour
50+
name: "libbin-debug-${CI_COMMIT_SHORT_SHA}"
51+
52+
build:release:
53+
stage: build
54+
image: debian:bookworm
55+
before_script:
56+
- apt-get update -qq
57+
- apt-get install -y -qq build-essential clang llvm
58+
script:
59+
- make clean
60+
- make release
61+
artifacts:
62+
paths:
63+
- build/lib*_release.so
64+
expire_in: 1 hour
65+
name: "libbin-release-${CI_COMMIT_SHORT_SHA}"
66+
67+
# =============================================================================
68+
# Test Stage
69+
# =============================================================================
70+
71+
test:unit:
72+
stage: test
73+
image: debian:bookworm
74+
dependencies:
75+
- build:default
76+
before_script:
77+
- apt-get update -qq
78+
- apt-get install -y -qq build-essential clang llvm
79+
script:
80+
- make test
81+
artifacts:
82+
reports:
83+
junit: test_results.xml
84+
paths:
85+
- bin/bin_tests
86+
expire_in: 1 week
87+
name: "libbin-unit-tests-${CI_COMMIT_SHORT_SHA}"
88+
89+
test:debug:
90+
stage: test
91+
image: debian:bookworm
92+
dependencies:
93+
- build:debug
94+
before_script:
95+
- apt-get update -qq
96+
- apt-get install -y -qq build-essential clang llvm
97+
script:
98+
- make test-debug
99+
artifacts:
100+
paths:
101+
- bin/bin_tests_debug
102+
expire_in: 1 week
103+
104+
test:release:
105+
stage: test
106+
image: debian:bookworm
107+
dependencies:
108+
- build:release
109+
before_script:
110+
- apt-get update -qq
111+
- apt-get install -y -qq build-essential clang llvm
112+
script:
113+
- make test-release
114+
artifacts:
115+
paths:
116+
- bin/bin_tests_release
117+
expire_in: 1 week
118+
119+
test:asan:
120+
stage: test
121+
image: debian:bookworm
122+
dependencies:
123+
- build:default
124+
before_script:
125+
- apt-get update -qq
126+
- apt-get install -y -qq build-essential clang llvm
127+
script:
128+
- make clean
129+
- make test-asan
130+
allow_failure: true
131+
artifacts:
132+
paths:
133+
- bin/bin_tests_asan
134+
expire_in: 1 week
135+
136+
test:ubsan:
137+
stage: test
138+
image: debian:bookworm
139+
dependencies:
140+
- build:default
141+
before_script:
142+
- apt-get update -qq
143+
- apt-get install -y -qq build-essential clang llvm
144+
script:
145+
- make clean
146+
- make test-ubsan
147+
allow_failure: true
148+
artifacts:
149+
paths:
150+
- bin/bin_tests_ubsan
151+
expire_in: 1 week
152+
153+
# =============================================================================
154+
# Analysis Stage
155+
# =============================================================================
156+
157+
analyze:clang-tidy:
158+
stage: analyze
159+
image: debian:bookworm
160+
before_script:
161+
- apt-get update -qq
162+
- apt-get install -y -qq build-essential clang clang-tools llvm
163+
script:
164+
- make check-tidy
165+
allow_failure: true
166+
artifacts:
167+
reports:
168+
sast: sast-report.json
169+
expire_in: 1 week
170+
171+
analyze:cppcheck:
172+
stage: analyze
173+
image: debian:bookworm
174+
before_script:
175+
- apt-get update -qq
176+
- apt-get install -y -qq cppcheck clang
177+
script:
178+
- make check-cppcheck
179+
allow_failure: true
180+
artifacts:
181+
expire_in: 1 week
182+
183+
# =============================================================================
184+
# Coverage Stage
185+
# =============================================================================
186+
187+
coverage:generate:
188+
stage: coverage
189+
image: debian:bookworm
190+
dependencies:
191+
- build:default
192+
before_script:
193+
- apt-get update -qq
194+
- apt-get install -y -qq build-essential clang llvm llvm-tools
195+
script:
196+
- make clean
197+
- make test-coverage
198+
- make coverage
199+
coverage: '/Lines executed:(\d+\.\d+)%/'
200+
artifacts:
201+
reports:
202+
coverage_report:
203+
coverage_format: cobertura
204+
path: coverage_report.xml
205+
paths:
206+
- build/*.gcov
207+
- bin/bin_tests_coverage
208+
expire_in: 30 days
209+
name: "libbin-coverage-${CI_COMMIT_SHORT_SHA}"
210+
allow_failure: true
211+
212+
# =============================================================================
213+
# Deploy Stage
214+
# =============================================================================
215+
216+
deploy:artifacts:
217+
stage: deploy
218+
image: debian:bookworm
219+
dependencies:
220+
- build:default
221+
- build:debug
222+
- build:release
223+
before_script:
224+
- apt-get update -qq
225+
- apt-get install -y -qq curl
226+
script:
227+
- echo "Deploying artifacts to GitLab"
228+
- ls -lah build/
229+
- echo "Artifacts ready for distribution"
230+
artifacts:
231+
paths:
232+
- build/lib*.so
233+
name: "${CI_PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}"
234+
expire_in: 30 days
235+
only:
236+
- master
237+
- tags
238+
239+
deploy:release:
240+
stage: deploy
241+
image: debian:bookworm
242+
before_script:
243+
- apt-get update -qq
244+
- apt-get install -y -qq curl git
245+
# Install glab CLI
246+
- curl -L https://gitlab.com/gitlab-org/cli/-/releases/latest/downloads/glab_linux_amd64.tar.gz | tar xz -C /usr/local/bin/
247+
script:
248+
- echo "Preparing release with glab CLI"
249+
- glab --version
250+
- |
251+
if [ -n "$CI_COMMIT_TAG" ]; then
252+
echo "Creating release for tag: $CI_COMMIT_TAG"
253+
glab release create "$CI_COMMIT_TAG" \
254+
--title "Release $CI_COMMIT_TAG" \
255+
--description "Automated release build for libbin" \
256+
--milestone "$CI_COMMIT_TAG" || true
257+
fi
258+
only:
259+
- tags
260+
allow_failure: true
261+
262+
deploy:test-glab:
263+
stage: deploy
264+
image: debian:bookworm
265+
before_script:
266+
- apt-get update -qq
267+
- apt-get install -y -qq curl git
268+
# Install glab CLI
269+
- curl -L https://gitlab.com/gitlab-org/cli/-/releases/latest/downloads/glab_linux_amd64.tar.gz | tar xz -C /usr/local/bin/
270+
script:
271+
- echo "Testing glab CLI integration"
272+
- glab --version
273+
- glab config get host || echo "No glab configuration found (expected in non-interactive CI)"
274+
- echo "Pipeline details:"
275+
- glab api projects/get --path-expand id,name,web_url || true
276+
- echo "glab CLI is properly installed and available"
277+
allow_failure: false
278+
only:
279+
- master
280+
- tags
281+
282+
# =============================================================================
283+
# Workflow Configuration
284+
# =============================================================================
285+
286+
workflow:
287+
rules:
288+
# Run pipeline for merge requests
289+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
290+
# Run pipeline for commits to protected branches
291+
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_PROTECTED'
292+
# Run pipeline for tags
293+
- if: '$CI_COMMIT_TAG'
294+
# Run pipeline for commits to master
295+
- if: '$CI_COMMIT_BRANCH == "master"'

0 commit comments

Comments
 (0)