optimize: Dramatically improve CI caching performance and validation
Summary
This MR dramatically optimizes GitLab CI performance by implementing single dependency installation with artifact sharing and registry-based Docker caching. These changes should reduce CI execution time from 9+ minutes (cache operations alone) to under 2 minutes.
Key Performance Improvements
- Added
.pre
stage withinstall:dependencies
job that runsnpm ci
once - All subsequent jobs use artifacts from this single installation
-
Eliminates 14+ redundant
npm ci
executions across validation, build, test, and security jobs - Uses
needs
dependency relationships for proper job orchestration
- Replaced local filesystem caching with registry-based cache optimization
- Uses
--cache-from/--cache-to type=registry
for better cache sharing across runners - Implements cache fallback keys for improved cache hit rates
- Fixed all
dependencies
vsneeds
validation errors - Resolved duplicate
needs
declarations - Complete YAML now passes GitLab's strict validation
Performance Analysis
Before (Current State):
-
⏱️ 4:12 cache restore + 5:00 cache save = 9+ minutes on caching alone -
🔄 14+ separatenpm ci
executions across all jobs -
💾 Local Docker cache with limited sharing between runners
After (This MR):
-
⚡ Singlenpm ci
in.pre
stage (~60-90 seconds) -
📦 Artifact sharing eliminates redundant dependency installations -
🌐 Registry-based caching with better hit rates - Expected total time savings: 7-8 minutes per pipeline
Validation Results
install:dependencies
needs
relationships for parallel execution
Technical Implementation
-
New
.pre
stage: Singleinstall:dependencies
job with 1-hour artifact retention -
Updated all jobs: Use
needs: [install:dependencies]
instead of individualnpm ci
-
Registry caching: Docker buildx with
type=registry
cache optimization - Proper job dependencies: Fixed all cross-stage references per GitLab requirements
Testing Strategy
-
GitLab CI YAML validation passes -
All pre-push checks pass (formatting, linting, type checking, build) -
Pipeline execution verification after merge -
Performance measurement against baseline
This optimization maintains all existing functionality while dramatically improving CI efficiency and reducing resource consumption.