-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup a build workflow with unit tests and code coverage [RT-58] (#3)
* Tweak the build workflow Signed-off-by: Fabrice Normandin <[email protected]> * Move the build workflow Signed-off-by: Fabrice Normandin <[email protected]> * Fix typo in build.yml Signed-off-by: Fabrice Normandin <[email protected]> * Only run on pull requests (not twice) Signed-off-by: Fabrice Normandin <[email protected]> * Use `pdm install` to install dependencies Signed-off-by: Fabrice Normandin <[email protected]> * Use `pdm run` to run tests Signed-off-by: Fabrice Normandin <[email protected]> * Add missing pytest-cov dev dependency Signed-off-by: Fabrice Normandin <[email protected]> * Add some badges to the README.md Signed-off-by: Fabrice Normandin <[email protected]> * Fix failing test in main_test.py Signed-off-by: Fabrice Normandin <[email protected]> * Fix bug in conftest.py when no GPU on host Signed-off-by: Fabrice Normandin <[email protected]> * Round simple stats to avoid minute differences - Seems like the regression tests are failing due to extremely small differences in the statistics like 1e-9 difference. Not sure what's causing this issue though. Signed-off-by: Fabrice Normandin <[email protected]> * Reduce precision further (something fishy going on) Signed-off-by: Fabrice Normandin <[email protected]> * Reduce simple attributes precision further Signed-off-by: Fabrice Normandin <[email protected]> --------- Signed-off-by: Fabrice Normandin <[email protected]>
- Loading branch information
Showing
13 changed files
with
236 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python application | ||
|
||
on: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
# https://stackoverflow.com/a/72408109/6388696 | ||
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
linting: | ||
name: Run linting/pre-commit checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
- run: pip install pre-commit | ||
- run: pre-commit --version | ||
- run: pre-commit install | ||
- run: pre-commit run --all-files | ||
|
||
unit_tests: | ||
needs: [linting] | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
platform: [ubuntu-latest] | ||
python-version: ['3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: pip install pdm | ||
- name: Install dependencies | ||
run: pdm install | ||
- name: Test with pytest (very fast) | ||
run: pdm run pytest -v --shorter-than=1.0 --cov=project --cov-report=xml --cov-append | ||
- name: Test with pytest (fast) | ||
run: pdm run pytest -v --cov=project --cov-report=xml --cov-append | ||
|
||
- name: Store coverage report as an artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-reports-unit-tests-${{ matrix.platform }}-${{ matrix.python-version }} | ||
path: ./coverage.xml | ||
|
||
integration_tests: | ||
needs: [unit_tests] | ||
runs-on: self-hosted | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
python-version: ['3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: pip install pdm | ||
- name: Install dependencies | ||
run: pdm install | ||
|
||
- name: Test with pytest | ||
run: pdm run pytest -v --cov=project --cov-report=xml --cov-append | ||
|
||
- name: Test with pytest (only slow tests) | ||
run: pdm run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append | ||
|
||
- name: Store coverage report as an artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-reports-integration-tests-${{ matrix.python-version }} | ||
path: ./coverage.xml | ||
|
||
# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/ | ||
upload-coverage-codecov: | ||
needs: [integration_tests] | ||
runs-on: ubuntu-latest | ||
name: Upload coverage reports to Codecov | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: coverage-reports-* | ||
merge-multiple: false | ||
# download all the artifacts in this directory (each .coverage.xml will be in a subdirectory) | ||
# Next step if this doesn't work would be to give the coverage files a unique name and use merge-multiple: true | ||
path: coverage_reports | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
directory: coverage_reports | ||
fail_ci_if_error: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# research_template | ||
|
||
![Build](https://github.com/mila-iqia/ResearchTemplate/workflows/build.yml/badge.svg) | ||
[![codecov](https://codecov.io/gh/mila-iqia/ResearchTemplate/graph/badge.svg?token=I2DYLK8NTD)](https://codecov.io/gh/mila-iqia/ResearchTemplate) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
10 changes: 5 additions & 5 deletions
10
project/datamodules/datamodules_test/test_first_batch/cifar10.yaml
This file contains 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
10 changes: 5 additions & 5 deletions
10
project/datamodules/datamodules_test/test_first_batch/fashion_mnist.yaml
This file contains 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
10 changes: 5 additions & 5 deletions
10
project/datamodules/datamodules_test/test_first_batch/mnist.yaml
This file contains 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
Oops, something went wrong.