@@ -516,3 +516,61 @@ jobs:
516516 env :
517517 TESTREPORTING_S3 : ${{ secrets.TESTREPORTING_S3 }}
518518 run : $SCRIPT_PY tests/reset_testing_resources.py ${{ matrix.test_suite }}
519+
520+ # Failed jobs that did not upload a test report are not seen by the test report processing, e.g. jobs that failed
521+ # during setup. Upload a report listing the failed jobs, so that the test report processing notifies the failed run.
522+ report-failed-jobs :
523+ needs : integration-tests
524+ if : ${{ failure() && (github.event_name != 'schedule' || github.repository == 'aws/aws-sam-cli') }}
525+ name : Report failed jobs
526+ runs-on : ubuntu-latest
527+ permissions :
528+ actions : read
529+ contents : read
530+ id-token : write
531+ steps :
532+ # Same as "Determine test type" of the integration-tests job
533+ - name : Determine test type
534+ shell : bash
535+ run : |
536+ if [[ "${{ inputs.install_mode }}" == "nightly-release" ]] || \
537+ [[ "${{ github.event.action }}" == "published" && "${{ github.event.release.prerelease }}" == "true" ]]; then
538+ echo "TEST_TYPE=nightly-release" >> "$GITHUB_ENV"
539+ elif [[ "${{ inputs.install_mode }}" == "latest-release" ]] || \
540+ [[ "${{ github.event.action }}" == "published" && "${{ github.event.release.prerelease }}" != "true" ]]; then
541+ echo "TEST_TYPE=latest-release" >> "$GITHUB_ENV"
542+ elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
543+ echo "TEST_TYPE=master" >> "$GITHUB_ENV"
544+ elif [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
545+ echo "TEST_TYPE=develop" >> "$GITHUB_ENV"
546+ else
547+ echo "TEST_TYPE=other" >> "$GITHUB_ENV"
548+ fi
549+
550+ - name : Configure AWS credentials via OIDC
551+ uses : aws-actions/configure-aws-credentials@cbe3b392738ccf3f987d68400dafcf4b0624a56c # v6
552+ with :
553+ role-to-assume : ${{ secrets.OIDC_ROLE_ARN }}
554+ aws-region : us-east-1
555+
556+ - name : Assume test reporting role
557+ uses : aws-actions/configure-aws-credentials@cbe3b392738ccf3f987d68400dafcf4b0624a56c # v6
558+ with :
559+ role-to-assume : ${{ secrets.TESTREPORTING_ARN }}
560+ aws-region : us-east-1
561+ role-chaining : true
562+
563+ - name : Upload failed jobs report
564+ shell : bash
565+ env :
566+ GH_TOKEN : ${{ github.token }}
567+ TESTREPORTING_S3 : ${{ secrets.TESTREPORTING_S3 }}
568+ run : |
569+ FAILED_JOBS=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/jobs?per_page=100" \
570+ --jq '[.jobs[] | select(.conclusion == "failure") | .name] | join(", ")')
571+ jq -n --arg failed_jobs "$FAILED_JOBS" --argjson created "$(date +%s)" \
572+ '{created: $created, duration: 0, exitcode: 1, environment: {FailedJobs: $failed_jobs},
573+ summary: {passed: 0, failed: 0, total: 0, collected: 0}, tests: []}' > TEST_REPORT-workflow.json
574+ cat TEST_REPORT-workflow.json
575+ aws s3 cp TEST_REPORT-workflow.json \
576+ "s3://$TESTREPORTING_S3/github/$TEST_TYPE/$(date -u +%Y-%m-%d)/$GITHUB_RUN_ID/TEST_REPORT-workflow.json"
0 commit comments