feat(kb/lefthook): use remote config

This commit is contained in:
Michele Cereda
2024-04-24 14:00:46 +02:00
parent 8412f624d9
commit 89b7f4f3ef
2 changed files with 71 additions and 4 deletions

View File

@@ -37,10 +37,13 @@ lint:
# ini: &pyinilint # FIXME
# run: pyinilint 'file'
md: &markdownlint
glob: "*.md"
run: >- # '{all_files}' and {files} only include ones managed by git for some reason
files: >-
find . -type 'f'
\( -name '*.md' -or -name '*.markdown' \)
-not \( -path '*/node_modules/*' -or -path '*/venv/*' \)
run: >-
docker run --rm -v "$PWD:/workdir" 'ghcr.io/igorshubovych/markdownlint-cli:latest'
**.md
{files}
yaml: &yamllint
glob: "*.{yaml,yml}"
run: >-
@@ -87,7 +90,7 @@ pre-commit:
<<: *hadolint
run: hadolint {staged_files}
lint-md:
<<: *markdownlint
glob: '*.{markdown,md}'
run: >-
docker run --rm -v "$PWD:/workdir" 'ghcr.io/igorshubovych/markdownlint-cli:latest'
{staged_files}

View File

@@ -2,6 +2,8 @@
1. [TL;DR](#tldr)
1. [Configuration](#configuration)
1. [Extend other files](#extend-other-files)
1. [Use files from other repositories](#use-files-from-other-repositories)
1. [Further readings](#further-readings)
1. [Sources](#sources)
@@ -66,6 +68,68 @@ $ ls -A1 *lefthook*
Configuration files can extend other files recursively.
### Extend other files
```yaml
extends:
- .lefthook/commitlint.yml
- .lefthook/docker.yml
- .lefthook/json.yml
```
### Use files from other repositories
Refer the [configuration] page.
Use the `remotes` key to include configuration files from this repository.<br/>
The configuration from remotes will be merged to the local config using the following priority:
- Local main config (`lefthook.yml`).
- Remote configs (`remotes`).
- Local overrides (`lefthook-local.yml`).
```yaml
# lefthook.yml
lint:
parallel: true
commands:
yaml:
glob: "*.{yaml,yml}"
run: >-
docker run --rm -v "$PWD:/code" 'registry.gitlab.com/pipeline-components/yamllint:latest'
yamllint {all_files}
remotes:
- git_url: https://gitlab.com/mine/oam.git
ref: main
configs:
- quality-assurance/lefthook/commitlint.yml
- quality-assurance/lefthook/docker.yml
- quality-assurance/lefthook/json.yml
```
```yaml
# lefthook-local.yml
no_tty: false
lint:
commands:
yaml:
run: .venv/bin/yamllint {all_files}
```
```sh
$ lefthook dump
lint:
commands:
docker:
run: hadolint {all_files}
glob: "*[Dd]ockerfile*"
yaml:
run: .venv/bin/yamllint {all_files}
glob: "*.{yaml,yml}"
parallel: true
```
## Further readings
- [Github]