Repository navigation
99 lines (90 loc) · 3.25 KB
/
Copy pathpython_ci.yml
File metadata and controls
99 lines (90 loc) · 3.25 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: check commit message format
run: |
# Get Commit Message
last_commit_log=$(git log -1 --pretty=format:"%s")
echo "last commit log: $last_commit_log"
feat="feat:[[:space:]].*$"
fix="fix:[[:space:]].*$"
test="test:[[:space:]].*$"
chore="chore:[[:space:]].*$"
merge="Merge pull request.*$"
doc="doc:[[:space:]].*$"
commit_msg_reg=(
$feat
$fix
$test
$chore
$merge
$doc
)
check_commit_msg() {
for regex in ${commit_msg_reg[*]}
do
echo "last commit log: $last_commit_log"
echo "$regex"
if [[ $last_commit_log =~ $regex ]]; then
printf "do match \n\n $last_commit_log $regex"
return 0
else
printf "does not match $last_commit_log $regex"
fi
done
return 1
}
check_commit_msg
if [[ $? == 1 ]]
then
printf "\n\n $last_commit_log commit message failed match"
exit 1
fi
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
# install flake8 checking tools dependencies
pip install flake8==3.7.9 black==20.8b1 flake8-black==0.2.1
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select BLK --show-source --statistics
# --exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --ignore=E402,W503,W504,E203,C901,I001,I003,I004,I100,I101,I201,D100 --max-complexity=10 --max-line-length=127 --statistics
# check notebook
# flake8_nb --count --exclude=*/*.py,*.ipynb_checkpoints* --ignore=E402,W503,W504,E203,C901,I001,I003,I004,I100,I101,I201,I202,D100 --max-line-length=127 --statistics
- name: Test with pytest
run: |
# install flake8 checking tools dependencies
pip install pytest==5.4.1 pytest-cov==2.8.1
python -m pytest --cov-report=xml --cov=./
- name: Check import foramt
run: |
# use isort to check
pip install flake8-isort==4.0.0
isort . --check-only --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=88
- name: Check rst file syntax
run: |
# use rstcheck
pip install flake8-docstrings==1.5.0
rstcheck docs/notes/*.rst -r
- uses: codecov/codecov-action@v1
with:
file: ./coverage.xml # optional
flags: unittests # optional
fail_ci_if_error: true # optional (default = false)