-
-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (74 loc) · 2.71 KB
/
testsPython.yml
File metadata and controls
79 lines (74 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
###############################################################################
# Workflow: Python Unit Tests
#
# Purpose:
# Runs Python unit tests automatically on pull requests and pushes to main/next.
#
# Triggers:
# - On push to main or next branches (Python files only)
# - On pull requests affecting Python files
# - Manual dispatch
#
# Key Steps:
# 1. Checkout repository code
# 2. Set up Python environment using a custom action
# 3. Run unit tests and report results
#
# Notes:
# - 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
push:
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"
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
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}}"
openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}"
openai-api-key: "${{ secrets.OPENAI_API_KEY }}"
mysql-host: "${{ secrets.MYSQL_HOST }}"
mysql-port: "${{ secrets.MYSQL_PORT }}"
mysql-user: "${{ secrets.MYSQL_USER }}"
mysql-password: "${{ secrets.MYSQL_PASSWORD }}"
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