-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Richard Lane
committed
Sep 30, 2024
1 parent
bb85b86
commit d08d7e8
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
}); |