Repository navigation
Production Smoke Tests #1
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: Production Smoke Tests | |
| on: | |
| deployment_status: | |
| workflow_dispatch: | |
| inputs: | |
| deployment_url: | |
| description: "Deployment URL to smoke test" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| issues: write | |
| concurrency: | |
| group: production-smoke-${{ github.event.deployment_status.deployment.id || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| smoke: | |
| name: Smoke test deployed app | |
| if: github.event_name == 'workflow_dispatch' || github.event.deployment_status.state == 'success' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| env: | |
| SMOKE_BASE_URL: ${{ inputs.deployment_url || github.event.deployment_status.environment_url || github.event.deployment_status.target_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright browser | |
| run: npx playwright install --with-deps chromium | |
| - name: Validate deployment URL | |
| run: | | |
| if [ -z "$SMOKE_BASE_URL" ]; then | |
| echo "::error::No deployment URL was provided by the deployment_status event or workflow_dispatch input." | |
| exit 1 | |
| fi | |
| echo "Running smoke tests against $SMOKE_BASE_URL" | |
| - name: Run production smoke tests | |
| run: npm run smoke | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: production-smoke-playwright-report | |
| path: playwright-report/ | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| - name: Alert on smoke failure | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const baseUrl = process.env.SMOKE_BASE_URL || "unknown deployment URL"; | |
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: `Production smoke tests failed for ${baseUrl}`, | |
| body: [ | |
| "The post-deployment smoke test suite failed.", | |
| "", | |
| `Deployment URL: ${baseUrl}`, | |
| `Workflow run: ${runUrl}`, | |
| "", | |
| "Please inspect the Playwright report artifact and deployment logs." | |
| ].join("\n") | |
| }); |