-
Notifications
You must be signed in to change notification settings - Fork 11
147 lines (136 loc) · 4.65 KB
/
python_linter.yml
File metadata and controls
147 lines (136 loc) · 4.65 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
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
---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Python Linter
#
# 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:
python-lint:
# Name the Job
name: Python Linter
# 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
# 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
# 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 requirements #
########################
- name: Install requirements
run: |
# Activate virtualenv
source python${{ matrix.python-version }}-venv/bin/activate
# Install requirements
pip install -r requirements.txt
################################
# 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="nets nets-unmantained nets-in-progress"
# pylint
for file in $(find $module -type f); do
if [ ${file: -3} == ".py" ]; then
echo Running: pylint $file
pylint $file
if [ "$?" = "0" ]; then echo "Pylint ok"; else echo "Pylint error"; exit $exit_code; fi
fi
done;
# pycodestyle
for file in $(find $module -type f); do
if [ ${file: -3} == ".py" ]; then
echo Running: pycodestyle $file
pycodestyle $file
if [ "$?" = "0" ]; then echo "pycodestyle ok"; else echo "pycodestyle error"; exit $exit_code; fi
fi
done;
# flake8
for file in $(find $module -type f); do
if [ ${file: -3} == ".py" ]; then
echo Running: flake8 $file
flake8 $file
if [ "$?" = "0" ]; then echo "Flake8 ok"; else echo "Flake8 error"; exit $exit_code; fi
fi
done;
# black
#for file in $(find $module -type f); do
# if [ ${file: -3} == ".py" ]; then
# echo Running: black --check $file
# black --check $file
# if [ "$?" = "0" ]; then echo "Black ok"; else echo "Black error"; exit $exit_code; fi
# fi
#done;
# mypy
#for file in $(find $module -type f); do
# if [ ${file: -3} == ".py" ]; then
# echo Running: mypy $file
# mypy $file
# if [ "$?" = "0" ]; then echo "mypy ok"; else echo "mypy error"; exit $exit_code; fi
# fi
#done;
# isort
for file in $(find $module -type f); do
if [ ${file: -3} == ".py" ]; then
echo Running: isort -rc $file -c --diff
isort -rc $file -c --diff --project $file
if [ "$?" = "0" ]; then echo "isort ok"; else echo "isort error"; exit $exit_code; fi
fi
done;