-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added pipenv setup for runner, and Github Actions to test runner
- Loading branch information
1 parent
0aec97b
commit 413923e
Showing
7 changed files
with
216 additions
and
27 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,53 @@ | ||
name: Python Lint and Test - Backend | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
env: | ||
FIREBASE_KEY: ${{ secrets.FIREBASE_KEY }} | ||
CONTACT_MONGODB_AT: ${{ secrets.CONTACT_MONGODB_AT }} | ||
BACKEND_PORT: ${{ secrets.BACKEND_PORT }} | ||
MONGODB_PORT: ${{ secrets.MONGODB_PORT }} | ||
jobs: | ||
Lint_And_Test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.8" | ||
- name: Install dependencies | ||
working-directory: ./apps/backend | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install coverage | ||
pip install pipenv | ||
pipenv install --dev --system --deploy --ignore-pipfile | ||
- name: Analyze backend with pylint | ||
working-directory: ./apps/backend | ||
# https://pylint.readthedocs.io/en/v2.16.1/user_guide/configuration/all-options.html#fail-on | ||
# Uses the .pylintrc rules file in the working directory | ||
# Fail if any Error-level notices were produced | ||
# Fail if the code quality score is below 9.0 | ||
# Recursively search the specified directories for files to analyze | ||
# Check the file app.py | ||
run: pylint --fail-on=E --fail-under=9.0 --recursive=y app.py | ||
- name: Test backend with pytest + record coverage | ||
working-directory: ./apps/backend | ||
run: bash coverage.sh | ||
- name: Zip backend coverage report | ||
working-directory: ./apps/backend | ||
run: zip -r codeCoverage.zip coverageReport/ | ||
- name: Upload backend coverage report | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: code-coverage-report-backend | ||
path: ./apps/backend/codeCoverage.zip |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# This script is used by | ||
# - the VSCode task 'Backend Code Coverage Report' to produce a report that can be displayed in the editor | ||
# - the CI to execute the tests and produce a report that gets uploaded as an artifact for download | ||
|
||
# Avoid pollution from past runs | ||
rm -f .coverage | ||
rm -f coverage.xml | ||
rm -rf coverageReport/ | ||
|
||
# Running `python -m pytest` and not `pytest` because we need the current dir on sys.path, see https://docs.pytest.org/en/6.2.x/usage.html#calling-pytest-through-python-m-pytest | ||
# -rA flag controls printed report details: https://docs.pytest.org/en/6.2.x/usage.html#detailed-summary-report | ||
# --cov flags from pytest-cov plugin control contents and file output of the report https://pytest-cov.readthedocs.io/en/latest/readme.html | ||
python -m pytest \ | ||
-rA \ | ||
--cov-report xml:coverage.xml \ | ||
--cov-report html:coverageReport \ | ||
--cov-branch \ | ||
--cov . \ | ||
--cov modules/ | ||
|
||
# Print information in the console for the user as well | ||
# -m also prints Missed lines | ||
coverage report -m | ||
|
||
echo "▶ Use the VSCode action 'Coverage Gutters: Display Coverage' to see coverage in the editor" |
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