From dc43a27b0a0bfda4f2643e340fb3d00c949de8e2 Mon Sep 17 00:00:00 2001 From: jrkaus Date: Fri, 24 Apr 2026 09:25:20 -0700 Subject: [PATCH 1/5] Update testsPython.yml Added Notification (Lumo) --- .github/workflows/testsPython.yml | 73 ++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..994f17e 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -66,14 +66,75 @@ jobs: # This job will run after the Python unit tests and # is scaffolded to facilitate sending notifications based # on the test results. + # notifications: notifications: needs: python-unit-tests runs-on: ubuntu-latest + # Optional: Parameterize the addressee (though GitHub comments go to the PR/Issue author by default) + env: + TARGET_USER: ${{ secrets.NOTIFICATION_USER || github.actor }} + steps: - - name: Notify on test results + - name: Post Failure Comment + # Only run if the python-unit-tests job failed + if: needs.python-unit-tests.result == 'failure' + uses: actions/github-script@v7 + with: + script: | + const workflowName = context.workflow; + const jobName = 'python-unit-tests'; + const runId = context.runId; + const sha = context.sha; + const repo = context.repo; + + // Construct the message + const message = ` + ❌ **Workflow Failed!** + + * **Repository:** ${repo.owner}/${repo.repo} + * **Workflow:** ${workflowName} + * **Job:** ${jobName} + * **Status:** FAILED + * **Commit:** [\`${sha.substring(0, 7)}\`](${context.payload.pull_request?.html_url || `https://github.com/${repo.owner}/${repo.repo}/commit/${sha}`}) + * **Run Link:** [View Logs](${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${runId}) + + @${process.env.TARGET_USER}, please check the logs. + `; + + try { + // Try to comment on the Pull Request if it exists + if (context.payload.pull_request) { + await github.rest.issues.createComment({ + owner: repo.owner, + repo: repo.repo, + issue_number: context.payload.pull_request.number, + body: message + }); + core.info(`Comment posted on PR #${context.payload.pull_request.number}`); + } else { + // If no PR, comment on the commit (via the associated issue or just log) + // Note: GitHub Actions cannot directly "comment" on a commit hash in the UI + // unless there is an open PR or Issue. + // Fallback: Create an issue if none exists, or just log to console. + // For this assignment, logging to console is sufficient if no PR exists. + core.warning("No open Pull Request found. Notification logged to workflow output."); + core.info(message); + + // Optional: Create an issue for the failure if you want persistent tracking + // await github.rest.issues.create({ + // owner: repo.owner, + // repo: repo.repo, + // title: `🚨 Workflow Failure: ${workflowName}`, + // body: message + // }); + } + } catch (error) { + core.error(`Failed to post comment: ${error.message}`); + throw error; + } + + - name: Post Success Comment (Optional) + # Only run if the job succeeded (optional, usually we only care about failures) + if: needs.python-unit-tests.result == 'success' run: | - if [ "${{ needs.python-unit-tests.result }}" == "success" ]; then - echo "success notifications go here" - else - echo "failure notifications go here" - fi + echo "✅ Tests passed successfully. No failure notification needed." From ac516ad01137136d9066cea0a37384f67091a3c1 Mon Sep 17 00:00:00 2001 From: jrkaus Date: Fri, 24 Apr 2026 09:34:47 -0700 Subject: [PATCH 2/5] Update testsPython.yml --- .github/workflows/testsPython.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 994f17e..18ad365 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -34,6 +34,8 @@ on: env: python-version: "3.13" + +Exception("Intentional Failure") jobs: # Job #1: Run Python unit tests From 104ac52667fca4d3a4ac0800630daae934580518 Mon Sep 17 00:00:00 2001 From: jrkaus Date: Fri, 24 Apr 2026 10:37:24 -0700 Subject: [PATCH 3/5] Update testsPython.yml added line exception and failure notification --- .github/workflows/testsPython.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 18ad365..df9e1c8 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -116,7 +116,7 @@ jobs: } else { // If no PR, comment on the commit (via the associated issue or just log) // Note: GitHub Actions cannot directly "comment" on a commit hash in the UI - // unless there is an open PR or Issue. + // unless there is an open PR or Issue. // Fallback: Create an issue if none exists, or just log to console. // For this assignment, logging to console is sufficient if no PR exists. core.warning("No open Pull Request found. Notification logged to workflow output."); From cc30d358bc04313ac345ac03538741db622c2e12 Mon Sep 17 00:00:00 2001 From: Kaus Date: Fri, 24 Apr 2026 12:09:18 -0700 Subject: [PATCH 4/5] Add failure notification to test workflow --- .github/workflows/testsPython.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index df9e1c8..ecebf1d 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -140,3 +140,12 @@ jobs: if: needs.python-unit-tests.result == 'success' run: | echo "✅ Tests passed successfully. No failure notification needed." + + - name: Notify on failure + if: failure() + run: | + echo "❌ Python unit tests failed!" >> $GITHUB_STEP_SUMMARY + echo "Repository: $GITHUB_REPOSITORY" >> $GITHUB_STEP_SUMMARY + echo "Commit: $GITHUB_SHA" >> $GITHUB_STEP_SUMMARY + echo "Triggered by: $GITHUB_ACTOR" >> $GITHUB_S + From cf432a52c965c8ad87003ab0703a06daee0c0af4 Mon Sep 17 00:00:00 2001 From: Kaus Date: Fri, 24 Apr 2026 12:37:43 -0700 Subject: [PATCH 5/5] Add intentional failure to test notification --- .github/workflows/testsPython.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index ecebf1d..5711617 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -35,8 +35,6 @@ on: env: python-version: "3.13" -Exception("Intentional Failure") - jobs: # Job #1: Run Python unit tests # @@ -148,4 +146,5 @@ jobs: echo "Repository: $GITHUB_REPOSITORY" >> $GITHUB_STEP_SUMMARY echo "Commit: $GITHUB_SHA" >> $GITHUB_STEP_SUMMARY echo "Triggered by: $GITHUB_ACTOR" >> $GITHUB_S + exit 1