Run Your Project Tests on GitHub
The final project requires passing tests for your app. Once they work locally, you can use GitHub Actions to run them on your committed code. This is an optional resource, with no separate lab or submission.
Run python -m pytest in your project first. Record the packages your app and tests need in requirements.txt, including pytest and httpx. Your tests must initialize a separate test database without relying on files or environment settings that exist only on your laptop.
Create .github/workflows/tests.yml in your final-project repository:
name: Project tests
on:
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- run: python -m pip install -r requirements.txt
- run: python -m pytestIf you keep test dependencies in a separate file, add an installation step for that file too. Commit and push the workflow and tests to the default branch. Open Actions → Project tests → Run workflow on GitHub. The runner checks out your code, installs its dependencies, and runs the same command you used locally. Open the completed run to read the results. GitHub’s manual-run instructions describe these controls.
A failure on GitHub can reveal an undeclared dependency or a test that relies on existing data from your laptop. Fix the cause, check locally, commit, and run the workflow again. The workflow is manual: later pushes do not start it automatically. Your local tests and bug demonstration satisfy the final project’s testing requirement even if you do not use Actions.