pre-commit-ci / issues

public issues for https://pre-commit.ci
16 stars 3 forks source link

Feature: allow running some hooks ONLY on pre-commit-ci #100

Closed Guts closed 2 years ago

Guts commented 2 years ago

Perhaps this ticket would be more appropriate on pre-commit rather than on the CI counterpart. Still, I put it here and don't hesitate in moving it if needed.

Currently, pre-commit.ci allows to skip hooks but the idea would be to be able to specify hooks to be executed only on pre-commit.ci but not locally (at least by default).

Use case? I have a heterogeneous team and some hooks require prerequisites (nodejs...) that contributors don't want/need/can't install locally. pre-commit.ci is the ideal response to this situation.

Something like that:

ci:
    only: [markdownlint]
    skip: [pylint]

repos:
  - repo: local
    hooks:
    -   id: pylint
        # ...

  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.29.0
    hooks:
      - id: markdownlint
        # ...

Or, introducing the notion of context directly into pre-commit:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.0.1
    hooks:
      - id: check-added-large-files
        context: all
      - id: check-yaml
        context: all

  - repo: local
    hooks:
    -   id: pylint
        context: local
        # ...

  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.29.0
    hooks:
      - id: markdownlint
        context: ci
        # ...
asottile commented 2 years ago

there is a dosage somewhere, I believe the conclusion was to configure SKIP locally

nodejs should work without any prerequisites though?

Guts commented 2 years ago

there is a dosage somewhere, I believe the conclusion was to configure SKIP locally

If there is an option to skip/ignore a hook for local runs, I buy it!

nodejs should work without any prerequisites though?

They do/can not have NodeJS installed.

Guts commented 2 years ago

Or maybe using stages: [manual]?

asottile commented 2 years ago

pre-commit will bring in node itself if not present

Guts commented 2 years ago

pre-commit will bring in node itself if not present

But not on Windows right? As mentioned into the doc:

new in 1.5.0: windows is now supported for node hooks. Currently python3 only due to a bug in cpython.

asottile commented 2 years ago

even on windows, as your quote says "since 1.5.0" which is years old at this point

Guts commented 2 years ago

Sorry for my misreading... It seems like I'm very tired...

Guts commented 2 years ago

I still think that it would be cool to make the context configurable: local, ci, windows, linux... But I understand that there is some workaround so you can close here @asottile :).