306 lines
9.2 KiB
YAML
306 lines
9.2 KiB
YAML
stages:
|
|
- pre
|
|
- build
|
|
- test
|
|
- science
|
|
- validate
|
|
- document
|
|
- report
|
|
|
|
default:
|
|
tags:
|
|
- build
|
|
|
|
variables:
|
|
UNSANDBOX_API_KEY: $UNSANDBOX_API_KEY
|
|
UNSANDBOX_PUBLIC_KEY: $UNSANDBOX_PUBLIC_KEY
|
|
UNSANDBOX_SECRET_KEY: $UNSANDBOX_SECRET_KEY
|
|
|
|
# ============================================================================
|
|
# STAGE 1: Detect Changes
|
|
# ============================================================================
|
|
detect-changes:
|
|
stage: pre
|
|
script:
|
|
- bash scripts/detect-changes.sh > changes.json
|
|
- cat changes.json
|
|
artifacts:
|
|
paths:
|
|
- changes.json
|
|
expire_in: 1 hour
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 2: Generate Dynamic Matrix
|
|
# ============================================================================
|
|
generate-matrix:
|
|
stage: pre
|
|
needs:
|
|
- detect-changes
|
|
script:
|
|
- bash scripts/generate-matrix.sh
|
|
artifacts:
|
|
paths:
|
|
- test-matrix.yml
|
|
expire_in: 1 hour
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 3: Build SDKs (only changed ones)
|
|
# ============================================================================
|
|
build:
|
|
stage: build
|
|
script:
|
|
- bash scripts/build-clients.sh
|
|
- |
|
|
# Build C examples
|
|
if [ -d "clients/c" ] && [ -f "clients/c/Makefile" ]; then
|
|
echo "Building C examples..."
|
|
make -C clients/c compile-examples || true
|
|
fi
|
|
artifacts:
|
|
paths:
|
|
- build/
|
|
- clients/c/examples/*.o
|
|
expire_in: 1 hour
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 4: Test Matrix (child pipeline trigger)
|
|
# ============================================================================
|
|
trigger-test-matrix:
|
|
stage: test
|
|
needs:
|
|
- generate-matrix
|
|
- build
|
|
trigger:
|
|
include:
|
|
- artifact: test-matrix.yml
|
|
job: generate-matrix
|
|
strategy: depend
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 5: Science Jobs (Pool Burning)
|
|
# ============================================================================
|
|
science-validate-examples:
|
|
stage: science
|
|
needs:
|
|
- build
|
|
script:
|
|
- bash scripts/validate-examples.sh
|
|
artifacts:
|
|
reports:
|
|
junit: science-results.xml
|
|
paths:
|
|
- science-results/
|
|
expire_in: 30 days
|
|
allow_failure: true
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
science-lint-sdks:
|
|
stage: science
|
|
script:
|
|
- bash scripts/science/lint-all-sdks.sh
|
|
artifacts:
|
|
reports:
|
|
junit: lint-results.xml
|
|
paths:
|
|
- lint-results/
|
|
expire_in: 30 days
|
|
allow_failure: true
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
science-benchmark-clients:
|
|
stage: science
|
|
script:
|
|
- bash scripts/science/benchmark-clients.sh
|
|
artifacts:
|
|
reports:
|
|
junit: benchmark-results.xml
|
|
paths:
|
|
- benchmark-results/
|
|
expire_in: 30 days
|
|
allow_failure: true
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 6: Validate Examples (from science job artifacts)
|
|
# ============================================================================
|
|
validate-examples:
|
|
stage: validate
|
|
needs:
|
|
- science-validate-examples
|
|
script:
|
|
- mkdir -p science-results
|
|
- |
|
|
if [ -f science-results/examples-validation-results.json ]; then
|
|
echo "Example validation results found"
|
|
cat science-results/examples-validation-results.json
|
|
|
|
# Extract stats and display summary
|
|
TOTAL=$(jq '.summary.total_examples' science-results/examples-validation-results.json 2>/dev/null || echo "0")
|
|
PASSED=$(jq '.summary.total_validated' science-results/examples-validation-results.json 2>/dev/null || echo "0")
|
|
FAILED=$(jq '.summary.total_failed' science-results/examples-validation-results.json 2>/dev/null || echo "0")
|
|
|
|
echo ""
|
|
echo "Summary: $PASSED/$TOTAL passed, $FAILED failed"
|
|
else
|
|
echo "No example validation results found"
|
|
fi
|
|
artifacts:
|
|
paths:
|
|
- science-results/
|
|
expire_in: 30 days
|
|
allow_failure: true
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 7: Generate Documentation
|
|
# ============================================================================
|
|
generate-documentation:
|
|
stage: document
|
|
needs:
|
|
- validate-examples
|
|
script:
|
|
- mkdir -p docs
|
|
- bash scripts/generate-docs.sh || true
|
|
- |
|
|
VALIDATION_TIME=$(date +%s)
|
|
CURRENT_TIME=$(date +%s)
|
|
MINUTES_AGO=$((($CURRENT_TIME - $VALIDATION_TIME) / 60))
|
|
echo "Last verified: $MINUTES_AGO minutes ago" > docs/VERIFICATION_TIMESTAMP.txt
|
|
echo "Generated: $(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> docs/VERIFICATION_TIMESTAMP.txt
|
|
- ls -la docs/ || echo "No documentation generated"
|
|
artifacts:
|
|
paths:
|
|
- docs/
|
|
- docs/VERIFICATION_TIMESTAMP.txt
|
|
expire_in: 30 days
|
|
allow_failure: true
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 8: Report
|
|
# ============================================================================
|
|
report:
|
|
stage: report
|
|
needs:
|
|
- generate-documentation
|
|
script:
|
|
- bash scripts/filter-results.sh
|
|
- |
|
|
if [ -f science-results/examples-validation-results.json ]; then
|
|
echo "Including example validation stats in final report..."
|
|
EXAMPLE_STATS=$(cat science-results/examples-validation-results.json)
|
|
jq --argjson examples "$EXAMPLE_STATS" '.properties += [{name: "example_validation_passed", value: $examples.examples.passed | tostring}, {name: "example_validation_failed", value: $examples.examples.failed | tostring}]' final-report.xml > final-report.xml.tmp && mv final-report.xml.tmp final-report.xml || true
|
|
fi
|
|
- echo "Including documentation generation artifacts..."
|
|
- ls -la docs/ 2>/dev/null | tail -5 || echo "No documentation available"
|
|
artifacts:
|
|
reports:
|
|
junit: final-report.xml
|
|
paths:
|
|
- reports/
|
|
- science-results/examples-validation-results.json
|
|
- docs/
|
|
- final-report.xml
|
|
expire_in: 30 days
|
|
only:
|
|
- main
|
|
- /^\d+\.\d+\.\d+$/
|
|
|
|
# ============================================================================
|
|
# STAGE 9: Performance Report (Tags Only)
|
|
# ============================================================================
|
|
perf-report:
|
|
stage: report
|
|
needs:
|
|
- trigger-test-matrix
|
|
variables:
|
|
GIT_STRATEGY: clone
|
|
GIT_DEPTH: 0
|
|
script:
|
|
- echo "========================================"
|
|
- echo "Performance Report Generator"
|
|
- echo "Tag: $CI_COMMIT_TAG"
|
|
- echo "========================================"
|
|
- |
|
|
# Validate tag format
|
|
if ! echo "$CI_COMMIT_TAG" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
echo "ERROR: Invalid tag format: $CI_COMMIT_TAG"
|
|
exit 1
|
|
fi
|
|
- |
|
|
# Generate performance report (fetches CI timing data)
|
|
echo "Step 1: Generating performance report..."
|
|
bash scripts/generate-perf-report.sh "$CI_COMMIT_TAG" || {
|
|
echo "WARN: Report generation failed, continuing..."
|
|
}
|
|
- |
|
|
# Generate charts via unsandbox (optional - may fail without API keys)
|
|
echo "Step 2: Generating performance charts..."
|
|
if [ -f "reports/$CI_COMMIT_TAG/perf.json" ]; then
|
|
build/un -a -f "reports/$CI_COMMIT_TAG/perf.json" scripts/generate-perf-charts.py && \
|
|
mv -f *.png "reports/$CI_COMMIT_TAG/" 2>/dev/null || \
|
|
echo "WARN: Chart generation skipped (unsandbox unavailable)"
|
|
else
|
|
echo "WARN: No perf.json found, skipping charts"
|
|
fi
|
|
- |
|
|
# Show what was generated
|
|
echo "Step 3: Report contents..."
|
|
ls -la "reports/$CI_COMMIT_TAG/" 2>/dev/null || echo "No report directory"
|
|
- |
|
|
# Commit back to main (requires deploy key with write access)
|
|
echo "Step 4: Committing to main..."
|
|
if [ -d "reports/$CI_COMMIT_TAG" ]; then
|
|
# Setup SSH deploy key if available
|
|
if [ -n "$DEPLOY_KEY" ]; then
|
|
mkdir -p ~/.ssh
|
|
echo "$DEPLOY_KEY" | base64 -d > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan -H git.unturf.com >> ~/.ssh/known_hosts 2>/dev/null
|
|
git remote set-url origin "ssh://git@git.unturf.com:2222/${CI_PROJECT_PATH}.git"
|
|
fi
|
|
|
|
git config user.email "ci@unturf.com"
|
|
git config user.name "GitLab CI"
|
|
git fetch origin main
|
|
git checkout main
|
|
git pull origin main --rebase
|
|
git add reports/
|
|
git diff --cached --quiet || {
|
|
git commit -m "perf: Add performance report for $CI_COMMIT_TAG [ci skip]"
|
|
git push origin main && echo "SUCCESS: Report committed to main" || \
|
|
echo "WARN: Push failed - add DEPLOY_KEY variable (base64 encoded SSH private key)"
|
|
}
|
|
else
|
|
echo "WARN: No report to commit"
|
|
fi
|
|
artifacts:
|
|
paths:
|
|
- reports/
|
|
expire_in: 90 days
|
|
when: always
|
|
rules:
|
|
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
|
|
allow_failure: true
|