Fix version #69
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: Code check | |
on: | |
pull_request: | |
branches: [develop, master] | |
jobs: | |
code_check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10.9' | |
check-latest: true | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Check black source code | |
run: black liltab --line-length=100 | |
- name: Check black test code | |
run: black test --line-length=100 | |
- name: Check flake8 source code | |
run: flake8 liltab --max-line-length=100 | |
- name: Check flake8 test code | |
run: flake8 test --max-line-length=100 | |
- name: Run test | |
run: | | |
export PYTHONPATH=`pwd` | |
pytest -vv --cov=liltab --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt | |
- name: Check test coverage | |
run: | | |
coverage_threshold=80 | |
coverage_result=$(awk -F " " '/^TOTAL/ {print substr($NF, 1, length($NF)-1)}' pytest-coverage.txt) | |
if (( $(echo "$coverage_result < $coverage_threshold" | bc -l) )); then | |
echo "Test coverage is below the threshold ($coverage_result%). Blocking PR merge." | |
exit 1 | |
fi | |
- name: Publish test report as an artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-results | |
path: | | |
pytest-coverage.txt | |
pytest.xml | |
- name: Pytest coverage comment | |
uses: MishaKav/pytest-coverage-comment@main | |
with: | |
pytest-coverage-path: pytest-coverage.txt | |
title: coverage | |
junitxml-path: pytest.xml | |
github-token: ${{github.token}} |