-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
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,74 @@ | ||
# This workflow will install Python dependencies and run tests with a single version of Python | ||
# For more information see: | ||
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Build App | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
strategy: | ||
matrix: | ||
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
os: [ubuntu-latest, windows-latest] | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python_version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "${{ matrix.python_version }}" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r tests/requirements.txt | ||
- name: Test with pytest (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
coverage run -m pytest \ | ||
-c ./tests/pytest.ini \ | ||
-W ignore::pytest.PytestCollectionWarning \ | ||
--md-report --md-report-output=report.md --md-report-color=never \ | ||
tests || pytest_exit_code=$? | ||
echo "## :clipboard: Test Results" >> $GITHUB_STEP_SUMMARY | ||
cat report.md >> $GITHUB_STEP_SUMMARY | ||
echo "## :bar_chart: Code coverage" >> $GITHUB_STEP_SUMMARY | ||
coverage report --format markdown >> $GITHUB_STEP_SUMMARY | ||
if [[ "$(coverage report --format total)" -lt 80 ]] | ||
then | ||
echo "::error::Code coverage is less than 80%" && exit_code=1 | ||
fi | ||
if [[ $pytest_exit_code -gt 0 ]] | ||
then | ||
echo "::error::Unit tests failed" && exit_code=1 | ||
fi | ||
exit $exit_code | ||
- name: Test with pytest (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
coverage run -m pytest -c ./tests/pytest.ini -W ignore::pytest.PytestCollectionWarning --md-report --md-report-output=report.md --md-report-color=never tests || pytest_exit_code=$? | ||
echo "## :clipboard: Test Results" >> $GITHUB_STEP_SUMMARY | ||
cat report.md >> $GITHUB_STEP_SUMMARY | ||
echo "## :bar_chart: Code coverage" >> $GITHUB_STEP_SUMMARY | ||
coverage report --format markdown >> $GITHUB_STEP_SUMMARY | ||
if ( "$(coverage report --format total)" -lt 80 ) | ||
{ | ||
echo "::error::Code coverage is less than 80%" && exit_code=1 | ||
} | ||
if ( $pytest_exit_code -gt 0 ) | ||
{ | ||
echo "::error::Unit tests failed" && exit_code=1 | ||
} | ||
exit $exit_code |