Skip to content

Badges

Badges #25

Workflow file for this run

name: Linting
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
- name: Create reports
run: |
mkdir -p reports
# Pyright
- name: Install pyright
run: |
pip install basedpyright
- name: Analyze the code with pyright
run: |
basedpyright $(git ls-files '*.py') > reports/pyright_report.txt || true
pyright_errors=$(basedpyright $(git ls-files '*.py') --outputjson | jq '.summary.errorCount')
echo ${pyright_errors} > pyright_errors.txt
if [ ${pyright_errors} -eq 0 ]; then
pyright_color="green"
elif [ ${pyright_errors} -lt 4 ]; then
pyright_color="yellow"
else
pyright_color="red"
fi
echo '{
"schemaVersion": 1,
"label": "Typing issues",
"message": "'"${pyright_errors}"'",
"color": "'"${pyright_color}"'"
}' > pyright_badge.json
# Pylint
- name: Install pylint
run: |
pip install pylint
- name: Analyze the code with pylint
run: |
pylint ./y > reports/pylint_report.txt || true
pylint_score=$(pylint -f json2 ./y | jq '.statistics.score')
echo ${pylint_score} > pylint_score.txt
if [ ${pylint_score} -gt 8 ]; then
pylint_color="green"
elif [ ${pylint_score} -gt 4 ]; then
pylint_color="yellow"
else
pylint_color="red"
fi
echo '{
"schemaVersion": 1,
"label": "Pylint score",
"message": "'"${pylint_score}"'/10",
"color": "'"${pylint_color}"'"
}' > pylint_badge.json
# Combine
- name: Combine results
run: |
echo '{
"pyright_errors": '"$(cat pyright_errors.txt)"',
"pylint_score": '"$(cat pylint_score.txt)"'
}' > lint.json
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: Upload lint.json
path: |
reports/*
- name: Release nightly
uses: softprops/action-gh-release@v2
with:
prerelease: true
name: nightly
tag_name: nightly
files: |
lint.json
pylint_badge.json
pyright_badge.json
reports/*
fail_on_unmatched_files: true
token: ${{ secrets.GITHUB_TOKEN }}