-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (56 loc) · 2.03 KB
/
code_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 black bin code
run: black bin --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: Check flake8 bin code
run: flake8 bin --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}}