Skip to content

Commit 183f71d

Browse files
authored
Merge pull request #74 from DSACMS/use-upstream-microsoft-pylint-action
Use Upstream Microsoft Pylint Action
2 parents e7d4253 + 3435969 commit 183f71d

File tree

4 files changed

+8
-84
lines changed

4 files changed

+8
-84
lines changed

.github/workflows/checks.yml

+8-34
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,15 @@ on:
55

66
jobs:
77
run-pylint:
8+
name: runner / pylint
89
permissions: write-all
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: LouisBrunner/[email protected]
12-
id: init
12+
- uses: actions/checkout@v2
13+
- uses: dciborow/[email protected]
1314
with:
14-
token: ${{ secrets.GITHUB_TOKEN }}
15-
name: Pylint Report
16-
status: in_progress
17-
- uses: actions/checkout@v4
18-
# update stats
19-
- uses: actions/setup-python@v4
20-
with:
21-
python-version: '3.9'
22-
- name: cache pip
23-
uses: actions/cache@v3
24-
with:
25-
path: ~/.cache/pip
26-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
27-
restore-keys: |
28-
${{ runner.os }}-pip-
29-
- run: pip install -r requirements.txt
30-
- run: |
31-
PYLINT_REPORT=$(./run_pylint.sh)
32-
echo "PYLINT_REPORT<<EOF" >> $GITHUB_ENV
33-
echo "$PYLINT_REPORT" >> $GITHUB_ENV
34-
echo 'EOF' >> $GITHUB_ENV
35-
36-
- uses: LouisBrunner/[email protected]
37-
with:
38-
token: ${{ secrets.GITHUB_TOKEN }}
39-
check_id: ${{ steps.init.outputs.check_id }}
40-
status: completed
41-
conclusion: ${{ job.status }}
42-
output: |
43-
{"summary":"Pylint Report Generation ran with status: ${{job.status}}" , "text_description": "Pylint Issues are listed below."}
44-
annotations: |
45-
${{ env.PYLINT_REPORT }}
15+
github_token: ${{ secrets.GITHUB_TOKEN }}
16+
reporter: github-pr-review
17+
level: warning
18+
glob_pattern: "**/*.py"
19+
filter_mode: "file"

run_pylint.sh

-4
This file was deleted.

scripts/run_pylint.py

-3
This file was deleted.

scripts/tests/metrics_tests.py

-43
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,3 @@
66

77
def test_base_metric():
88
raise NotImplementedError
9-
10-
11-
def run_pylint():
12-
# Run pylint command and parse json
13-
pylint_out = subprocess.run(['pylint', '--output-format=json',
14-
"--init-hook=\"import sys; sys.path.append('scripts/')\"", "scripts/*"], stdout=subprocess.PIPE, check=False)
15-
16-
pylint_list = json.loads(pylint_out.stdout)
17-
18-
# Parse pylint format into GitHub Checks Annotation format
19-
for item in pylint_list:
20-
# Rename error type to annotation_level
21-
item['annotation_level'] = item.pop('type')
22-
23-
# translate pylint terms to github terms
24-
if item['annotation_level'] == "convention":
25-
item['annotation_level'] = 'notice'
26-
elif item['annotation_level'] == "refactor":
27-
item['annotation_level'] = 'warning'
28-
29-
# if end fields are empty, make them the same as the start
30-
item['end_line'] = item.pop('endLine')
31-
if item['end_line'] is None:
32-
item['end_line'] = item['line']
33-
34-
item['start_line'] = item.pop('line')
35-
item['start_column'] = item.pop('column')
36-
item['end_column'] = item.pop('endColumn')
37-
if item['end_column'] is None:
38-
item['end_column'] = item['start_column']
39-
item['title'] = item.pop('symbol')
40-
41-
# Don't include columns if annotation spans multiple lines
42-
if item['start_line'] != item['end_line']:
43-
item.pop('start_column')
44-
item.pop('end_column')
45-
item.pop('module')
46-
item.pop('obj')
47-
item.pop('message-id')
48-
49-
to_return = pylint_list[:50]#json.dumps(pylint_list, indent=2)
50-
#Print max of 50 terms since thats the max for GitHub
51-
print(json.dumps(to_return, indent=2))

0 commit comments

Comments
 (0)