-
Notifications
You must be signed in to change notification settings - Fork 8
270 lines (249 loc) · 9.51 KB
/
linter.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#############################
# Start the job on all push #
#############################
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
###############
# Set the Job #
###############
jobs:
build_controller:
# Name the Job
name: Lint Code Base - Controller
# Set the agent to run on
runs-on: ubuntu-latest
###################
# Python versions #
###################
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
#########################
# Pick a Python version #
#########################
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
##############################
# Set up a Python virtualenv #
##############################
- name: Set up Python virtual environment
run: |
# Create a virtualenv
python -m venv python${{ matrix.python-version }}-venv-controller
# Activate virtualenv
source python${{ matrix.python-version }}-venv-controller/bin/activate
########################
# Install dependencies #
########################
- name: Install dependencies
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-controller/bin/activate
# Install dependencies required by the controller
sudo apt-get install graphviz libgraphviz-dev
# Upgrade pip
python -m pip install --upgrade pip
# Install linters and other python modules
pip install pylint pycodestyle flake8 black mypy isort setuptools wheel pytest
##############################
# Install controller modules #
##############################
- name: Install controller modules
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-controller/bin/activate
# Setup db_update library
cd db_update
python setup.py install
# Setup protos
cd ../control_plane/protos
python setup.py install
# Setup controller modules
cd ../../control_plane/controller
python setup.py install
cd ../../
################################
# Run Linter against code base #
################################
- name: Python Code Quality and Lint
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-controller/bin/activate
# Module to be tested
cd db_update
module="db_update" # control_plane/protos folder excluded
# pylint
echo Running: pylint $module --disable=similarities
pylint $module --disable=similarities
if [ "$?" = "0" ]; then echo "Pylint ok"; else echo "Pylint error"; exit $exit_code; fi
# pycodestyle
echo Running: pycodestyle $module
pycodestyle $module
if [ "$?" = "0" ]; then echo "pycodestyle ok"; else echo "pycodestyle error"; exit $exit_code; fi
# flake8
echo Running: flake8 $module
flake8 $module
if [ "$?" = "0" ]; then echo "Flake8 ok"; else echo "Flake8 error"; exit $exit_code; fi
# black
# echo Running: black --check $module
# black --check $module
# if [ "$?" = "0" ]; then echo "Black ok"; else echo "Black error"; exit $exit_code; fi
# mypy
# echo Running: mypy $module
# mypy $module
# if [ "$?" = "0" ]; then echo "mypy ok"; else echo "mypy error"; exit $exit_code; fi
# isort
echo Running: isort -rc $module -c --diff
isort -rc $module -c --diff --project db_update
if [ "$?" = "0" ]; then echo "isort ok"; else echo "isort error"; exit $exit_code; fi
cd ../
#
# Module to be tested
cd control_plane/controller/
module="controller" # control_plane/protos folder excluded
# pylint
echo Running: pylint $module --disable=similarities
pylint $module --disable=similarities
if [ "$?" = "0" ]; then echo "Pylint ok"; else echo "Pylint error"; exit $exit_code; fi
# pycodestyle
echo Running: pycodestyle $module
pycodestyle $module
if [ "$?" = "0" ]; then echo "pycodestyle ok"; else echo "pycodestyle error"; exit $exit_code; fi
# flake8
echo Running: flake8 $module
flake8 $module
if [ "$?" = "0" ]; then echo "Flake8 ok"; else echo "Flake8 error"; exit $exit_code; fi
# black
# echo Running: black --check $module
# black --check $module
# if [ "$?" = "0" ]; then echo "Black ok"; else echo "Black error"; exit $exit_code; fi
# mypy
# echo Running: mypy $module
# mypy $module
# if [ "$?" = "0" ]; then echo "mypy ok"; else echo "mypy error"; exit $exit_code; fi
# isort
echo Running: isort -rc $module -c --diff
isort -rc $module -c --diff --project controller
if [ "$?" = "0" ]; then echo "isort ok"; else echo "isort error"; exit $exit_code; fi
cd ../../
build_node_manager:
# Name the Job
name: Lint Code Base - Node Manager
# Set the agent to run on
runs-on: ubuntu-latest
###################
# Python versions #
###################
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
#########################
# Pick a Python version #
#########################
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
##############################
# Set up a Python virtualenv #
##############################
- name: Set up Python virtual environment
run: |
# Create a virtualenv
python -m venv python${{ matrix.python-version }}-venv-node-mgr
# Activate virtualenv
source python${{ matrix.python-version }}-venv-node-mgr/bin/activate
########################
# Install dependencies #
########################
- name: Install dependencies
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-node-mgr/bin/activate
# Upgrade pip
python -m pip install --upgrade pip
# Install linters and other python modules
pip install pylint pycodestyle flake8 black mypy isort setuptools wheel pytest
################################
# Install node manager modules #
################################
- name: Install node manager modules
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-node-mgr/bin/activate
# Setup protos
cd control_plane/protos
python setup.py install
# Setup node-manager modules
cd ../../control_plane/node-manager
python setup.py install
cd ../../
################################
# Run Linter against code base #
################################
- name: Python Code Quality and Lint
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv-node-mgr/bin/activate
# Module to be tested
cd control_plane/node-manager
module="node_manager" # control_plane/protos folder excluded
# pylint
echo Running: pylint $module --disable=similarities
pylint $module --disable=similarities
if [ "$?" = "0" ]; then echo "Pylint ok"; else echo "Pylint error"; exit $exit_code; fi
# pycodestyle
echo Running: pycodestyle $module
pycodestyle $module
if [ "$?" = "0" ]; then echo "pycodestyle ok"; else echo "pycodestyle error"; exit $exit_code; fi
# flake8
echo Running: flake8 $module
flake8 $module
if [ "$?" = "0" ]; then echo "Flake8 ok"; else echo "Flake8 error"; exit $exit_code; fi
# black
# echo Running: black --check $module
# black --check $module
# if [ "$?" = "0" ]; then echo "Black ok"; else echo "Black error"; exit $exit_code; fi
# mypy
# echo Running: mypy $module
# mypy $module
# if [ "$?" = "0" ]; then echo "mypy ok"; else echo "mypy error"; exit $exit_code; fi
# isort
echo Running: isort -rc $module -c --diff
isort -rc $module -c --diff --project node_manager
if [ "$?" = "0" ]; then echo "isort ok"; else echo "isort error"; exit $exit_code; fi
cd ../../