From d32e4aed4a919dddc4dcdbde2f7e399373ca2f09 Mon Sep 17 00:00:00 2001 From: Ti-Tai Wang Date: Mon, 26 Sep 2022 13:27:07 -0700 Subject: [PATCH 1/4] wrap up lint --- .github/workflows/lint.yaml | 2 ++ tools/format.bat | 19 +++++++++++++++++++ tools/style.bat | 23 +++++++++++++++++++++++ tools/style_optional.bat | 19 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tools/format.bat create mode 100644 tools/style.bat create mode 100644 tools/style_optional.bat diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 72248432a1..033982ab0d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -10,6 +10,8 @@ jobs: lint-python: name: Lint Python runs-on: ubuntu-latest + permissions: + pull_request: write steps: - uses: actions/checkout@v2 - name: Setup Python diff --git a/tools/format.bat b/tools/format.bat new file mode 100644 index 0000000000..a49643f757 --- /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 0000000000..10e57aed89 --- /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 0000000000..d525b43a4a --- /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 From ee7a1a1a61c962b889ebec13503327828d089739 Mon Sep 17 00:00:00 2001 From: AllenTiTaiWang Date: Mon, 26 Sep 2022 16:17:12 -0700 Subject: [PATCH 2/4] full permission update --- .github/workflows/lint.yaml | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 033982ab0d..c8a4b948a1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -11,7 +11,18 @@ jobs: name: Lint Python runs-on: ubuntu-latest permissions: - pull_request: write + actions: write + checks: write + contents: write + deployments: none + id-token: write + issues: write + discussions: write + packages: write + pull-requests: write + repository-projects: none + security-events: none + statuses: write steps: - uses: actions/checkout@v2 - name: Setup Python @@ -37,6 +48,19 @@ jobs: enforce-style: name: Enforce style runs-on: ubuntu-latest + permissions: + actions: write + checks: write + contents: write + deployments: none + id-token: write + issues: write + discussions: write + packages: write + pull-requests: write + repository-projects: none + security-events: none + statuses: write steps: - uses: actions/checkout@v2 - name: Setup Python @@ -63,6 +87,19 @@ jobs: optional-style: name: Optional style runs-on: ubuntu-latest + permissions: + actions: write + checks: write + contents: write + deployments: none + id-token: write + issues: write + discussions: write + packages: write + pull-requests: write + repository-projects: none + security-events: none + statuses: write steps: - uses: actions/checkout@v2 - name: Setup Python From c555c202ab1f53ff99079b2264b681e480c81164 Mon Sep 17 00:00:00 2001 From: AllenTiTaiWang Date: Mon, 26 Sep 2022 18:49:37 -0700 Subject: [PATCH 3/4] try some limitations --- .github/workflows/lint.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c8a4b948a1..dd4075529e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -16,13 +16,13 @@ jobs: contents: write deployments: none id-token: write - issues: write - discussions: write - packages: write + issues: none + discussions: none + packages: none pull-requests: write repository-projects: none security-events: none - statuses: write + statuses: read steps: - uses: actions/checkout@v2 - name: Setup Python From a4f5e67bfe656266a9ce9beabbeb89f99a7fd004 Mon Sep 17 00:00:00 2001 From: AllenTiTaiWang Date: Tue, 27 Sep 2022 09:32:33 -0700 Subject: [PATCH 4/4] delete permissions on non 3rd party actions --- .github/workflows/lint.yaml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index dd4075529e..2217474d7d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -48,19 +48,6 @@ jobs: enforce-style: name: Enforce style runs-on: ubuntu-latest - permissions: - actions: write - checks: write - contents: write - deployments: none - id-token: write - issues: write - discussions: write - packages: write - pull-requests: write - repository-projects: none - security-events: none - statuses: write steps: - uses: actions/checkout@v2 - name: Setup Python @@ -87,19 +74,6 @@ jobs: optional-style: name: Optional style runs-on: ubuntu-latest - permissions: - actions: write - checks: write - contents: write - deployments: none - id-token: write - issues: write - discussions: write - packages: write - pull-requests: write - repository-projects: none - security-events: none - statuses: write steps: - uses: actions/checkout@v2 - name: Setup Python