From 8a792d9a509911e3abbd5085448da63b3b9906f4 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 7 Apr 2022 21:22:59 -0500 Subject: [PATCH 1/2] clean up pre-commit --- .github/workflows/python-tests.yml | 20 ++++++++++++++++++ .github/workflows/trigger_precommit.yml | 27 ------------------------- .pre-commit-config.yaml | 6 +++--- CONTRIBUTING.rst | 5 ++++- 4 files changed, 27 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/trigger_precommit.yml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 1491e21c60..b57377dd46 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -43,6 +43,26 @@ jobs: run: | codecov + pre-commit: + name: pre-commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: pre-commit/action@v2.0.0 + with: + extra_args: --all-files --hook-stage=manual + - name: Help message if pre-commit fail + if: ${{ failure() }} + run: | + echo "You can install pre-commit hooks to automatically run formatting" + echo "on each commit with:" + echo " pre-commit install" + echo "or you can run by hand on staged files with" + echo " pre-commit run" + echo "or after-the-fact on already committed files with" + echo " pre-commit run --all-files --hook-stage=manual" + test_docs_and_examples: name: Test Docs and Examples timeout-minutes: 10 diff --git a/.github/workflows/trigger_precommit.yml b/.github/workflows/trigger_precommit.yml deleted file mode 100644 index 89a16ee339..0000000000 --- a/.github/workflows/trigger_precommit.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Trigger Pre-Commit on a PR -on: - issue_comment: - types: [created] - -permissions: - contents: write - pull-requests: write - -jobs: - pr-script: - runs-on: ubuntu-latest - steps: - - uses: khan/pull-request-comment-trigger@1.0.0 - id: check - with: - trigger: "auto run pre-commit" - - if: steps.check.outputs.triggered == 'true' - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - if: steps.check.outputs.triggered == 'true' - uses: jupyterlab/maintainer-tools/.github/actions/pr-script@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - pre_commit: true - commit_message: "auto run pre-commit" - target: ${{ github.event.issue.html_url }} - association: ${{ github.event.comment.author_association }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 296eccfe8d..7a0522db7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,3 @@ -ci: - skip: [check-jsonschema] - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 @@ -47,6 +44,7 @@ repos: hooks: - id: doc8 args: [--max-line-length=200] + stages: [manual] - repo: https://github.com/pycqa/flake8 rev: 4.0.1 @@ -58,6 +56,7 @@ repos: "flake8-logging-format==0.6.0", "flake8-implicit-str-concat==0.2.0", ] + stages: [manual] - repo: https://github.com/pre-commit/mirrors-eslint rev: v8.12.0 @@ -72,3 +71,4 @@ repos: files: ^\.github/workflows/ types: [yaml] args: ["--schemafile", "https://json.schemastore.org/github-workflow"] + stages: [manual] diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 9f643ebb2a..d97a2606e8 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -59,7 +59,7 @@ You can invoke the pre-commit hook by hand at any time with:: which should run any autoformatting on your code and tell you about any errors it couldn't fix automatically. -You may also install [black integration](https://github.com/psf/black#editor-integration) +You may also install `black integration `_ into your text editor to format code automatically. If you have already committed files before setting up the pre-commit @@ -67,6 +67,9 @@ hook with ``pre-commit install``, you can fix everything up using ``pre-commit run --all-files``. You need to make the fixing commit yourself after that. +Some of the hooks only run on CI by default, but you can invoke them by +running with the ``--hook-stage manual`` argument. + Troubleshooting the Installation -------------------------------- From 18c2a92656e31c24b2ee628c9967cd939b8849da Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 7 Apr 2022 21:33:20 -0500 Subject: [PATCH 2/2] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a0522db7e..f7b174cef3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,6 +62,7 @@ repos: rev: v8.12.0 hooks: - id: eslint + stages: [manual] - repo: https://github.com/sirosen/check-jsonschema rev: 0.14.2