Skip to content
Snippets Groups Projects
Commit 19056abb authored by Jean-Michel Picod's avatar Jean-Michel Picod
Browse files

Replace custom action by shell script

parent 47c523e9
No related branches found
No related tags found
No related merge requests found
......@@ -26,11 +26,7 @@ jobs:
- name: Register matcher
run: echo ::add-matcher::./.github/python_matcher.json
- name: Test code with pylint
uses: ./github_actions/pylint
with:
config-file: .pylintrc
files: '**/*.py'
exclude-path: third_party
runs: ./tools/run_pylint.sh
yapf:
runs-on: ubuntu-18.04
......
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"]
---
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
#!/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
#!/usr/bin/env bash
SUCCESS=0
# Ensure we are at the project root directory
cd $(readlink -f $(dirname $0))/..
for file in `find . ! -path "./third_party/*" -type f -name '*.py'`
do
# Output header for our custom matcher on Github workflow
echo "PYLINT:${file}"
if ! pylint --rcfile=.pylintrc --score=n "$file"
then
SUCCESS=1
fi
done
exit $SUCCESS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment