|
| 1 | +name: QA Scenarios |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'scripts/run-scenarios.cjs' |
| 7 | + - 'bruno/Tests/**' |
| 8 | + - 'bruno/SIS/**' |
| 9 | + - '.github/workflows/qa-scenarios.yml' |
| 10 | + push: |
| 11 | + branches: [ main ] |
| 12 | + paths: |
| 13 | + - 'scripts/run-scenarios.cjs' |
| 14 | + - 'bruno/Tests/**' |
| 15 | + - 'bruno/SIS/**' |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + env: |
| 19 | + description: 'Bruno environment name (default ci.ed-fi.org)' |
| 20 | + required: false |
| 21 | + default: 'ci.ed-fi.org' |
| 22 | + includeSteps: |
| 23 | + description: 'Include detailed steps in aggregate summary' |
| 24 | + required: false |
| 25 | + default: 'false' |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + pull-requests: write |
| 30 | + actions: read |
| 31 | + |
| 32 | +concurrency: |
| 33 | + group: qa-scenarios-${{ github.ref }} |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | +jobs: |
| 37 | + qa: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Use Node.js 20 |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: 20 |
| 47 | + cache: 'npm' |
| 48 | + cache-dependency-path: bruno/package-lock.json |
| 49 | + |
| 50 | + - name: Mask client secret (if present) |
| 51 | + run: | |
| 52 | + if [ -f bruno/Tests/environments/ci.ed-fi.org.bru ]; then |
| 53 | + SECRET_LINE=$(grep -E 'edFiClientSecret:' bruno/Tests/environments/ci.ed-fi.org.bru || true) |
| 54 | + if [ -n "$SECRET_LINE" ]; then |
| 55 | + SECRET_VAL=$(echo "$SECRET_LINE" | sed -E 's/.*edFiClientSecret:\s*([^ ]+)/\1/') |
| 56 | + echo "::add-mask::$SECRET_VAL" |
| 57 | + fi |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Run QA Scenarios |
| 61 | + id: runqa |
| 62 | + env: |
| 63 | + BRUNO_ENV: ${{ github.event.inputs.env || 'ci.ed-fi.org' }} |
| 64 | + INCLUDE_STEPS: ${{ github.event.inputs.includeSteps || 'false' }} |
| 65 | + run: | |
| 66 | + set -e |
| 67 | + INCLUDE_FLAG="" |
| 68 | + if [ "$INCLUDE_STEPS" = "true" ]; then INCLUDE_FLAG="--include-steps"; fi |
| 69 | + node scripts/run-scenarios.cjs --env "$BRUNO_ENV" $INCLUDE_FLAG || EXIT=$? |
| 70 | + # Preserve non-zero exit for later; script already writes summary.json |
| 71 | + if [ -n "$EXIT" ]; then echo "exit_code=$EXIT" >> $GITHUB_OUTPUT; else echo "exit_code=0" >> $GITHUB_OUTPUT; fi |
| 72 | +
|
| 73 | + - name: Show aggregate summary |
| 74 | + if: always() |
| 75 | + run: | |
| 76 | + if [ -f automation-testing/results/summary.json ]; then |
| 77 | + cat automation-testing/results/summary.json | jq '.' || cat automation-testing/results/summary.json |
| 78 | + else |
| 79 | + echo "summary.json not found" |
| 80 | + fi |
| 81 | +
|
| 82 | + - name: Upload QA artifacts |
| 83 | + if: always() |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: qa-scenarios-results |
| 87 | + path: | |
| 88 | + automation-testing/results/summary.json |
| 89 | + automation-testing/results/*.json |
| 90 | + automation-testing/results/last-output.txt |
| 91 | + if-no-files-found: warn |
| 92 | + |
| 93 | + - name: Comment summary on PR |
| 94 | + if: github.event_name == 'pull_request' |
| 95 | + uses: actions/github-script@v7 |
| 96 | + with: |
| 97 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + script: | |
| 99 | + const fs = require('fs'); |
| 100 | + const summaryPath = 'automation-testing/results/summary.json'; |
| 101 | + if (!fs.existsSync(summaryPath)) { |
| 102 | + github.rest.issues.createComment({ |
| 103 | + issue_number: context.payload.pull_request.number, |
| 104 | + owner: context.repo.owner, |
| 105 | + repo: context.repo.repo, |
| 106 | + body: ':warning: QA Scenarios did not produce a summary.json file.' |
| 107 | + }); |
| 108 | + } else { |
| 109 | + const data = JSON.parse(fs.readFileSync(summaryPath,'utf8')); |
| 110 | + const lines = []; |
| 111 | + lines.push('### QA Scenarios Summary'); |
| 112 | + lines.push(`Status: **${data.exitStatus}**`); |
| 113 | + lines.push(`Entities Processed: **${data.totals.entitiesProcessed}**`); |
| 114 | + lines.push(`Assertions: Passed **${data.totals.assertionsPassed}**, Failed **${data.totals.assertionsFailed}**, Total **${data.totals.assertionsTotal}**`); |
| 115 | + if (data.entities) { |
| 116 | + lines.push(''); |
| 117 | + lines.push('| Entity | Passed | Failed | Total |'); |
| 118 | + lines.push('|--------|--------|--------|-------|'); |
| 119 | + for (const e of data.entities) { |
| 120 | + const a = e.assertions; lines.push(`| ${e.entity} | ${a.passed} | ${a.failed} | ${a.total} |`); |
| 121 | + } |
| 122 | + } |
| 123 | + github.rest.issues.createComment({ |
| 124 | + issue_number: context.payload.pull_request.number, |
| 125 | + owner: context.repo.owner, |
| 126 | + repo: context.repo.repo, |
| 127 | + body: lines.join('\n') |
| 128 | + }); |
| 129 | + } |
| 130 | +
|
| 131 | + - name: Fail if scenarios failed |
| 132 | + if: steps.runqa.outputs.exit_code != '0' |
| 133 | + run: | |
| 134 | + echo "Scenario script exited with code ${EXIT_CODE}"; exit 1 |
0 commit comments