Skip to content

Commit

Permalink
workflow for pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Lane committed Sep 30, 2024
1 parent bb85b86 commit d08d7e8
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Run Pylint
id: pylint
run: |
pylint $(git ls-files '*.py') > pylint-report.txt || true
- name: Check Pylint score
id: check_score
run: |
score=$(tail -n 2 pylint_report.txt | head -n 1 | awk '{print $7}')
echo "Pylint score: $score"
echo "::set-output name=pylint_score::$score"
if grep -qE "fatal|error" pylint_report.txt; then
echo "Pylint found errors"
exit 1
fi
- name: Set Status
run: |
score=${{ steps.check_score.outputs.pylint_score }}
if (( $(echo "$score < 9.0" | bc -l) )); then
echo "Pylint score is less than 9.0; failing"
echo "::set-output name=pylint_status::failure"
exit 1
elif (( $(echo "$score < 10.0" | bc -l) )); then
echo "Pylint score is less than 10.0; warning"
echo "::set-output name=pylint_status::neutral"
else
echo "Pylint score is 10.0; passing"
echo "::set-output name=pylint_status::success"
- name: Set GitHub Commit Status
uses: actions/github-script@v6
with:
script: |
const status = '${{ steps.set_status.outputs.pylint_status }}';
const context = 'Pylint Check';
const description = status === 'success' ? 'Pylint score is 10.0' : (status === 'neutral' ? 'Pylint score is between 9.0 and 10.0' : 'Pylint score is less than 9.0 or contains errors');
const state = status === 'success' ? 'success' : (status === 'neutral' ? 'neutral' : 'failure');
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: state,
context: context,
description: description
});

0 comments on commit d08d7e8

Please sign in to comment.