From 721fcf955c8d0bb87a6b5b49d03dc33c9bd3c0f5 Mon Sep 17 00:00:00 2001 From: akasarle Date: Mon, 4 May 2026 10:55:06 -0700 Subject: [PATCH 1/2] Modify notifications job to send email on failure Updated the notifications job to send an email on test failure instead of using conditional echo statements. --- .github/workflows/testsPython.yml | 55 ++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..f5ff60e 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -19,7 +19,7 @@ # - Integrates with Codecov for coverage reporting ############################################################################### name: Python Unit Tests - + on: workflow_dispatch: # Allows the workflow to be manually triggered from the GitHub Actions tab pull_request: # @@ -31,10 +31,10 @@ on: - next # Trigger workflow on pushes to main and next paths: # branches, but only if Python files are changed - "**.py" # - + env: python-version: "3.13" - + jobs: # Job #1: Run Python unit tests # @@ -46,7 +46,7 @@ jobs: - name: Checkout code id: checkout uses: actions/checkout@v6 - + - name: Run Python tests uses: ./.github/actions/tests/python with: @@ -61,19 +61,50 @@ jobs: mysql-database: "${{ secrets.MYSQL_DATABASE }}" mysql-charset: "${{ secrets.MYSQL_CHARSET }}" codecov-token: "${{ secrets.CODECOV_TOKEN }}" - + # Job #2: Notifications (Mini-capstone assignment) # This job will run after the Python unit tests and # is scaffolded to facilitate sending notifications based # on the test results. + # notifications: + # needs: python-unit-tests + # runs-on: ubuntu-latest + # steps: + # - name: Notify on test results + # run: | + # if [ "${{ needs.python-unit-tests.result }}" == "success" ]; then + # echo "success notifications go here" + # else + # echo "failure notifications go here" + # fi + + # Job #2a: Notifications (Mini-capstone assignment solution) + # This job will run after the Python unit tests and + # is scaffolded to facilitate sending notifications based + # on the test results, especially the new *Failure notification. notifications: needs: python-unit-tests runs-on: ubuntu-latest + if: always() # ensures this job runs even if tests fail + steps: - - name: Notify on test results - run: | - if [ "${{ needs.python-unit-tests.result }}" == "success" ]; then - echo "success notifications go here" - else - echo "failure notifications go here" - fi + - name: Send email on failure + if: ${{ needs.python-unit-tests.result != 'success' }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: ${{ secrets.SMTP_SERVER }} + server_port: ${{ secrets.SMTP_PORT }} + username: ${{ secrets.EMAIL_USERNAME }} + password: ${{ secrets.EMAIL_PASSWORD }} + subject: "❌ Unit Tests Failed" + body: | + Your GitHub Actions workflow has failed. + + Repository: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + + Check details here: +https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + to: ${{ secrets.EMAIL_TO }} + from: GitHub Actions From 0a273a79c0c79824448bfc9bc67c653cacb95252 Mon Sep 17 00:00:00 2001 From: akasarle Date: Mon, 4 May 2026 11:04:30 -0700 Subject: [PATCH 2/2] Refactor Python unit tests workflow configuration --- .github/workflows/testsPython.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index f5ff60e..fbf4405 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -19,7 +19,7 @@ # - Integrates with Codecov for coverage reporting ############################################################################### name: Python Unit Tests - + on: workflow_dispatch: # Allows the workflow to be manually triggered from the GitHub Actions tab pull_request: # @@ -31,10 +31,10 @@ on: - next # Trigger workflow on pushes to main and next paths: # branches, but only if Python files are changed - "**.py" # - + env: python-version: "3.13" - + jobs: # Job #1: Run Python unit tests # @@ -46,7 +46,7 @@ jobs: - name: Checkout code id: checkout uses: actions/checkout@v6 - + - name: Run Python tests uses: ./.github/actions/tests/python with: @@ -61,7 +61,7 @@ jobs: mysql-database: "${{ secrets.MYSQL_DATABASE }}" mysql-charset: "${{ secrets.MYSQL_CHARSET }}" codecov-token: "${{ secrets.CODECOV_TOKEN }}" - + # Job #2: Notifications (Mini-capstone assignment) # This job will run after the Python unit tests and # is scaffolded to facilitate sending notifications based @@ -77,7 +77,7 @@ jobs: # else # echo "failure notifications go here" # fi - + # Job #2a: Notifications (Mini-capstone assignment solution) # This job will run after the Python unit tests and # is scaffolded to facilitate sending notifications based @@ -86,7 +86,7 @@ jobs: needs: python-unit-tests runs-on: ubuntu-latest if: always() # ensures this job runs even if tests fail - + steps: - name: Send email on failure if: ${{ needs.python-unit-tests.result != 'success' }} @@ -99,12 +99,12 @@ jobs: subject: "❌ Unit Tests Failed" body: | Your GitHub Actions workflow has failed. - + Repository: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} - + Check details here: -https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} to: ${{ secrets.EMAIL_TO }} from: GitHub Actions