-
Notifications
You must be signed in to change notification settings - Fork 5
122 lines (119 loc) · 5.33 KB
/
main.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Linting, testing, coverage, and release
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
jobs:
test_3_6:
name: ${{ matrix.os.name }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os.runs-on }}
strategy:
matrix:
python-version: [ 3.6 ]
os:
- name: Linux
runs-on: ubuntu-20.04
python_platform: linux
- name: Windows
runs-on: windows-latest
python_platform: win32
- name: macOS
runs-on: macos-latest
python_platform: darwin
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.6
uses: actions/setup-python@v5
with:
python-version: 3.6
architecture: x64
- name: install_dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
pip install -r requirements.txt
- name: Test with unittest
run: |
python setup.py test
test:
name: ${{ matrix.os.name }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os.runs-on }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
os:
- name: Linux
runs-on: ubuntu-latest
python_platform: linux
- name: Windows
runs-on: windows-latest
python_platform: win32
- name: macOS
runs-on: macos-latest
python_platform: darwin
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: install_dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
pip install -r requirements.txt
- name: Test with unittest
run: |
python setup.py test
- name: Lint with flake8
run: |
pip install flake8
flake8 . --count --select=$(printf '%s,' {A..Z}) --ignore='F811,W503,E203' --show-source --max-complexity=13 --max-line-length=119 --statistics
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Check formatted with black
run: |
pip install black
python -m black . --check --extend-exclude 'cdd/tests/mocks/cstify.py'
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Doc coverage
run: |
pip install interrogate
interrogate -e 'cdd/tests/mocks/cstify.py' --generate-badge '.github/doccoverage.svg'
sed -i 's/interrogate/doc coverage/g; s/data-doc c/data-doc-c/g' .github/doccoverage.svg
# Setup git config
email_author="$(git log -1 --pretty=format:'%an <%ce>')"
author="${email_author% *}"
email="${email_author#*<}"; email="${email::-1}"
git config --global user.name "$author"
git config --global user.email "$email"
# Only commit and push if there's a change
if git diff --name-only --diff-filter='M' | grep -qF '.github/doccoverage.svg'; then
git add .github/doccoverage.svg
git commit -m '[.github/doccoverage.svg] Updated coverage'
git push origin master
fi
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Test coverage
run: |
pip install codecov coverage
coverage run -m unittest discover
env
bash <(curl --proto '=https' --tlsv1.2 -sSf https://codecov.io/bash)
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: (matrix.python-version == '3.8' || matrix.python-version == '3.12') && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: PyPi release
run: |
pip install twine
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_NON_INTERACTIVE: 1
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'