refactor(ci): improve CI workflow health checks and New Relic verific… #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI with Doppler & New Relic | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r app/requirements.txt | |
| - name: Install Doppler CLI | |
| uses: dopplerhq/cli-action@v3 | |
| - name: Verify Doppler connection | |
| run: doppler secrets --project infra-pipeline-poa --config dev --only-names | |
| env: | |
| DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} | |
| - name: Start Flask app with Doppler | |
| run: | | |
| doppler run --project infra-pipeline-poa --config dev --command="python app/app.py" & | |
| APP_PID=$! | |
| echo "APP_PID=$APP_PID" >> $GITHUB_ENV | |
| # Wait for app to be ready (max 30 seconds) | |
| echo "⏳ Waiting for app to start..." | |
| for i in {1..30}; do | |
| if curl -sf http://localhost:5000/health > /dev/null 2>&1; then | |
| echo "✅ App is ready!" | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| env: | |
| DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} | |
| - name: Health check | |
| run: | | |
| response=$(curl -sf http://localhost:5000/health) | |
| echo "Health check response: $response" | |
| if echo "$response" | grep -q '"status":"ok"' || echo "$response" | grep -q '"status": "ok"'; then | |
| echo "✅ Health check passed" | |
| else | |
| echo "❌ Health check failed" | |
| exit 1 | |
| fi | |
| - name: Test main endpoint | |
| run: | | |
| response=$(curl -s http://localhost:5000) | |
| echo "App response: $response" | |
| if echo "$response" | grep -q '"status":"healthy"' || echo "$response" | grep -q '"status": "healthy"'; then | |
| echo "✅ App is working correctly" | |
| else | |
| echo "❌ App response unexpected" | |
| exit 1 | |
| fi | |
| - name: Verify New Relic integration | |
| run: | | |
| # Check if New Relic is initialized in the app logs or via /health endpoint | |
| if doppler secrets get NEW_RELIC_LICENSE_KEY --project infra-pipeline-poa --config dev --plain > /dev/null 2>&1; then | |
| echo "✅ New Relic credentials configured in Doppler" | |
| else | |
| echo "⚠️ New Relic credentials not found in Doppler" | |
| fi | |
| env: | |
| DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} | |
| - name: Stop Flask app | |
| if: always() | |
| run: | | |
| if [ ! -z "$APP_PID" ]; then | |
| kill $APP_PID || true | |
| fi | |
| lsof -ti:5000 | xargs kill -9 || true |