Skip to content

Commit 87fe41e

Browse files
committed
For release v0.5
1 parent da61cdf commit 87fe41e

File tree

4 files changed

+28
-43
lines changed

4 files changed

+28
-43
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
# pre-commit hooks for Swimm
22

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).
44

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.
66

77
## For Those That Don't Need To Modify The Hooks:
88

99
If you don't need to modify any of the hooks, you can simply pull in the hook configurations from this repository.
1010

1111
Put the following contents into `.pre-commit-config.yaml` in the root of your repository (create it if needed):
1212

13-
```
13+
```yml
1414
repos:
1515
- 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)
1717
hooks:
1818
- id: swimm-verify # Verifies documentation is in sync
1919
```
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).
2821

2922
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.
3023

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.
3225

3326
## For Those Who Want To Modify The Hooks
3427

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:
3729

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+
```
3837

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.

hooks/README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,30 @@
22

33
- `swimm-verify` will run Swimm's verification checks, and exit nonzero if they fail. Recommended.
44
- `swimm-verify-nonblocking` (v0.4 only) Like swimm-verify, but will always return successfully. Webooks are used to open an issue if verification fails.
5-
- `swimm-export` An example of exporting Swimm docs for third-party documentation hubs like Confluence & Notion
65

76
All hooks will currently work with the web or desktop version of swimm. If you
87
don't have the CLI component, the hook will download it for you and clean up
98
after it runs.
109

1110
If you use the web version, you'll need `curl` and `wget` installed.
1211

12+
If the environmental variable `SWIMM_VERIFY_WEBHOOK` is set, the scripts will
13+
send a POST request to the URL with the field `context` containing the output
14+
of the `swimm_cli verify` command. This is useful for build automation, such
15+
as automatically opening an issue if the non-blocking hook fails.
16+
17+
An example of how this can be automated is given as a ["Zap" template at Zapier](https://zapier.com),
18+
which consists of a webhook that creates a card on a Trello board. You can switch
19+
the Trello part for Github, Jira, BitBucket and *most* other forges.
20+
1321
## The `swimm-verify` Hook:
1422

1523
This is the simplest (and most ideal) configuration. The verification check will
1624
return nonzero if something requires attention. Documentation failing verification
1725
will be treated just like any other test that fails.
1826

19-
## The `swimm-verify-nonblocking` Hook (v0.4 only):
20-
21-
This hook allows documentation verification checks to proceed, and will (optionally)
22-
call a webhook that opens an issue at Github, Bitbucket, Jira, Trello Or anything
23-
else that has an API using [Zapier](http://zapier.com).
24-
25-
We have a template you can use to set this up quickly at:
26-
27-
https://zapier.com/shared/82c84601a5f678127c6cada740e64279c7fdd274
28-
29-
But any webook conveniently accessed with curl will work.
30-
31-
32-
To set it up:
33-
34-
1. Start with the template linked above. Grab your unique webhook URL.
35-
2. Change the workflow to open the issue whereever it works for you.
36-
3. Make sure anyone using the extension has the environmental variable `SWIMM_VERIFY_WEBHOOK` set to the webhook URL.
37-
4. If the verification fails, the webhook will open an issue with the output letting you know what needs fixed.
38-
39-
## The `swimm-export` Hook:
27+
## The `swimm-verify-nonblocking` Hook (v0.4+ only):
4028

41-
This hook demonstrates exporting Swimm documentation to other formats for
42-
publishing in other knowledge collections like Docusaurus, Notion, Confluence
43-
and others. This is only currently usable for the Desktop version.
29+
This hook is just like `swimm-verify`, but it will always exit successfully, even if
30+
the documentation verification check fails. If used on a conunction with a webhook,
31+
you can let the build proceed and create an issue with a deadline to complete.

hooks/swimm-verify-nonblocking.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ webhook() {
7474
warn "Could not read enviormental variable SWIMM_VERIFY_WEBHOOK so I don't know who to call."
7575
return
7676
}
77-
printf "Hi! I'm Webhook!\nContext is:\n%s\nDialing: %s\n" "$@" "$SWIMM_VERIFY_WEBHOOK"
7877
$BIN_CURL --data "context=$@" $SWIMM_VERIFY_WEBHOOK | grep success 2>&1 >/dev/null
7978
if [ $? -eq 0 ]; then
8079
printf "Webhook succeeded!"

hooks/swimm-verify.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ webhook() {
7575
warn "Could not read enviormental variable SWIMM_VERIFY_WEBHOOK so I don't know who to call."
7676
return
7777
}
78-
printf "Hi! I'm Webhook!\nContext is:\n%s\nDialing: %s\n" "$@" "$SWIMM_VERIFY_WEBHOOK"
7978
$BIN_CURL --data "context=$@" $SWIMM_VERIFY_WEBHOOK | grep success 2>&1 >/dev/null
8079
if [ $? -eq 0 ]; then
8180
printf "Webhook succeeded!"

0 commit comments

Comments
 (0)