Skip to content

Feature request : add a "fail fast" configuration entry #240

Closed

Description

@Lucas-C

Here is my use case:

  • I have integration tests (in Java + with protractor) that are costly to execute (in term of execution time)
  • when earlier hooks detect issues with the code (e.g. eslint checks), I don't want to execute my integration tests until I've fixed those errors

Btw, I don't ask to change the current behaviour, but could you develop on the reasons behind the design decision to run all tests, indifferently of their outcome ? What are the benefits ?

Activity

  1. asottile commented on Jun 3, 2015

    @asottile
    Member

    The main benefit to running all of the hooks is for fixers. That said, this seems like a reasonable idea. The unfortunate bit is there isn't a good place to put it in .pre-commit-config.yaml without breaking the schema :S

  2. Lucas-C commented on Jun 4, 2015

    @Lucas-C
    ContributorAuthor

    Agreed.
    I can't find the relevant issue but I remember seeing a plan to get rid of the JSON schemas : is that still considered ? And then, should this be pending on json schema removal ?
    Alternatively we could maybe simply extend the schema to allow this optional new field.
    It won't "break" anything in the sense that it will still be backward compatible.

  3. asottile commented on Jun 4, 2015

    @asottile
    Member

    Oh I imagined we would want a top level all-or-nothing option instead of having to repeat it in every hook. The breaking change I was thinking of was changing the config to be a map instead of a list (Which would enable a bunch of other things I've wanted to do). Apis are hard.

    And yeah I'm planning on ditching JSON schema. if we're just adding a property to hooks it's probably not breaking (we've done it in the past)

  4. Lucas-C commented on Jun 4, 2015

    @Lucas-C
    ContributorAuthor

    Ok, I imagined on my part that we could have something like this:

    - config:
      - fail-fast: false
    - repo: local
      hooks:
      - id: do_not_commit
        name: Block if "DO NOT COMMIT" is found
        entry: DO NOT COMMIT
        language: pcre
        files: ''
    - config:
      - timeout: 120s
      - fail-fast: true
    

    (The repetition of the same config property is just here to show a possible edge case, and because I lack imagination :D)

  5. asottile commented on Jun 6, 2015

    @asottile
    Member

    I'd rather have a format that looks like this, though migration will be somewhat difficult:

    fail-fast: true
    repos:
    -   repo: local
        hooks:
        -   id: ...
            ...
  6. asottile commented on Sep 8, 2017

    @asottile
    Member

    This will be available in 1.1.0 (once released) -- I plan to also throw in a couple other things as well into this release.

    The format for failing fast is:

    fail_fast: true
    repos:
    - ...

    as such it is only available with the v2 configuration introduced in 1.0.0

  7. Lucas-C commented on Sep 11, 2017

    @Lucas-C
    ContributorAuthor

    Awesome, thanks !

  8. asottile commented on Sep 11, 2017

    @asottile
    Member

    This is now available in v1.1.0! Thanks again for the issue!

  9. added a commit that references this issue on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions