-
Notifications
You must be signed in to change notification settings - Fork 11
174 lines (148 loc) · 5.31 KB
/
pylint.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
name: Pylint
on:
push:
paths:
- '**.py'
- 'RequirementsFiles/**'
- '.github/workflows/pylint.yml'
- 'LaunchFile/**'
pull_request:
paths:
- '**.py'
- 'RequirementsFiles/**'
- '.github/workflows/pylint.yml'
- 'LaunchFile/**'
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: |
RequirementsFiles/requirements.txt
RequirementsFiles/requirements-CPU.txt
RequirementsFiles/requirements-cuda.txt
RequirementsFiles/requirements-cuda-CPU.txt
RequirementsFiles/requirements-llama-cpp.txt
RequirementsFiles/requirements-llama-cpp-CPU.txt
RequirementsFiles/requirements-stable-diffusion-cpp.txt
RequirementsFiles/requirements-stable-diffusion-cpp-CPU.txt
- name: Create virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install base dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install pylint black flake8 mypy
- name: Install project dependencies
run: |
# Installing main requirements (CPU version for CI)
pip install --no-deps -r RequirementsFiles/requirements-CPU.txt
pip install --no-deps -r RequirementsFiles/requirements-cuda-CPU.txt
pip install --no-deps -r RequirementsFiles/requirements-llama-cpp-CPU.txt
pip install --no-deps -r RequirementsFiles/requirements-stable-diffusion-cpp-CPU.txt
continue-on-error: true
- name: Create .pylintrc
run: |
cat > .pylintrc << EOF
[MASTER]
ignore=venv
persistent=yes
[MESSAGES CONTROL]
disable=\
C0111, # missing-docstring
C0103, # invalid-name
C0301, # line-too-long
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
R0913, # too-many-arguments
R0914, # too-many-locals
W0611, # unused-import
W0401, # wildcard-import
W0614, # unused-wildcard-import
W0703, # broad-except
E1101, # no-member (often false-positives)
[FORMAT]
max-line-length=120
[BASIC]
good-names=i,j,k,ex,Run,_,fp,id
[MISCELLANEOUS]
notes=FIXME,XXX,TODO
[SIMILARITIES]
min-similarity-lines=4
ignore-comments=yes
ignore-docstrings=yes
ignore-imports=yes
EOF
- name: Run black check
run: |
black --check --diff LaunchFile/
continue-on-error: true
- name: Run pylint
run: |
mkdir -p ./reports
pylint LaunchFile/ --output-format=json > ./reports/pylint-report.json || true
pylint LaunchFile/ --output-format=text > ./reports/pylint-report.txt || true
continue-on-error: true
- name: Run flake8
run: |
flake8 LaunchFile/ --max-line-length=120 --statistics --tee --output-file=./reports/flake8-report.txt || true
continue-on-error: true
- name: Check pylint score
run: |
SCORE=$(tail -n 2 ./reports/pylint-report.txt | grep -oP "(?<=rated at )[0-9.]+")
echo "Pylint score: $SCORE/10"
if (( $(echo "$SCORE < 7.0" | bc -l) )); then
echo "Warning: Pylint score is below 7.0"
exit 1
fi
- name: Run MyPy
run: |
source venv/bin/activate
mypy LaunchFile/
continue-on-error: true
- name: Run tests
run: |
source venv/bin/activate
python -m unittest discover -s tests || true
continue-on-error: true
- name: Upload lint results
if: always()
uses: actions/upload-artifact@v3
with:
name: lint-reports
path: |
./reports/pylint-report.json
./reports/pylint-report.txt
./reports/flake8-report.txt
retention-days: 14
- name: Comment PR with lint results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const pylintReport = fs.readFileSync('./reports/pylint-report.txt', 'utf8');
const score = pylintReport.match(/rated at ([0-9.]+)/);
const scoreValue = score ? score[1] : 'N/A';
const body = `## Lint Results
### Pylint Score: ${scoreValue}/10
<details>
<summary>Detailed Report</summary>
\`\`\`
${pylintReport}
\`\`\`
</details>`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});