diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 72248432a..2217474d7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -10,6 +10,19 @@ jobs: lint-python: name: Lint Python runs-on: ubuntu-latest + permissions: + actions: write + checks: write + contents: write + deployments: none + id-token: write + issues: none + discussions: none + packages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: read steps: - uses: actions/checkout@v2 - name: Setup Python diff --git a/tools/format.bat b/tools/format.bat new file mode 100644 index 000000000..a49643f75 --- /dev/null +++ b/tools/format.bat @@ -0,0 +1,19 @@ +:: SPDX-License-Identifier: Apache-2.0 + +@echo off +:: This script helps Windows user to format the code +::before submitting the PR + +for /f %%i in ('git rev-parse --show-toplevel') do set root_path=%%i +ECHO "Git Root PATH: %root_path%" +CD /D %root_path% + +ECHO "\nblack reformatting..." +black . --color +ECHO "\nblack done!" + +ECHO "\nisort reformatting..." +isort . --color +ECHO "\nisort done!" + +PAUSE \ No newline at end of file diff --git a/tools/style.bat b/tools/style.bat new file mode 100644 index 000000000..10e57aed8 --- /dev/null +++ b/tools/style.bat @@ -0,0 +1,23 @@ +:: SPDX-License-Identifier: Apache-2.0 + +@echo off +:: This script helps Windows user to check formatting +::before submitting the PR + +for /f %%i in ('git rev-parse --show-toplevel') do set root_path=%%i +ECHO "Git Root PATH: %root_path%" +CD /D %root_path% + +ECHO "\n::group:: ===> check flake8..." +flake8 onnxscript +ECHO "::endgroup::" + +ECHO "\n::group:: ===> check isort..." +isort . --color --diff --check +ECHO "::endgroup::" + +ECHO "\n::group:: ===> check black format..." +black . --color --diff --check +ECHO "::endgroup::" + +PAUSE \ No newline at end of file diff --git a/tools/style_optional.bat b/tools/style_optional.bat new file mode 100644 index 000000000..d525b43a4 --- /dev/null +++ b/tools/style_optional.bat @@ -0,0 +1,19 @@ +:: SPDX-License-Identifier: Apache-2.0 + +@echo off +:: This script helps Windows user to check formatting +::before submitting the PR + +for /f %%i in ('git rev-parse --show-toplevel') do set root_path=%%i +ECHO "Git Root PATH: %root_path%" +CD /D %root_path% + +ECHO "\n::group:: ===> check pylint" +pylint onnxscript +ECHO "::endgroup::" + +ECHO "\n::group:: ===> check mypy" +mypy onnxscript --config-file pyproject.toml +ECHO "::endgroup::" + +PAUSE