Skip to content

Commit bf3d905

Browse files
authored
Add another validate-config hook (#38)
to run `packit validate-config` directly. The previously added `validate-config` hook has been renamed to `validate-config-in-container`. Fixes #36
2 parents c4da9b7 + b77c319 commit bf3d905

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
language: script
66
always_run: true
77
args: [upstream_url]
8+
89
- id: validate-config
10+
name: Validate package config
11+
description: Check for missing values and incorrect types
12+
entry: ./pre-commit-hooks/validate-config.sh
13+
language: script
14+
files: ^\.?packit.ya?ml$
15+
16+
- id: validate-config-in-container
917
name: Validate package config
1018
description: Check for missing values and incorrect types
1119
entry: quay.io/packit/packit:latest packit -d validate-config

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,38 @@ Our repo for managing pre-commit hooks
33

44
### Our hooks
55

6-
- `check-rebase` - Check if your branch is up to date with the upstream.
6+
- `check-rebase` - Check if your branch is up-to-date with the upstream.
77
- Specify the url of the upstream repo in `args: [git://github...]`.
8-
8+
- `validate-config` - Validate a [package config for Packit](https://packit.dev/docs/configuration).
9+
- Requires `bash`.
10+
- Runs the validation if there's a `packit` binary present.
11+
- Passes if `packit` is not installed; this is useful if you can't install `packit` in the CI but still want to run the hook at least locally.
12+
- `validate-config-in-container` - Validate a [package config for Packit](https://packit.dev/docs/configuration).
13+
- Uses [packit image](https://quay.io/repository/packit/packit) to run packit in a container.
14+
- Requires `docker` binary to be present, which can be a problem for example in [pre-commit.ci](https://github.com/pre-commit-ci/issues/issues/11)
915

1016
### Using check-rebase with pre-commit
1117

1218
Add this to your `.pre-commit-config.yaml`
1319

1420
- repo: https://github.com/packit/pre-commit-hooks
15-
rev: the revision or tag to clone at
21+
rev: v1.2.0
1622
hooks:
17-
- id: check-rebase
23+
- id: check-rebase
1824
args: [upstream_url]
25+
26+
### Using validate-config with pre-commit
27+
28+
Add this to your `.pre-commit-config.yaml`
29+
30+
- repo: https://github.com/packit/pre-commit-hooks
31+
rev: v1.2.0
32+
hooks:
33+
- id: validate-config
34+
35+
or
36+
37+
- repo: https://github.com/packit/pre-commit-hooks
38+
rev: v1.2.0
39+
hooks:
40+
- id: validate-config-in-container
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/bash
2+
3+
set -eu
4+
5+
if command -v packit; then
6+
packit -d validate-config
7+
else
8+
echo "packit not installed, can't validate the config"
9+
echo "either install packit or try the validate-config-in-container hook"
10+
fi

0 commit comments

Comments
 (0)