CI/CD Pipeline Fix Guide
🔧 CI/CD Pipeline Fix Guide
Section titled “🔧 CI/CD Pipeline Fix Guide”🎯 Root Cause: Missing Git Metadata for Datadog Test Visibility
Section titled “🎯 Root Cause: Missing Git Metadata for Datadog Test Visibility”The CI/CD pipelines are failing to show test results in Datadog because Git metadata is missing from test runs. This prevents tests from appearing in the “Tests” tab in Datadog.
🔍 Problem Analysis
Section titled “🔍 Problem Analysis”Symptoms:
Section titled “Symptoms:”- ✅ Test runs appear in “Test Runs” tab
- ❌ No data appears in “Tests” tab
- ❌ Missing
git.repository_url,git.commit.sha,git.branchin test execution metadata
Root Causes:
Section titled “Root Causes:”- Missing Git Environment Variables: Required Datadog Git metadata not set
- CI Provider Detection Failure: GitHub Actions environment not properly detected
- Missing .git Folder Access: Git commands not available during test execution
✅ Solutions Implemented
Section titled “✅ Solutions Implemented”1. Added Git Metadata to CI Pipeline
Section titled “1. Added Git Metadata to CI Pipeline”Updated .github/workflows/ci.yml and .github/workflows/working-ci.yml with:
env: # Git metadata for Datadog Test Visibility DD_GIT_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }} DD_GIT_COMMIT_SHA: ${{ github.sha }} DD_GIT_BRANCH: ${{ github.ref_name }} DD_API_KEY: ${{ secrets.DD_API_KEY }} DD_APP_KEY: ${{ secrets.DD_APP_KEY }}2. Enhanced Environment Setup
Section titled “2. Enhanced Environment Setup”Added comprehensive Git metadata collection:
- name: Setup test environment run: | # Add Git metadata for Datadog Test Visibility echo "DD_GIT_REPOSITORY_URL=${{ github.server_url }}/${{ github.repository }}" >> .env.local echo "DD_GIT_COMMIT_SHA=${{ github.sha }}" >> .env.local echo "DD_GIT_BRANCH=${{ github.ref_name }}" >> .env.local echo "DD_GIT_COMMIT_MESSAGE=$(git log -1 --pretty=%B)" >> .env.local echo "DD_GIT_COMMIT_AUTHOR_NAME=$(git log -1 --pretty=%an)" >> .env.local echo "DD_GIT_COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=%ae)" >> .env.local echo "DD_GIT_COMMIT_AUTHOR_DATE=$(git log -1 --pretty=%aI)" >> .env.local echo "DD_GIT_COMMIT_COMMITTER_NAME=$(git log -1 --pretty=%cn)" >> .env.local echo "DD_GIT_COMMIT_COMMITTER_EMAIL=$(git log -1 --pretty=%ce)" >> .env.local echo "DD_GIT_COMMIT_COMMITTER_DATE=$(git log -1 --pretty=%cI)" >> .env.local3. Required Environment Variables
Section titled “3. Required Environment Variables”| Variable | Source | Description |
|---|---|---|
DD_GIT_REPOSITORY_URL | ${{ github.server_url }}/${{ github.repository }} | Repository URL |
DD_GIT_COMMIT_SHA | ${{ github.sha }} | Full commit hash |
DD_GIT_BRANCH | ${{ github.ref_name }} | Branch name |
DD_GIT_COMMIT_MESSAGE | $(git log -1 --pretty=%B) | Commit message |
DD_GIT_COMMIT_AUTHOR_NAME | $(git log -1 --pretty=%an) | Author name |
DD_GIT_COMMIT_AUTHOR_EMAIL | $(git log -1 --pretty=%ae) | Author email |
🚀 Next Steps
Section titled “🚀 Next Steps”Immediate Actions:
Section titled “Immediate Actions:”- Test the Updated Pipeline: Commit changes and trigger CI/CD
- Verify Datadog Integration: Check that tests appear in both “Test Runs” and “Tests” tabs
- Monitor Pipeline Success: Ensure Git metadata is properly collected
Pipeline Priorities:
Section titled “Pipeline Priorities:”- Start with Simple Pipeline: Use
working-ci.ymlfor basic functionality - Gradually Enable Features: Add integration tests once basic pipeline works
- Fix One Issue at a Time: Don’t try to solve all 23 workflow problems simultaneously
Expected Results:
Section titled “Expected Results:”- ✅ Tests appear in Datadog “Tests” tab
- ✅ Git metadata visible in test execution details
- ✅ Proper test result attribution to commits and branches
- ✅ Test trend analysis available in Datadog
🔧 Troubleshooting
Section titled “🔧 Troubleshooting”If Tests Still Don’t Appear:
Section titled “If Tests Still Don’t Appear:”-
Check Environment Variables:
Terminal window # In CI, verify these are set:echo "DD_GIT_REPOSITORY_URL: $DD_GIT_REPOSITORY_URL"echo "DD_GIT_COMMIT_SHA: $DD_GIT_COMMIT_SHA"echo "DD_GIT_BRANCH: $DD_GIT_BRANCH" -
Verify Git Access:
Terminal window # Ensure git commands work:git log -1 --pretty=%Hgit branch --show-current -
Check Datadog API Keys:
Terminal window # Verify secrets are available (don't log actual values):[ -n "$DD_API_KEY" ] && echo "DD_API_KEY is set" || echo "DD_API_KEY is missing"[ -n "$DD_APP_KEY" ] && echo "DD_APP_KEY is set" || echo "DD_APP_KEY is missing"
Manual Override (if needed):
Section titled “Manual Override (if needed):”If automatic detection fails, set manually:
env: DD_GIT_REPOSITORY_URL: "https://github.com/ryanmaclean/vibecode-webgui" DD_GIT_COMMIT_SHA: "${{ github.sha }}" DD_GIT_BRANCH: "${{ github.ref_name }}"📊 Success Metrics
Section titled “📊 Success Metrics”Before Fix:
Section titled “Before Fix:”- ❌ 100% pipeline failure rate
- ❌ No test visibility in Datadog
- ❌ Missing Git attribution
After Fix (Expected):
Section titled “After Fix (Expected):”- ✅ At least one working pipeline
- ✅ Tests visible in Datadog “Tests” tab
- ✅ Proper Git metadata attribution
- ✅ Test trend analysis available
This fix addresses the fundamental issue preventing CI/CD test visibility in Datadog. Once implemented, we can focus on fixing individual test failures with proper tracking and attribution.