style: pre-commit updates #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################################################### | |
| # 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 |