8000 Python Flake8 linter workflow to replace stickler-ci (#1786) · PetervHoof3/pvlib-python@23453b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 23453b4

Browse files
reepoikandersolar
andauthored
Python Flake8 linter workflow to replace stickler-ci (pvlib#1786)
* adding flake8 linter workflow * lint only changed files * move changed files to env variable * remove filename flag * remove trailing dot * rename job * pass filenames as positional arguments * pipe filenames to xargs * change to check pvlib repo * only lint python files * missing parenthesis * skip linting if no Python files edited * try env instead of output * reformatting * create lint issues to try out the new linter * Revert "create lint issues to try out the new linter" This reverts commit 31cbb3b. * create a lint issue in a file with other lint issues * use flake8 --diff with flake8 5.0.4 * call to git fetch * use GITHUB_TOKEN for fetching * set repository read permission * try using https link to repo instead of ssh * test if GITHUB_TOKEN permissions are not needed * add temporary example of linting annotations * breaking workflow command into more steps * use base ref variable instead of hard-coding main branch * update whatsnew and remove lint error example --------- Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
1 parent 27bb4e5 commit 23453b4

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "flake8-linter-error",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+([EWCNF]\\d+\\s+.+)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"message": 4
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/flake8.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python Flake8 Linter
2+
on:
3+
pull_request:
4+
jobs:
5+
flake8-linter:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout source
9+
uses: actions/checkout@v3
10+
- name: Install Python 3.11
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.11'
14+
- name: Install Flake8 5.0.4 linter
15+
run: pip install flake8==5.0.4 # use this version for --diff option
16+
- name: Setup Flake8 output matcher for PR annotations
17+
run: echo '::add-matcher::.github/workflows/flake8-linter-matcher.json'
18+
- name: Fetch pull request target branch
19+
run: |
20+
git remote add upstream https://github.com/pvlib/pvlib-python.git
21+
git fetch upstream $GITHUB_BASE_REF
22+
- name: Run Flake8 linter
23+
run: git diff upstream/$GITHUB_BASE_REF HEAD | flake8
24+
--exclude pvlib/version.py
25+
--ignore E201,E241,E226,W503,W504
26+
--max-line-length 79
27+
--diff

docs/sphinx/source/whatsnew/v0.10.2.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Bug fixes
2323

2424
Testing
2525
~~~~~~~
26-
26+
* Added GitHub action to lint file changes with Flake8, replacing Stickler-CI.
27+
(:issue:`776`, :issue:`1722`, :pull:`1786`)
2728

2829
Documentation
2930
~~~~~~~~~~~~~
@@ -37,3 +38,4 @@ Requirements
3738
Contributors
3839
~~~~~~~~~~~~
3940
* Adam R. Jensen (:ghuser:`AdamRJensen`)
41+
* Taos Transue (:ghuser:`reepoi`)

0 commit comments

Comments
 (0)
0