Feature/reaper app #38
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: Code Quality | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9.18] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pylint==3.0.1 | |
- name: Analysing the code with pylint | |
id: pylint | |
run: | | |
pylint --disable R0801,C0114,C0415,R1735,R1705,C0301,C0103,C0116,E0401,C0115,W0718,R1710,W0718,R0903 $(git ls-files '*.py') | |
pylint_score=$(pylint --score y --disable R0801,C0114,C0415,R1735,R1705,C0301,C0103,C0116,E0401,C0115,W0718,R1710,W0718,R0903 $(git ls-files '*.py') | grep -oP '(?<=Your code has been rated at )[^/]+') | |
echo "::set-output name=Pylint_Score::$pylint_score" | |
echo "Your code has been rated at : $pylint_score" > pylint_report.txt | |
- name: Check Pylint Threshold | |
run: | | |
pylint_score="${{ steps.pylint.outputs.Pylint_Score }}" | |
pylint_score=$(echo "$pylint_score" | awk -F. '{print $1}') | |
if [ "$pylint_score" -ge 9 ]; then | |
echo "Pylint score meets the threshold." | |
else | |
echo "Pylint score does not meet the threshold. Skipping badge generation." | |
exit 0 | |
fi | |
- name: Publish Pylint Badge | |
if: success() | |
run: | | |
pylint_score="${{ steps.pylint.outputs.Pylint_Score }}" | |
pylint_score=$(echo "$pylint_score" | awk -F. '{print $1}') | |
curl "https://img.shields.io/badge/Pylint-$pylint_score/10-brightgreen?style=for-the-badge" -o pylint-badge.svg | |
working-directory: ${{ github.workspace }} | |
- name: Upload Pylint Badge as Artifact | |
if: success() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pylint-badge | |
path: pylint-badge.svg | |
- name: Download Pylint Badge | |
run: | | |
# Define your GitHub repository and the artifact name | |
repo="${{ github.repository }}" | |
artifact_name="pylint-badge" | |
# Create the URL to download the artifact | |
url="https://api.github.com/repos/${repo}/actions/artifacts/${artifact_name}/zip" | |
# Download the artifact and save it as pylint-badge.zip | |
curl -LJO -H "Accept: application/vnd.github.v3+json" "$url" | |
unzip -q "${artifact_name}" -d "${artifact_name}" | |
# Move the badge to the desired location in your repository | |
mv "${artifact_name}/pylint-badge.svg" "${{ github.workspace }}" | |
working-directory: ${{ github.workspace }} | |
- name: Extract Pylint score | |
id: pylint-score | |
run: echo "name=score::$(cat pylint_report.txt | grep -oP '(?<=Your code has been rated at )[^/]+')" >> $GITHUB_STATE | |
- name: Publish score as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pylint-artifact | |
path: pylint_report.txt |