From 90af21ac8bcd34c6f410ee2b20f5e4f9e193f2f8 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 1 Jul 2025 16:11:35 -0700 Subject: [PATCH] fix: reorganize pipeline to run smoke tests AFTER deployments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change smoke tests to trigger after deployments complete (not on push) - Auto-promotion now depends on smoke test success (not duplicate testing) - Promotion to production depends on staging smoke tests - Eliminates testing previous deployments instead of new ones - Creates logical flow: deploy โ†’ test โ†’ promote --- .github/workflows/auto-promote.yml | 60 +++------------------ .github/workflows/promote-to-production.yml | 60 +++------------------ .github/workflows/smoke-test.yml | 9 ++-- 3 files changed, 19 insertions(+), 110 deletions(-) diff --git a/.github/workflows/auto-promote.yml b/.github/workflows/auto-promote.yml index 971b37c..cfea21a 100644 --- a/.github/workflows/auto-promote.yml +++ b/.github/workflows/auto-promote.yml @@ -2,7 +2,7 @@ name: Auto-Promote Pipeline on: workflow_run: - workflows: ["Deploy to Development"] + workflows: ["Smoke Tests"] types: - completed branches: [ develop ] @@ -24,67 +24,21 @@ jobs: with: ref: develop - - name: Wait for dev deployment to settle + - name: Wait for smoke test results to settle run: | - echo "โณ Waiting for dev deployment to fully settle..." - sleep 60 + echo "โณ Smoke tests completed, proceeding with promotion..." + sleep 30 - - name: Run comprehensive dev tests + - name: Verify dev smoke tests passed run: | - echo "๐Ÿงช Running comprehensive tests on dev environment..." - - # Use the canonical Knative domain - CANONICAL_URL="https://game-2048-dev.game-2048-dev.${{ secrets.DEV_DOMAIN }}" - echo "Testing canonical domain: $CANONICAL_URL" - - canonical_response=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$CANONICAL_URL") - if [ "$canonical_response" != "200" ]; then - echo "โŒ Canonical domain returned HTTP $canonical_response" - exit 1 - fi - echo "โœ… Canonical domain accessible" - - # Test content validation on canonical domain - echo "Testing content validation on canonical domain..." - content=$(curl -s -L --max-time 30 "$CANONICAL_URL") - - if ! echo "$content" | grep -q "2048"; then - echo "โŒ Content missing 2048 title" - exit 1 - fi - - if ! echo "$content" | grep -q "HOW TO PLAY"; then - echo "โŒ Content missing game instructions" - exit 1 - fi - - if ! echo "$content" | grep -q "style.css"; then - echo "โŒ CSS file not referenced" - exit 1 - fi - - if ! echo "$content" | grep -q "script.js"; then - echo "โŒ JavaScript file not referenced" - exit 1 - fi - - echo "โœ… All content validation tests passed" - - # Test performance on canonical domain - echo "Testing performance on canonical domain..." - response_time=$(curl -s -o /dev/null -w "%{time_total}" -L --max-time 30 "$CANONICAL_URL") - if (( $(echo "$response_time > 10.0" | bc -l) )); then - echo "โŒ Response time too slow: ${response_time}s" - exit 1 - fi - echo "โœ… Performance test passed: ${response_time}s" + echo "โœ… Development smoke tests passed - proceeding with auto-promotion to staging" - name: Auto-promote develop to staging branch uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - console.log('๐Ÿš€ All dev tests passed! Auto-promoting develop to staging branch...'); + console.log('๐Ÿš€ All dev smoke tests passed! Auto-promoting develop to staging branch...'); // Create a merge from develop to staging try { diff --git a/.github/workflows/promote-to-production.yml b/.github/workflows/promote-to-production.yml index 1cb7d83..2152353 100644 --- a/.github/workflows/promote-to-production.yml +++ b/.github/workflows/promote-to-production.yml @@ -2,7 +2,7 @@ name: Promote to Production on: workflow_run: - workflows: ["Deploy to Staging"] + workflows: ["Smoke Tests"] types: - completed branches: [ staging ] @@ -20,67 +20,21 @@ jobs: with: ref: staging - - name: Wait for staging deployment to settle + - name: Wait for staging smoke test results to settle run: | - echo "โณ Waiting for staging deployment to fully settle..." - sleep 120 + echo "โณ Staging smoke tests completed, proceeding with production promotion..." + sleep 30 - - name: Run comprehensive staging tests + - name: Verify staging smoke tests passed run: | - echo "๐Ÿงช Running comprehensive tests on staging environment..." - - # Use the canonical Knative domain for staging - CANONICAL_URL="https://game-2048-staging.game-2048-staging.${{ secrets.STAGING_DOMAIN }}" - echo "Testing canonical staging domain: $CANONICAL_URL" - - canonical_response=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$CANONICAL_URL") - if [ "$canonical_response" != "200" ]; then - echo "โŒ Staging canonical domain returned HTTP $canonical_response" - exit 1 - fi - echo "โœ… Staging canonical domain accessible" - - # Test staging content validation on canonical domain - echo "Testing staging content validation..." - content=$(curl -s -L --max-time 30 "$CANONICAL_URL") - - if ! echo "$content" | grep -q "2048"; then - echo "โŒ Content missing 2048 title" - exit 1 - fi - - if ! echo "$content" | grep -q "HOW TO PLAY"; then - echo "โŒ Content missing game instructions" - exit 1 - fi - - if ! echo "$content" | grep -q "style.css"; then - echo "โŒ CSS file not referenced" - exit 1 - fi - - if ! echo "$content" | grep -q "script.js"; then - echo "โŒ JavaScript file not referenced" - exit 1 - fi - - echo "โœ… All staging content validation tests passed" - - # Test staging performance on canonical domain - echo "Testing staging performance..." - response_time=$(curl -s -o /dev/null -w "%{time_total}" -L --max-time 30 "$CANONICAL_URL") - if (( $(echo "$response_time > 10.0" | bc -l) )); then - echo "โŒ Response time too slow: ${response_time}s" - exit 1 - fi - echo "โœ… Staging performance test passed: ${response_time}s" + echo "โœ… Staging smoke tests passed - proceeding with auto-promotion to production" - name: Auto-promote staging to main branch uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - console.log('๐ŸŽฏ All staging tests passed! Auto-promoting staging to main branch...'); + console.log('๐ŸŽฏ All staging smoke tests passed! Auto-promoting staging to main branch...'); // Create a merge from staging to main try { diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 7386f07..5227ffa 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -1,10 +1,11 @@ name: Smoke Tests on: - push: - branches: [ main, develop ] - pull_request: - branches: [ main ] + workflow_run: + workflows: ["Deploy to Development", "Deploy to Staging", "Deploy to Production"] + types: + - completed + branches: [ develop, staging, main ] schedule: # Run smoke tests every 6 hours - cron: '0 */6 * * *'