|
1 | 1 | # pre-commit hooks for Swimm |
2 | 2 |
|
3 | | -Utilizing [pre-commit](https://pre-commit.com/), you can enable Swimm checks to run prior to the review cycle. In order to get started, you'll need to [install pre-commit](https://pre-commit.com/#install) (pip, brew and other methods are available). |
| 3 | +Utilizing [pre-commit](https://pre-commit.com/), you can enable Swimm checks to run locally with other lints, prior to the PR review cycle. In order to get started, you'll need to [install pre-commit](https://pre-commit.com/#install) (pip, brew and other methods are available). |
4 | 4 |
|
5 | | -After that, there are two ways you can make use of the hooks hosted here: |
| 5 | +Then, select which hook you want to run. **Most** users won't need to modify the. |
6 | 6 |
|
7 | 7 | ## For Those That Don't Need To Modify The Hooks: |
8 | 8 |
|
9 | 9 | If you don't need to modify any of the hooks, you can simply pull in the hook configurations from this repository. |
10 | 10 |
|
11 | 11 | Put the following contents into `.pre-commit-config.yaml` in the root of your repository (create it if needed): |
12 | 12 |
|
13 | | -``` |
| 13 | +```yml |
14 | 14 | repos: |
15 | 15 | - repo: https://github.com/swimmio/pre-commit |
16 | | - rev: v0.3 # (Check release tags for the latest release, current preview release is v0.4) |
| 16 | + rev: v0.5 # (Check release tags for the latest release, current is v0.5) |
17 | 17 | hooks: |
18 | 18 | - id: swimm-verify # Verifies documentation is in sync |
19 | 19 | ``` |
20 | | -That should be all you need if you just want to run the verification checks locally, and treat failure like any other test failing. |
21 | | - |
22 | | -There are two more hooks explained in [hooks/](https://github.com/swimmio/pre-commit/tree/main/hooks) which you can optionally enable: |
23 | | - |
24 | | -``` |
25 | | - - id: swimm-verify-nonblocking # Verifies documentation but doesn't block, opens an issue instead. |
26 | | - - id: swimm-export # (Illustrative only) Shows how you could set up your existing hooks to export your documentation to Docusaurus, Notion, Etc. |
27 | | -``` |
| 20 | +That should be all you need if you just want to run the verification checks locally, and treat failure like any other test failing. If you need to open an issue instead of failing, use `swimm-verify-nonblocking` as described in [hooks/](https://github.com/swimmio/pre-commit/tree/main/hooks). |
28 | 21 |
|
29 | 22 | If you already have a `.pre-commit-config.yaml` file, add the swimm checks as a new `- repo` section, wherever you'd like them to run. Note that if you have failure mode set to fast, no other checks will run if documentation can't be verified, so we recommend adding Swimm as the last (or close to last) check. |
30 | 23 |
|
31 | | -Note: The hooks are currently implemented as bash scripts; Windows users need to run WSL in order to use them for now. I'm planning to do it agnostically just with Python in the near future. |
| 24 | +Note: The hooks are currently implemented as bash scripts; Windows users need to run WSL in order to use them for now. |
32 | 25 |
|
33 | 26 | ## For Those Who Want To Modify The Hooks |
34 | 27 |
|
35 | | -Fork this repository to your orgainzation, make the changes you want, and tag in a release for your team to use. Then, your team will need to |
36 | | -point their configuration files to the forked repo (and specify your version) rather than pointing them here. |
| 28 | +Grab the script in [hooks/](https://github.com/swimmio/pre-commit/tree/main/hooks) that you want to use as a base, and just include it in your own pre-commit repository. Your configuration will look something like this: |
37 | 29 |
|
| 30 | +```yml |
| 31 | +repos: |
| 32 | + - repo: https://github.com/your-organization/your-pre-commit-repo |
| 33 | + rev: vX.Y # (Your version nuymbers) |
| 34 | + hooks: |
| 35 | + - id: swimm-verify |
| 36 | +``` |
38 | 37 |
|
39 | | -If you create any new hooks that you think others might find useful, feel free to send over a PR. |
| 38 | +You can also fork this repository to your own organization, commit whatever changes you wish to make, and then tag in a new release for your teammates to use. |
0 commit comments