Skip to content

Workflow file for this run

name: Development Checks
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
pull_request:
branches:
- main
- dev
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: pip
cache-dependency-path: |
requirements.txt
- name: Run pre-commit
uses: pre-commit/[email protected]
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pre-commit
uses: pre-commit/[email protected]
- name: Run Pytest
run: |
# coverage run on pytest. If pytest fails, workflow exits in failure
coverage run -m pytest --doctest-modules
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
coverage report -m --format=markdown >> temp.md
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
{
echo 'REPORT<<EOF'
cat temp.md
echo EOF
} >> "$GITHUB_ENV"
echo "report=$REPORT" >> $GITHUB_ENV
- name: Report Coverage
uses: actions/github-script@v7
env:
min_coverage: 50
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${{ env.REPORT }}`
})
if ( ${{ env.total }} <= ${{ env.min_coverage }} ) {
console.log(
"Coverage test failed as code coverage is ${{ env.total }}% and the minimum is ${{ env.min_coverage}}%"
)
process.exitCode = 1
}