Build Unit test boilerplate #1206
Workflow file for this run
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
name: Unit Testing | |
on: | |
pull_request: | |
types: [opened, edited, reopened, closed, synchronize] | |
paths: | |
- '**.py' | |
branches: | |
- 'development' | |
# push: | |
# paths-ignore: | |
# - '.github/**' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
checks: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
name: Unit test | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -e . | |
pip install -r tests/requirements.txt | |
- name: Test with pytest | |
run: | | |
pytest tests --junitxml=tests/junit/test-results.xml \ | |
--cov-config=tests/.coveragerc --cov=sarracenia --cov-report=html --cov-report=lcov --cov-report=xml \ | |
--html=tests/report.html --self-contained-html | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action/linux@v2 | |
if: ${{ always() }} | |
with: | |
files: | | |
tests/junit/test-results.xml | |
# - name: Publish Coverage Results | |
# uses: orgoro/[email protected] | |
# with: | |
# coverageFile: tests/coverage/coverage.xml | |
# - name: Pytest coverage comment | |
# uses: MishaKav/pytest-coverage-comment@main | |
# if: ${{ always() }} | |
# with: | |
# #pytest-coverage-path: tests/coverage/coverage.lcov | |
# pytest-xml-coverage-path: tests/coverage/coverage.xml | |
# #title: My Coverage Report Title | |
# #badge-title: My Badge Coverage Title | |
# #hide-badge: false | |
# #hide-report: false | |
# create-new-comment: false | |
# hide-comment: false | |
# report-only-changed-files: true | |
# remove-link-from-badge: false | |
# #unique-id-for-comment: python3.8 | |
# junitxml-path: tests/junit/test-results.xml | |
# junitxml-title: Test Results | |
- name: Upload pytest junit results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: results-junit | |
path: tests/junit/test-results.xml | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
- name: Upload pytest HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: results-report | |
path: tests/report.html | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
- name: Upload code coverage report (HTML) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: tests/coverage/html_report | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
- name: Upload code coverage report (LCOV) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-lcov | |
path: tests/coverage/coverage.lcov | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
- name: Upload code coverage report (XML) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-xml | |
path: tests/coverage/coverage.xml | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} |