-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (114 loc) · 3.96 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
---
###########################
###########################
## 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:
# Name the Job
name: Lint Code Base
# 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@master
#########################
# 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
# Activate virtualenv
source python${{ matrix.python-version }}-venv/bin/activate
########################
# Install dependencies #
########################
- name: Install dependencies
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv/bin/activate
# Install dependencies required by NetfilterQueue
sudo apt-get install build-essential python-dev libnetfilter-queue-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 data-plane modules #
##############################
- name: Install data-plane modules
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv/bin/activate
# Setup data-plane modules
python setup.py install
################################
# Run Linter against code base #
################################
- name: Python Code Quality and Lint
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv/bin/activate
# Module to be tested
module=data_plane
# pylint
echo Running: pylint $module
pylint $module
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
if [ "$?" = "0" ]; then echo "isort ok"; else echo "isort error"; exit $exit_code; fi