-
Notifications
You must be signed in to change notification settings - Fork 16
52 lines (45 loc) · 1.28 KB
/
python-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
name: lint-python-code
on:
pull_request:
branches: [main]
paths: ['**.py', '**.ipynb']
workflow_call:
jobs:
python-linter:
runs-on: ubuntu-latest
steps:
- name: Checking out repo
uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install flake8
pip install pynblint
- name: Lint Python Code
run: |
flake8 . --select=E901,E999,F821,F822,F823 --exclude=__init__.py
env:
FLAKE8_OPTIONS: "--ignore=E203,W503"
- name: Getting PR details
run: |
touch pr.json
gh pr view $PR_NUMBER --json files > pr.json
touch pr.json
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Linting all Jupyter Notebook files
uses: jannekem/[email protected]
with:
script: |
import os
import json
with open('pr.json','r') as json_file:
data = json.load(json_file)
for file in data["files"]:
path = file["path"]
if os.path.exists(path):
os.system(f"pynblint {path}")