From 5cbebff80aa71d3877a0b1005f6425cd279f4914 Mon Sep 17 00:00:00 2001 From: Jane Ho Date: Mon, 27 Apr 2026 22:18:04 -0700 Subject: [PATCH 1/4] feat: add OpenAI failure notification for Stackdemy assignment --- .github/workflows/testsPython.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..63cd19f 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -72,8 +72,25 @@ jobs: 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: Notify on Failure + if: ${{ needs.python-unit-tests.result == 'failure' }} + run: | + curl --location 'https://api.openai.lawrencemcdaniel.com/passthrough_v2/' \ + --header 'x-api-key: ${{ secrets.PASSTHROUGH_API_KEY }}' \ + --header 'Content-Type: application/json' \ + --data '{ + "model": "gpt-4o-mini", + "end_point": "ChatCompletion", + "temperature": 0.50, + "max_tokens": 1024, + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant." + }, + { + "role": "user", + "content": "The Python Unit Tests failed for ${{ github.repository }}." + } + ] + }' From 72c768d19d2b43eb1231f7d803623b4b920fb4aa Mon Sep 17 00:00:00 2001 From: Jane Ho Date: Mon, 27 Apr 2026 22:58:28 -0700 Subject: [PATCH 2/4] feat: sending email to user in case of failure --- .github/workflows/testsPython.yml | 42 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 63cd19f..39d6e8a 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -69,28 +69,24 @@ jobs: notifications: needs: python-unit-tests runs-on: ubuntu-latest + if: always() steps: - - name: Notify on test results - run: | - - name: Notify on Failure + - name: Send mail if: ${{ needs.python-unit-tests.result == 'failure' }} - run: | - curl --location 'https://api.openai.lawrencemcdaniel.com/passthrough_v2/' \ - --header 'x-api-key: ${{ secrets.PASSTHROUGH_API_KEY }}' \ - --header 'Content-Type: application/json' \ - --data '{ - "model": "gpt-4o-mini", - "end_point": "ChatCompletion", - "temperature": 0.50, - "max_tokens": 1024, - "messages": [ - { - "role": "system", - "content": "You are a helpful assistant." - }, - { - "role": "user", - "content": "The Python Unit Tests failed for ${{ github.repository }}." - } - ] - }' + uses: dawidd6/action-send-mail@v3 + with: + # SMTP server details (e.g., smtp.gmail.com) + server_address: ${{ secrets.MAIL_SERVER }} + server_port: 465 + username: ${{ secrets.MAIL_USERNAME }} + password: ${{ secrets.MAIL_PASSWORD }} + subject: "❌ Build Failed: ${{ github.repository }}" + # This sends the email to the person who pushed the code + to: ${{ github.event.pusher.email }} + from: GitHub Actions Bot + body: | + The Python Unit Tests failed for ${{ github.repository }}. + Commit: ${{ github.sha }} + Pushed by: ${{ github.actor }} + + Check the logs here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} From 07f9c5cd24eca8d02c9d8cffa20e06a921fcd3a5 Mon Sep 17 00:00:00 2001 From: Jane Ho Date: Tue, 28 Apr 2026 20:25:53 -0700 Subject: [PATCH 3/4] Add email notification for failed unit tests --- .github/workflows/testsPython.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 39d6e8a..87b7e03 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -69,24 +69,22 @@ jobs: notifications: needs: python-unit-tests runs-on: ubuntu-latest + # This line ensures the notification job runs even if the tests fail if: always() steps: - name: Send mail - if: ${{ needs.python-unit-tests.result == 'failure' }} + needs.python-unit-tests.result == 'failure' uses: dawidd6/action-send-mail@v3 with: - # SMTP server details (e.g., smtp.gmail.com) - server_address: ${{ secrets.MAIL_SERVER }} + # SMTP server details (Example for Gmail) + server_address: smtp.gmail.com server_port: 465 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} - subject: "❌ Build Failed: ${{ github.repository }}" - # This sends the email to the person who pushed the code - to: ${{ github.event.pusher.email }} - from: GitHub Actions Bot + subject: "CI Build Failed: ${{ github.repository }}" + to: janednho@gmail.com + from: GitHub Actions Workflow body: | - The Python Unit Tests failed for ${{ github.repository }}. - Commit: ${{ github.sha }} - Pushed by: ${{ github.actor }} + The Python Unit Tests failed for the repository ${{ github.repository }}. Check the logs here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} From c01a757a75eadae1dca27e659ec95d2164c014fd Mon Sep 17 00:00:00 2001 From: Jane Ho Date: Tue, 28 Apr 2026 20:34:54 -0700 Subject: [PATCH 4/4] added IF and removed personal email --- .github/workflows/testsPython.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 87b7e03..07bfa0f 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -73,7 +73,7 @@ jobs: if: always() steps: - name: Send mail - needs.python-unit-tests.result == 'failure' + if: needs.python-unit-tests.result == 'failure' uses: dawidd6/action-send-mail@v3 with: # SMTP server details (Example for Gmail) @@ -82,7 +82,7 @@ jobs: username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} subject: "CI Build Failed: ${{ github.repository }}" - to: janednho@gmail.com + to: #your email here from: GitHub Actions Workflow body: | The Python Unit Tests failed for the repository ${{ github.repository }}.