|
| 1 | +# Universal Language Connector - GitLab CI/CD Pipeline |
| 2 | +# RSR-compliant continuous integration |
| 3 | + |
| 4 | +variables: |
| 5 | + RUST_VERSION: "1.75" |
| 6 | + CARGO_HOME: "${CI_PROJECT_DIR}/.cargo" |
| 7 | + RUST_LOG: "info" |
| 8 | + |
| 9 | +# Cache dependencies across jobs |
| 10 | +.cache_template: &cache_definition |
| 11 | + cache: |
| 12 | + key: "${CI_COMMIT_REF_SLUG}" |
| 13 | + paths: |
| 14 | + - server/target/ |
| 15 | + - ${CARGO_HOME} |
| 16 | + - clients/vscode/node_modules/ |
| 17 | + |
| 18 | +# Stages |
| 19 | +stages: |
| 20 | + - validate |
| 21 | + - build |
| 22 | + - test |
| 23 | + - security |
| 24 | + - deploy |
| 25 | + - release |
| 26 | + |
| 27 | +# Before script - install Rust |
| 28 | +.rust_template: &rust_install |
| 29 | + before_script: |
| 30 | + - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_VERSION} |
| 31 | + - source $HOME/.cargo/env |
| 32 | + - rustc --version |
| 33 | + - cargo --version |
| 34 | + |
| 35 | +# Validate RSR Compliance |
| 36 | +rsr-compliance: |
| 37 | + stage: validate |
| 38 | + image: alpine:latest |
| 39 | + script: |
| 40 | + - apk add --no-cache bash just |
| 41 | + - just validate-rsr |
| 42 | + allow_failure: false |
| 43 | + artifacts: |
| 44 | + reports: |
| 45 | + junit: rsr-compliance-report.xml |
| 46 | + expire_in: 1 week |
| 47 | + |
| 48 | +# Format check |
| 49 | +format: |
| 50 | + stage: validate |
| 51 | + image: rust:${RUST_VERSION} |
| 52 | + <<: *cache_definition |
| 53 | + <<: *rust_install |
| 54 | + script: |
| 55 | + - cd server |
| 56 | + - cargo fmt --check |
| 57 | + allow_failure: false |
| 58 | + |
| 59 | +# Linting |
| 60 | +clippy: |
| 61 | + stage: validate |
| 62 | + image: rust:${RUST_VERSION} |
| 63 | + <<: *cache_definition |
| 64 | + <<: *rust_install |
| 65 | + script: |
| 66 | + - cd server |
| 67 | + - rustup component add clippy |
| 68 | + - cargo clippy -- -D warnings |
| 69 | + allow_failure: false |
| 70 | + |
| 71 | +# Build debug |
| 72 | +build-debug: |
| 73 | + stage: build |
| 74 | + image: rust:${RUST_VERSION} |
| 75 | + <<: *cache_definition |
| 76 | + <<: *rust_install |
| 77 | + script: |
| 78 | + - cd server |
| 79 | + - cargo build |
| 80 | + artifacts: |
| 81 | + paths: |
| 82 | + - server/target/debug/universal-connector-server |
| 83 | + expire_in: 1 day |
| 84 | + |
| 85 | +# Build release |
| 86 | +build-release: |
| 87 | + stage: build |
| 88 | + image: rust:${RUST_VERSION} |
| 89 | + <<: *cache_definition |
| 90 | + <<: *rust_install |
| 91 | + script: |
| 92 | + - cd server |
| 93 | + - cargo build --release |
| 94 | + artifacts: |
| 95 | + paths: |
| 96 | + - server/target/release/universal-connector-server |
| 97 | + expire_in: 1 week |
| 98 | + only: |
| 99 | + - main |
| 100 | + - tags |
| 101 | + |
| 102 | +# Unit tests |
| 103 | +test-unit: |
| 104 | + stage: test |
| 105 | + image: rust:${RUST_VERSION} |
| 106 | + <<: *cache_definition |
| 107 | + <<: *rust_install |
| 108 | + dependencies: |
| 109 | + - build-debug |
| 110 | + script: |
| 111 | + - cd server |
| 112 | + - cargo test --lib -- --test-threads=1 |
| 113 | + artifacts: |
| 114 | + reports: |
| 115 | + junit: server/target/junit.xml |
| 116 | + expire_in: 1 week |
| 117 | + |
| 118 | +# Integration tests |
| 119 | +test-integration: |
| 120 | + stage: test |
| 121 | + image: rust:${RUST_VERSION} |
| 122 | + <<: *cache_definition |
| 123 | + <<: *rust_install |
| 124 | + dependencies: |
| 125 | + - build-debug |
| 126 | + script: |
| 127 | + - cd server |
| 128 | + - cargo test --test '*' -- --test-threads=1 |
| 129 | + allow_failure: true # Integration tests may require external services |
| 130 | + |
| 131 | +# Code coverage |
| 132 | +coverage: |
| 133 | + stage: test |
| 134 | + image: rust:${RUST_VERSION} |
| 135 | + <<: *cache_definition |
| 136 | + <<: *rust_install |
| 137 | + script: |
| 138 | + - cargo install cargo-tarpaulin || true |
| 139 | + - cd server |
| 140 | + - cargo tarpaulin --out Xml --output-dir coverage |
| 141 | + coverage: '/\d+\.\d+% coverage/' |
| 142 | + artifacts: |
| 143 | + reports: |
| 144 | + coverage_report: |
| 145 | + coverage_format: cobertura |
| 146 | + path: server/coverage/cobertura.xml |
| 147 | + paths: |
| 148 | + - server/coverage/ |
| 149 | + expire_in: 1 week |
| 150 | + only: |
| 151 | + - main |
| 152 | + |
| 153 | +# Security audit |
| 154 | +security-audit: |
| 155 | + stage: security |
| 156 | + image: rust:${RUST_VERSION} |
| 157 | + <<: *rust_install |
| 158 | + script: |
| 159 | + - cargo install cargo-audit || true |
| 160 | + - cd server |
| 161 | + - cargo audit --deny warnings |
| 162 | + allow_failure: true # Don't block on advisories initially |
| 163 | + only: |
| 164 | + - main |
| 165 | + - merge_requests |
| 166 | + |
| 167 | +# Dependency check |
| 168 | +dependency-check: |
| 169 | + stage: security |
| 170 | + image: rust:${RUST_VERSION} |
| 171 | + <<: *rust_install |
| 172 | + script: |
| 173 | + - cargo install cargo-outdated || true |
| 174 | + - cd server |
| 175 | + - cargo outdated --exit-code 1 |
| 176 | + allow_failure: true |
| 177 | + only: |
| 178 | + - schedules |
| 179 | + |
| 180 | +# SAST (Static Application Security Testing) |
| 181 | +sast: |
| 182 | + stage: security |
| 183 | + image: rust:${RUST_VERSION} |
| 184 | + script: |
| 185 | + - echo "SAST scanning with cargo-geiger or similar" |
| 186 | + - cargo install cargo-geiger || true |
| 187 | + - cd server |
| 188 | + - cargo geiger || true |
| 189 | + allow_failure: true |
| 190 | + |
| 191 | +# Build Docker image |
| 192 | +docker-build: |
| 193 | + stage: deploy |
| 194 | + image: docker:latest |
| 195 | + services: |
| 196 | + - docker:dind |
| 197 | + script: |
| 198 | + - docker build -f deployment/Dockerfile -t universal-connector:${CI_COMMIT_SHORT_SHA} . |
| 199 | + - docker tag universal-connector:${CI_COMMIT_SHORT_SHA} universal-connector:latest |
| 200 | + only: |
| 201 | + - main |
| 202 | + - tags |
| 203 | + artifacts: |
| 204 | + paths: |
| 205 | + - universal-connector.tar |
| 206 | + expire_in: 1 week |
| 207 | + |
| 208 | +# VS Code client build |
| 209 | +vscode-client: |
| 210 | + stage: build |
| 211 | + image: node:20 |
| 212 | + script: |
| 213 | + - cd clients/vscode |
| 214 | + - npm ci |
| 215 | + - npm run compile |
| 216 | + artifacts: |
| 217 | + paths: |
| 218 | + - clients/vscode/out/ |
| 219 | + expire_in: 1 day |
| 220 | + cache: |
| 221 | + key: vscode-deps |
| 222 | + paths: |
| 223 | + - clients/vscode/node_modules/ |
| 224 | + |
| 225 | +# Documentation |
| 226 | +docs: |
| 227 | + stage: build |
| 228 | + image: rust:${RUST_VERSION} |
| 229 | + <<: *rust_install |
| 230 | + script: |
| 231 | + - cd server |
| 232 | + - cargo doc --no-deps |
| 233 | + artifacts: |
| 234 | + paths: |
| 235 | + - server/target/doc/ |
| 236 | + expire_in: 1 week |
| 237 | + only: |
| 238 | + - main |
| 239 | + |
| 240 | +# Release binary (on tags) |
| 241 | +release-binary: |
| 242 | + stage: release |
| 243 | + image: rust:${RUST_VERSION} |
| 244 | + <<: *cache_definition |
| 245 | + <<: *rust_install |
| 246 | + script: |
| 247 | + - cd server |
| 248 | + - cargo build --release |
| 249 | + - strip target/release/universal-connector-server |
| 250 | + - tar czf universal-connector-${CI_COMMIT_TAG}-x86_64-linux.tar.gz -C target/release universal-connector-server |
| 251 | + artifacts: |
| 252 | + paths: |
| 253 | + - server/universal-connector-*.tar.gz |
| 254 | + expire_in: never |
| 255 | + only: |
| 256 | + - tags |
| 257 | + except: |
| 258 | + - branches |
| 259 | + |
| 260 | +# Deploy to staging |
| 261 | +deploy-staging: |
| 262 | + stage: deploy |
| 263 | + image: alpine:latest |
| 264 | + script: |
| 265 | + - echo "Deploy to staging environment" |
| 266 | + - echo "Example: scp binary to staging server" |
| 267 | + environment: |
| 268 | + name: staging |
| 269 | + url: https://staging.universal-connector.org |
| 270 | + only: |
| 271 | + - main |
| 272 | + when: manual |
| 273 | + |
| 274 | +# Deploy to production |
| 275 | +deploy-production: |
| 276 | + stage: deploy |
| 277 | + image: alpine:latest |
| 278 | + script: |
| 279 | + - echo "Deploy to production environment" |
| 280 | + - echo "Example: scp binary to production server" |
| 281 | + environment: |
| 282 | + name: production |
| 283 | + url: https://universal-connector.org |
| 284 | + only: |
| 285 | + - tags |
| 286 | + when: manual |
| 287 | + |
| 288 | +# Nightly builds |
| 289 | +nightly: |
| 290 | + stage: build |
| 291 | + image: rust:${RUST_VERSION} |
| 292 | + <<: *cache_definition |
| 293 | + <<: *rust_install |
| 294 | + script: |
| 295 | + - cd server |
| 296 | + - cargo build --release |
| 297 | + only: |
| 298 | + - schedules |
| 299 | + artifacts: |
| 300 | + paths: |
| 301 | + - server/target/release/universal-connector-server |
| 302 | + expire_in: 7 days |
| 303 | + |
| 304 | +# Performance benchmarks |
| 305 | +benchmarks: |
| 306 | + stage: test |
| 307 | + image: rust:${RUST_VERSION} |
| 308 | + <<: *cache_definition |
| 309 | + <<: *rust_install |
| 310 | + script: |
| 311 | + - echo "Benchmarks not yet implemented" |
| 312 | + - echo "To add: uncomment criterion in Cargo.toml and implement benches/" |
| 313 | + allow_failure: true |
| 314 | + only: |
| 315 | + - main |
| 316 | + |
| 317 | +# License compliance check |
| 318 | +license-check: |
| 319 | + stage: validate |
| 320 | + image: rust:${RUST_VERSION} |
| 321 | + <<: *rust_install |
| 322 | + script: |
| 323 | + - cargo install cargo-license || true |
| 324 | + - cd server |
| 325 | + - cargo license --json |
| 326 | + allow_failure: true |
| 327 | + |
| 328 | +# Check all clients compile |
| 329 | +clients-check: |
| 330 | + stage: validate |
| 331 | + image: alpine:latest |
| 332 | + script: |
| 333 | + - apk add --no-cache bash |
| 334 | + - echo "Checking client LOC constraints..." |
| 335 | + - test $(wc -l < clients/vscode/extension.ts) -lt 100 || (echo "VS Code client exceeds 100 LOC" && exit 1) |
| 336 | + - test $(wc -l < clients/neovim/init.lua) -lt 100 || (echo "Neovim client exceeds 100 LOC" && exit 1) |
| 337 | + - test $(wc -l < clients/emacs/universal-connector.el) -lt 100 || (echo "Emacs client exceeds 100 LOC" && exit 1) |
| 338 | + - echo "✅ All clients meet <100 LOC constraint" |
| 339 | + allow_failure: false |
| 340 | + |
| 341 | +# Merge request pipeline |
| 342 | +include: |
| 343 | + - template: Security/SAST.gitlab-ci.yml |
| 344 | + - template: Security/Dependency-Scanning.gitlab-ci.yml |
| 345 | + - template: Security/License-Scanning.gitlab-ci.yml |
0 commit comments