From ff35300559a9509f2ef54d263c3b29bfb7b566f7 Mon Sep 17 00:00:00 2001 From: Santos Date: Wed, 29 Apr 2026 15:11:51 -0700 Subject: [PATCH 1/7] Add notification on failed Python unit tests --- .github/workflows/testsPython.yml | 30 ++++++++++++++++++++++-------- Makefile | 4 ++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..02aafe4 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -34,6 +34,7 @@ on: env: python-version: "3.13" + NOTIFY_USER: santosi0 jobs: # Job #1: Run Python unit tests @@ -68,12 +69,25 @@ jobs: # on the test results. notifications: needs: python-unit-tests - runs-on: ubuntu-latest + runs-on: ubuntu-latest +# Only run this job if the test job failed + if: needs.python-unit-tests.result == 'failure' + 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: Create GitHub issue on test failure + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: "❌ Python Unit Tests Failed", + body: `@${process.env.NOTIFY_USER} +The Python unit tests failed. + +• Workflow: ${context.workflow} +• Branch: ${context.ref} +• Commit: ${context.sha} + +Please check the GitHub Actions logs for details.` + }) diff --git a/Makefile b/Makefile index 7bebd1b..539590c 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ export ifeq ($(OS),Windows_NT) PYTHON := python.exe - ACTIVATE_VENV := venv\Scripts\activate + ACTIVATE_VENV := venv/Scripts/activate else PYTHON := python3.13 - ACTIVATE_VENV := source venv/bin/activate + ACTIVATE_VENV := source venv/Scripts/activate endif PIP := $(PYTHON) -m pip From 4372a93ec9605066f0e74007d51c5c52a567cff9 Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 09:34:29 -0700 Subject: [PATCH 2/7] debug file --- .github/workflows/debug.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..2781cd4 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,11 @@ + +ame: Debug Manual Run + +on: + workflow_dispatch: + +jobs: + debug: + runs-on: ubuntu-latest + steps: + - run: echo "Workflow runs" From 90fd98970931b5e2bd082f027ce74a5b9f184248 Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 09:49:16 -0700 Subject: [PATCH 3/7] debug file --- .github/workflows/debug.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 2781cd4..68f8e10 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -1,5 +1,5 @@ -ame: Debug Manual Run +name: Debug Manual Run on: workflow_dispatch: From b429f23c2033c2cf91e8477de0b97a05bebc36ef Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 10:10:39 -0700 Subject: [PATCH 4/7] Add notification on failed Python unit tests --- .github/workflows/testsPython.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 02aafe4..4cc4b4a 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -82,12 +82,5 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, title: "❌ Python Unit Tests Failed", - body: `@${process.env.NOTIFY_USER} -The Python unit tests failed. - -• Workflow: ${context.workflow} -• Branch: ${context.ref} -• Commit: ${context.sha} - -Please check the GitHub Actions logs for details.` + body: `@${process.env.NOTIFY_USER}\nThe Python unit tests failed.\n\n• Workflow: ${context.workflow}\n• Branch: ${context.ref}\n• Commit: ${context.sha}\n\nPlease check the GitHub Actions logs for details.` }) From ae103b0a9dc5e6ed1b062e40e4aa8bed5c7b4691 Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 10:17:09 -0700 Subject: [PATCH 5/7] Add notification on failed Python unit tests --- .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 4cc4b4a..1ddf2cb 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -82,5 +82,5 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, title: "❌ Python Unit Tests Failed", - body: `@${process.env.NOTIFY_USER}\nThe Python unit tests failed.\n\n• Workflow: ${context.workflow}\n• Branch: ${context.ref}\n• Commit: ${context.sha}\n\nPlease check the GitHub Actions logs for details.` + body: `@${process.env.NOTIFY_USER}The Python unit tests failed.• Workflow: ${context.workflow}• Branch: ${context.ref}• Commit: ${context.sha}Please check the GitHub Actions logs for details.` }) From 8b2a18e89ba95146afbd3a5b06a1a80b7e727308 Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 10:43:17 -0700 Subject: [PATCH 6/7] Add notification on fialed Python unit tests --- .github/workflows/testsPython.yml | 40 +++++++++++++------------------ 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 1ddf2cb..c7bab08 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -15,22 +15,23 @@ # 3. Run unit tests and report results # # Notes: -# - secrets are set in https://github.com/smarter-sh/smarter/settings/secrets/actions +# - Secrets are set in https://github.com/smarter-sh/smarter/settings/secrets/actions # - 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: # - paths: # Trigger workflow on pull requests, but - - "**.py" # only if Python files are changed + workflow_dispatch: + pull_request: + paths: + - "**.py" push: - branches: # - - main # - - next # Trigger workflow on pushes to main and next - paths: # branches, but only if Python files are changed - - "**.py" # + branches: + - main + - next + paths: + - "**.py" env: python-version: "3.13" @@ -38,21 +39,17 @@ env: jobs: # Job #1: Run Python unit tests - # - # This job will run on an Ubuntu runner and execute the Python - # tests by using a custom action located in ./.github/actions/tests/python. python-unit-tests: - runs-on: ubuntu-latest # the runner (remote machine) will use Ubuntu OS + runs-on: ubuntu-latest steps: - name: Checkout code - id: checkout uses: actions/checkout@v6 - name: Run Python tests uses: ./.github/actions/tests/python with: environment: "local" - python-version: "${{ env.python-version}}" + python-version: "${{ env.python-version }}" openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}" openai-api-key: "${{ secrets.OPENAI_API_KEY }}" mysql-host: "${{ secrets.MYSQL_HOST }}" @@ -64,13 +61,9 @@ jobs: 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 -# Only run this job if the test job failed + runs-on: ubuntu-latest if: needs.python-unit-tests.result == 'failure' steps: @@ -82,5 +75,6 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, title: "❌ Python Unit Tests Failed", - body: `@${process.env.NOTIFY_USER}The Python unit tests failed.• Workflow: ${context.workflow}• Branch: ${context.ref}• Commit: ${context.sha}Please check the GitHub Actions logs for details.` - }) + body: `@${process.env.NOTIFY_USER}The Python unit tests failed.Please check the GitHub Actions logs for details.` + ) + '' From 419b03ae72e2d121478bd87ba0a7829b108a4c9a Mon Sep 17 00:00:00 2001 From: Santos Date: Thu, 30 Apr 2026 11:00:28 -0700 Subject: [PATCH 7/7] Add notification on failed Python unit tests --- .github/workflows/testsPython.yml | 51 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index c7bab08..0bb3ca1 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -15,23 +15,22 @@ # 3. Run unit tests and report results # # Notes: -# - Secrets are set in https://github.com/smarter-sh/smarter/settings/secrets/actions +# - secrets are set in https://github.com/smarter-sh/smarter/settings/secrets/actions # - Integrates with Codecov for coverage reporting ############################################################################### - name: Python Unit Tests on: - workflow_dispatch: - pull_request: - paths: - - "**.py" + workflow_dispatch: # Allows the workflow to be manually triggered from the GitHub Actions tab + pull_request: # + paths: # Trigger workflow on pull requests, but + - "**.py" # only if Python files are changed push: - branches: - - main - - next - paths: - - "**.py" + branches: # + - main # + - next # Trigger workflow on pushes to main and next + paths: # branches, but only if Python files are changed + - "**.py" # env: python-version: "3.13" @@ -39,17 +38,21 @@ env: jobs: # Job #1: Run Python unit tests + # + # This job will run on an Ubuntu runner and execute the Python + # tests by using a custom action located in ./.github/actions/tests/python. python-unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # the runner (remote machine) will use Ubuntu OS steps: - name: Checkout code + id: checkout uses: actions/checkout@v6 - name: Run Python tests uses: ./.github/actions/tests/python with: environment: "local" - python-version: "${{ env.python-version }}" + python-version: "${{ env.python-version}}" openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}" openai-api-key: "${{ secrets.OPENAI_API_KEY }}" mysql-host: "${{ secrets.MYSQL_HOST }}" @@ -61,9 +64,13 @@ jobs: 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 + runs-on: ubuntu-latest +# Only run this job if the test job failed if: needs.python-unit-tests.result == 'failure' steps: @@ -72,9 +79,15 @@ jobs: with: script: | github.rest.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: "❌ Python Unit Tests Failed", - body: `@${process.env.NOTIFY_USER}The Python unit tests failed.Please check the GitHub Actions logs for details.` + owner: context.repo.owner, + repo: context.repo.repo, + title: "❌ Python Unit Tests Failed", + body: `@${process.env.NOTIFY_USER} + The Python unit tests failed. + + • Workflow: ${context.workflow} + • Branch: ${context.ref} + • Commit: ${context.sha} + Please check the GitHub Actions logs for details.` ) - '' + ''