Skip to content

[NeMo-UX] Support load_strictness #10679

[NeMo-UX] Support load_strictness

[NeMo-UX] Support load_strictness #10679

name: Isort and Black Formatting; PyLint Docs check
# Incrementally reformat only changed files with black, all files with isort
#
# Replaces pre-commit.ci, since it reformats all the files.
# See issue https://github.com/pre-commit-ci/issues/issues/90
#
# The action requires a custom token to trigger workflow after pushing reformatted files back to the branch.
# `secrets.GITHUB_TOKEN` can be used instead, but this will result
# in not running necessary checks after reformatting, which is undesirable.
# For details see https://github.com/orgs/community/discussions/25702
on:
pull_request_target:
paths:
- '**.py'
types: [ opened, synchronize, reopened, labeled, unlabeled ]
defaults:
run:
shell: bash -x -e -u -o pipefail {0}
jobs:
reformat_with_isort_and_black_and_pylint:
runs-on: ubuntu-latest
permissions:
# write permissions required to commit changes
contents: write
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
# setup repository and ref for PRs, see
# https://github.com/EndBug/add-and-commit?tab=readme-ov-file#working-with-prs
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# custom token is required to trigger actions after reformatting + pushing
token: ${{ secrets.NEMO_REFORMAT_TOKEN }}
# https://github.com/tj-actions/changed-files
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**.py
- name: Setup Python env
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: black
uses: psf/black@stable
with:
options: "--verbose"
# apply only to changed files (pass explicitly the files)
src: "${{ steps.changed-files.outputs.all_changed_files }}"
version: "~= 24.3"
- name: isort
uses: isort/isort-action@v1
with:
isort-version: "5.13.2"
# reformat all files with isort – safe since the whole repo is already reformatted
configuration: ""
- uses: EndBug/add-and-commit@v9
# Commit changes. Nothing is committed if no changes.
with:
message: Apply isort and black reformatting
commit: --signoff
- name: pylint
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip-docs') }}
run: |
pip install pylint
CHANGED_FILES=$(git diff --name-only --diff-filter=d --merge-base origin/main nemo/ | grep '\.py$' || true)
ADDITIONAL_PYLINT_ARGS=()
echo ${{ github.event.pull_request.labels.*.name }}
pylint ${ADDITIONAL_PYLINT_ARGS[@]} $CHANGED_FILES