Skip to content

Commit

Permalink
[Lint] Add bat version and lint CI permission (#132)
Browse files Browse the repository at this point in the history
1. Add bat version linter for Windows user
2. Add permission setting for third-party actions in lint.yaml to limit
their access
3. Did some research and discussed with @justinchuby, CodeQL **only
hints on the modified file in a PR**, and the error/warning/note are all
informative, and aligned with pylint/mypy which are included in out
lint, so I suggest we can have it for a while, and see how it goes.
(However, disable one or few rules that we don't need in CodeQL seems
doable in the next release:
github/codeql#7937)

fixes #127

Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
  • Loading branch information
titaiwangms and justinchuby committed Sep 28, 2022
1 parent e45e2bd commit 05778ce
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/lint.yaml
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions 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
23 changes: 23 additions & 0 deletions 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
19 changes: 19 additions & 0 deletions 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

0 comments on commit 05778ce

Please sign in to comment.