-
Notifications
You must be signed in to change notification settings - Fork 870
130 lines (116 loc) · 3.48 KB
/
lint.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
123
124
125
126
127
128
129
130
name: Lint
on:
push:
branches:
- master
pull_request:
branches:
- master
merge_group:
jobs:
mypy:
runs-on: ubuntu-20.04
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: x64
- name: Checkout TorchServe
uses: actions/checkout@v3
- name: Install mypy
run: |
pip install mypy
- name: Run mypy
env:
MYPY_FORCE_COLOR: 1
TERM: xterm-color
run: |
set -eux
STATUS=
if ! mypy --config=mypy.ini; then
STATUS=fail
fi
if [ -n "$STATUS" ]; then
echo 'Please fix the above mypy warnings.'
false
fi
build:
runs-on: ubuntu-20.04
name: Lint changed files
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Install lint utilities
run: |
pip install pre-commit
pre-commit install
- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]
with:
files: |
**/*.py
- name: Lint all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
pre-commit run --files $file
done
- name: What to do if this action fails
if: ${{ failure() }}
run: |
echo "You need to lint your code with pre-commit"
echo "pip install pre-commit"
echo "cd serve/"
echo "pre-commit install"
echo "pre-commit will lint your code for you, so git add and commit those new changes and this check should become green"
echo "If you've already pushed some files remotely then run git diff --name-only main | xargs pre-commit run --files"
spellcheck:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get install aspell aspell-en
pip install pyspelling
- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]
with:
files: |
**/*.md
- name: Check spellings
run: |
sources=""
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
sources="${sources} -S $file"
done
if [ ! "$sources" ]; then
echo "No files to spellcheck"
else
pyspelling -c $GITHUB_WORKSPACE/ts_scripts/spellcheck_conf/spellcheck.yaml --name Markdown $sources
fi
- name: In the case of misspellings
if: ${{ failure() }}
run: |
echo "Please fix the misspellings. If you are sure about some of them, "
echo "so append those to ts_scripts/spellcheck_conf/wordlist.txt"
security-check:
runs-on: ubuntu-20.04
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: x64
- name: Checkout TorchServe
uses: actions/checkout@v3
- name: Install Bandit
run: |
python -m pip install --upgrade pip
pip install bandit
- name: Run bandit
run: |
# Skip the B501 rule related to SSL certificate validation checks
bandit -r . --severity-level high -s B501