add pylint yml file and pylint-score #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Pylint | |
on: pull_request | |
jobs: | |
formatting: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Set up Python ${{ matrix.python-version }} for Pylint | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Pylint | |
run: pip install pylint | |
- name: Check Score | |
run: | | |
echo "Start checking scores" | |
pylint `find . -name "*.py"` | grep 'Your code has been rated' | awk '{print $10}' | awk -F/ '{print $1}' | |
NEW_SCORE=$(pylint `find . -name "*.py"` | grep 'Your code has been rated' | awk '{print $10}' | awk -F/ '{print $1}') | |
NEW_SCORE=$(echo "scale=2; $NEW_SCORE" | bc) | |
echo NEW_SCORE=$NEW_SCORE | |
OLD_SCORE=$(cat .pylint-score); | |
OLD_SCORE=$(echo "scale=2; $OLD_SCORE" | bc) | |
THREESHOLD_SCORE=$OLD_SCORE; | |
echo THREESHOLD_SCORE=$THREESHOLD_SCORE | |
if [ "$(echo "$NEW_SCORE > $THREESHOLD_SCORE" | bc -l)" -eq 1 ] ; then | |
echo "NEW_SCORE is greater than THREESHOLD_SCORE" | |
echo "Updating THREESHOLD_SCORE" | |
echo THREESHOLD_SCORE=$NEW_SCORE | |
echo "$THREESHOLD_SCORE" > .pylint-score | |
git config --global user.name "PylintBot" | |
git config --global author.name "PylintBot" | |
git config --global user.email "[email protected]" | |
git config --global author.email "[email protected]" | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git checkout $GITHUB_HEAD_REF | |
git pull | |
git commit -am "Update pylint threeshold score" | |
git push | |
else | |
exit 1 | |
fi |