From d69b40f2cfb6ded211e4e5edb0570e207a924e4f Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod <jmichel@google.com> Date: Thu, 27 Feb 2020 18:39:44 +0100 Subject: [PATCH] Add custom python problem matcher for pylint and yapf --- .github/python_matcher.json | 47 ++++++++++++++++++++++++++++++++++++ .github/workflows/python.yml | 12 ++++++--- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .github/python_matcher.json diff --git a/.github/python_matcher.json b/.github/python_matcher.json new file mode 100644 index 0000000..35abaf1 --- /dev/null +++ b/.github/python_matcher.json @@ -0,0 +1,47 @@ +{ + "problemMatcher": [ + { + "owner": "yapf-diff", + "pattern": [ + { + "regexp": "^[+-]{3}\\s*([^\\s]*)\\s*\\((original|reformatted)\\)$", + "file": 1 + }, + { + "regexp": "^@@\\s*-(\\d+),(\\d+)\\s*\\+(\\d+),(\\d+)\\s*@@$", + "line": 1, + "column": 2 + }, + { + "regexp": "^(\\s|\\+[^+]|\\-[^-]).*$", + "loop": true, + "message": 1 + } + ] + }, + { + "owner": "pylint", + "pattern": [ + { + "regexp": "^PYLINT:\\(.*)/.*$", + "fromPath": 1 + }, + { + "regexp": "^\\*{13}\\s*Module\\s+(.*)$", + "file": 1 + }, + { + "regexp": "^([CEFIRW]\\d{4}):\\s*(\\d+)\\s*:\\s*(.*)$", + "code": 1, + "line": 2, + "message": 3 + }, + { + "regexp": "^([^CEFIRW*]*)$", + "message": 1, + "loop": true + } + ] + } + ] +} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index dc739b8..7c0e104 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,7 +26,10 @@ jobs: - name: Test code with pylint run: | pip install pylint - pylint --rcfile=.pylintrc --score=n `find . ! -path "./third_party/*" -type f -name '*.py'` + ./setup.sh + echo ::add-matcher::./.github/python_matcher.json + find . -type f -name '*.py' -exec echo PYLINT:\{\} \; -exec pylint --rcfile=.pylintrc --score=n \{\} \; + #find . ! -path "./third_party/*" -type f -name '*.py' -exec echo PYLINT:\{\} \; -exec pylint --rcfile=.pylintrc --score=n \{\} \; yapf: runs-on: ubuntu-18.04 @@ -39,6 +42,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - pip install yapf + pip install yapf tockloader - name: Test code formatting with yapf - run: yapf --style=chromium --recursive --exclude third_party --diff . + run: | + ./setup.sh + echo ::add-matcher::./.github/python_matcher.json + yapf --style=chromium --recursive --exclude third_party --diff . -- GitLab