-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (77 loc) · 2.68 KB
/
github-ci.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
71
72
73
74
75
76
77
78
79
80
81
82
name: QMI Python CI runner on push
# This runner runs on regular push to a branch.
on:
push:
paths-ignore:
- README.md
- CHANGELOG.md
- .gitignore
- ACKNOWLEDGEMENTS.md
- LICENSE.md
- CONTRIBUTING.md
- TESTING.md
env:
# minimum pylint code quality score (max. 10)
PYLINT_MIN_SCORE: "9.00"
# minimum code coverage (goal: 90%; max. 100%)
COVERAGE_MIN_PERC: "90"
# maximum code complexity (goal: <= 30; unbounded)
COMPLEXITY_MAX_SCORE: "30"
# this should be a comma separated list
SOURCE_DIRS: "qmi/"
jobs:
on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python-latest
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
sudo apt-get update -qy
sudo apt-get install -y bc
python3 --version
pip install --upgrade pip
pip install -e '.[dev]'
- name: pylint
if: always()
run: |
pylint --score=yes --load-plugins=pylint.extensions.mccabe --max-complexity=$COMPLEXITY_MAX_SCORE $SOURCE_DIRS | tee pylint.log
PYLINT_SCORE=$( tail -n 2 pylint.log | grep -o '[0-9]\{1,2\}\.[0-9]\{2\}' | head -n 1 )
echo "Pylint score: $PYLINT_SCORE"
exit $( echo "$PYLINT_SCORE < $PYLINT_MIN_SCORE" | bc )
- name: upload pylint test results
if: always()
uses: actions/upload-artifact@v3
with:
name: pylint-results
path: pylint.log
- name: mypy
if: always()
run: |
mypy --namespace-packages $SOURCE_DIRS | tee mypy.log
if [ -n "$( tail -n 1 mypy.log | grep -e '^Succes' )" ]; then RESULT="pass"; else RESULT="fail"; fi
echo "Mypy result: $RESULT"
if [[ "$RESULT" = *"pass"* ]]; then exit 0; else exit 1; fi
- name: upload mypy test results
if: always()
uses: actions/upload-artifact@v3
with:
name: mypy-results
path: mypy.log
- name: coverage
if: always()
run: |
coverage run --branch --source=$SOURCE_DIRS -m unittest discover --start-directory=tests --pattern="test_*.py"
coverage report --show-missing --fail-under=$COVERAGE_MIN_PERC | tee coverage.log
COVERAGE_PERC=$(grep "TOTAL" coverage.log | grep -Eo '[0-9.]+%' | sed 's/%//')
echo "Coverage: $COVERAGE_PERC%"
exit $( echo "$COVERAGE_PERC < $COVERAGE_MIN_PERC" | bc )
- name: upload coverage results
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage.log