Try with a custom action
This commit is contained in:
11
.github/workflows/python.yml
vendored
11
.github/workflows/python.yml
vendored
@@ -23,11 +23,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip setuptools wheel
|
python -m pip install --upgrade pip setuptools wheel
|
||||||
pip install tockloader pylint
|
pip install tockloader pylint
|
||||||
|
- name: Register matcher
|
||||||
|
run: echo ::add-matcher::./.github/python_matcher.json
|
||||||
- name: Test code with pylint
|
- name: Test code with pylint
|
||||||
run: |
|
uses: ./github_actions/pylint
|
||||||
echo ::add-matcher::./.github/python_matcher.json
|
with:
|
||||||
find . -type f -name '*.py' -exec echo PYLINT:\{\} \; -exec pylint --rcfile=.pylintrc --score=n \{\} \;
|
config-file: .pylintrc
|
||||||
# find . ! -path "./third_party/*" -type f -name '*.py' -exec echo PYLINT:\{\} \; -exec pylint --rcfile=.pylintrc --score=n \{\} \;
|
files: '**/*.py'
|
||||||
|
exclude-path: third_party
|
||||||
|
|
||||||
yapf:
|
yapf:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
|||||||
10
github_actions/pylint/Dockerfile
Normal file
10
github_actions/pylint/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM python:3.7-alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache bash build-base gcc
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
RUN pip install pylint
|
||||||
|
RUN python --version ; pip --version ; pylint --version
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
20
github_actions/pylint/action.yml
Normal file
20
github_actions/pylint/action.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: 'Pylint'
|
||||||
|
description: 'Runs pylint across multiple files/modules'
|
||||||
|
author: 'Jean-Michel Picod <jmichel@google.com>'
|
||||||
|
inputs:
|
||||||
|
config-file:
|
||||||
|
description: pylintrc configuration file
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: files, directories, or globs
|
||||||
|
required: true
|
||||||
|
ignore-files:
|
||||||
|
description: files to ignore/exclude
|
||||||
|
required: false
|
||||||
|
exclude-path:
|
||||||
|
description: paths to ignore/exclude
|
||||||
|
required: false
|
||||||
|
runs:
|
||||||
|
using: docker
|
||||||
|
image: Dockerfile
|
||||||
32
github_actions/pylint/entrypoint.sh
Normal file
32
github_actions/pylint/entrypoint.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
env
|
||||||
|
|
||||||
|
PYLINT_CMD=pylint --score=n${INPUT_CONFIG_FILE:+ --rcfile=${INPUT_CONFIG_FILE}}
|
||||||
|
EXCLUDE_PATH=${INPUT_EXCLUDE_PATH:-}
|
||||||
|
EXCLUDE_FILES=${INPUT_EXCLUDE_PATH:-}
|
||||||
|
|
||||||
|
SUCCESS=0
|
||||||
|
for file in ${FILES}
|
||||||
|
do
|
||||||
|
fname=$(basename $file)
|
||||||
|
directory=$(dirname $file)
|
||||||
|
if [[ "$directory" =~ "^${EXCLUDE_PATH}" ]]
|
||||||
|
then
|
||||||
|
echo "Ignoring file '$file' (reason: matching exclude-path parameter)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ "$fname" =~ "${EXCLUDE_FILES}" ]]
|
||||||
|
then
|
||||||
|
echo "Ignoring file '$file' (reason: matching exclude-files parameter)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Just to trigger the custom matcher
|
||||||
|
echo PYLINT:$file
|
||||||
|
if ! $PYLINT_CMD $file
|
||||||
|
then
|
||||||
|
SUCCESS=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $SUCCESS
|
||||||
Reference in New Issue
Block a user