type hints and api docs #147
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: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: [ main ] | |
jobs: | |
pylint: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
shell: bash | |
outputs: | |
branch: ${{ steps.extract_branch.outputs.branch }} | |
rating: ${{ steps.analyze.outputs.rating }} | |
path: ${{ steps.analyze.outputs.path }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract base branch name | |
id: extract_branch | |
shell: bash | |
run: | | |
TMP_PULL_BASE_REF="${{ github.base_ref }}" | |
TMP_GITHUB_REF="${GITHUB_REF#refs/heads/}" | |
EXPORT_VALUE="" | |
if [ "${TMP_PULL_BASE_REF}" != "" ] | |
then | |
EXPORT_VALUE="${TMP_PULL_BASE_REF}" | |
else | |
EXPORT_VALUE="${TMP_GITHUB_REF}" | |
fi | |
echo "branch=${EXPORT_VALUE}" >> $GITHUB_OUTPUT | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install tox | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install tox | |
#- name: Run tox bare-ass | |
#run: | | |
#tox -e lint | |
- name: Run pylint | |
id: analyze | |
env: | |
BADGE_PATH: badges/pylint-score.svg | |
run: | | |
rating=$(bash -c 'tox -e lint' | grep 'Your code has been rated at' | cut -f7 -d " ") | |
echo "Pylint score: ${rating}" | |
echo "rating=${rating}" >> $GITHUB_OUTPUT | |
echo "path=${BADGE_PATH}" >> $GITHUB_OUTPUT | |
badge: | |
# Only generate and publish if these conditions are met: | |
# - The previous job/analyze step ended successfully | |
# - At least one of these is true: | |
# - This is a push event and the push event is on branch 'main' or 'develop' | |
# Note: if this repo is personal (ie, not an org repo) then you can | |
# use the following to change the scope of the next 2 jobs | |
# instead of running on branch push as shown below: | |
# - This is a pull request event and the pull actor is the same as the repo owner | |
# if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/main' }} | |
name: Generate badge image with pylint score | |
runs-on: ubuntu-20.04 | |
needs: [pylint] | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: badges | |
path: badges | |
# Use the output from the `analyze` step | |
- name: Create pylint badge | |
uses: emibcn/[email protected] | |
id: badge | |
with: | |
label: 'Pylint score' | |
status: ${{ needs.pylint.outputs.rating }} | |
color: 'green' | |
path: ${{ needs.pylint.outputs.path }} | |
- name: Commit badge | |
env: | |
BRANCH: ${{ needs.pylint.outputs.branch }} | |
FILE: 'pylint-score.svg' | |
working-directory: ./badges | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
mkdir -p "${BRANCH}" | |
mv "${FILE}" "${BRANCH}" | |
git add "${BRANCH}/${FILE}" | |
# Will give error if badge has not changed | |
git commit -m "Add/Update badge" || true | |
- name: Push badge commit | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: badges | |
directory: badges |