This package contains the following files:
├── src
│ ├── datagen.py
├── test
│ ├── test_datagen.py
├── .github
│ ├── workflows
│ ├── run_all_tests.yaml
├── requirements.txt
├── test-requirements.txt
└── .gitignore
The src directory contains all the source code files for your project. In this example, there is one file - datagen.py, which generates arrays of random numbers. You will edit this file to generate images or vectors from their respective datasets.
The test directory contains all the unit tests for our source code files (test_datagen.py).
The .github/workflows directory contains the different workflows that we want to run using GitHub Actions. The run_all_tests.yaml file runs all of our tests as separate jobs any time we push, create a pull request, or manually run on GitHub.
The requirements.txt file and test-requirements.txt file contain the required packages for the code and tests respectively.
To run all tests locally, make sure pytest is installed. Then, run
python -m pytest
in the root directory.
To run a single test, make sure pytest is installed. Them, run
python -m pytest test/test_file_you_want_to_run.py
To view the tests that have run and their logs,
- Go to your GitHub Repository
- Click on Actions
- View the most recent run of your workflow or manually run your workflow
To add a new test to the run_all_tests.yaml file, add a new job with the following format
Your_Job_Name:
runs-on: ubuntu-latest
container: python
steps:
- uses: actions/checkout@v2
- name: Your_Step_Name
run: |
pip install -r requirements.txt
pip install -r test-requirements.txt
python -m pytest test/test_file_you_want_to_run.py