mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
refactor(lefthook): slice config file into dedicated config files
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
module.exports = {extends: ['@commitlint/config-conventional']}
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
'@commitlint/config-conventional'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
|||||||
/node_modules/
|
/node_modules/
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
|
|
||||||
|
venv/
|
||||||
.venv/
|
.venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
|
|||||||
@@ -6,104 +6,37 @@ skip_output:
|
|||||||
- skips
|
- skips
|
||||||
|
|
||||||
|
|
||||||
|
extends:
|
||||||
|
- lefthook/ansible.yml
|
||||||
|
- lefthook/commitlint.yml
|
||||||
|
- lefthook/docker.yml
|
||||||
|
- lefthook/json.yml
|
||||||
|
- lefthook/kics.yml
|
||||||
|
- lefthook/markdown.yml
|
||||||
|
- lefthook/yaml.yml
|
||||||
|
|
||||||
|
|
||||||
bootstrap:
|
bootstrap:
|
||||||
parallel: true
|
parallel: true
|
||||||
commands:
|
commands:
|
||||||
commitlint:
|
|
||||||
run: npm install --save-dev '@commitlint/cli' '@commitlint/config-conventional'
|
|
||||||
venv:
|
venv:
|
||||||
run: make create-venv
|
run: make create-venv
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
parallel: true
|
parallel: true
|
||||||
commands:
|
|
||||||
commitlint-config:
|
|
||||||
glob: '.commitlintrc.js'
|
|
||||||
run: node_modules/.bin/commitlint --print-config
|
|
||||||
|
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
parallel: true
|
parallel: true
|
||||||
commands:
|
# commands:
|
||||||
ansible: &ansible-lint
|
# ini: &pyinilint # FIXME
|
||||||
files: find . -type f -path "*ansible*" -not -path "*venv*"
|
# run: pyinilint 'file'
|
||||||
glob: '*.{yaml,yml}'
|
|
||||||
run: .venv/bin/ansible-lint {files}
|
|
||||||
docker: &hadolint
|
|
||||||
# The official docker image is based on scratch and only takes only one
|
|
||||||
# input file at a time. I have no clue how to fix that for now so let's
|
|
||||||
# just use the local command.
|
|
||||||
glob: "*Dockerfile*"
|
|
||||||
run: hadolint {all_files}
|
|
||||||
# ini: &pyinilint # FIXME
|
|
||||||
# run: pyinilint 'file'
|
|
||||||
md: &markdownlint
|
|
||||||
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'
|
|
||||||
{files}
|
|
||||||
yaml: &yamllint
|
|
||||||
glob: "*.{yaml,yml}"
|
|
||||||
run: >-
|
|
||||||
docker run --rm -v "$PWD:/code" 'registry.gitlab.com/pipeline-components/yamllint:latest'
|
|
||||||
yamllint {all_files}
|
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
parallel: true
|
parallel: true
|
||||||
commands:
|
commands:
|
||||||
ansible-playbook: &ansible-playbook-syntax-check
|
ansible-playbook:
|
||||||
glob: "*ansible*/play*.{yaml,yml}"
|
glob: "*ansible*/play*.{yaml,yml}"
|
||||||
run: .venv/bin/ansible-playbook -i localhost, --syntax-check {all_files}
|
|
||||||
json: &jq
|
|
||||||
# No official docker image available for now, falling back to the local
|
|
||||||
# command.
|
|
||||||
glob: '*.json'
|
|
||||||
run: jq -r 'input_filename' {all_files}
|
|
||||||
yaml: &yq
|
|
||||||
# Python's one, not mikefarah's.
|
|
||||||
# No official docker image available for now, falling back to the local
|
|
||||||
# command.
|
|
||||||
glob: '*.{yaml,yml}'
|
|
||||||
run: >-
|
|
||||||
echo '{all_files}'
|
|
||||||
| xargs -t .venv/bin/yq '.'
|
|
||||||
|
|
||||||
|
|
||||||
pre-commit:
|
pre-commit:
|
||||||
parallel: true
|
parallel: true
|
||||||
commands:
|
|
||||||
validate-json:
|
|
||||||
<<: *jq
|
|
||||||
run: jq -r 'input_filename' {staged_files}
|
|
||||||
validate-yaml:
|
|
||||||
<<: *yq
|
|
||||||
run: >-
|
|
||||||
.venv/bin/yq '.' {staged_files} > /dev/null
|
|
||||||
&& echo 'All YAML files are readable'
|
|
||||||
validate-ansible-playbooks:
|
|
||||||
<<: *ansible-playbook-syntax-check
|
|
||||||
lint-ansible:
|
|
||||||
<<: *ansible-lint
|
|
||||||
lint-docker:
|
|
||||||
<<: *hadolint
|
|
||||||
run: hadolint {staged_files}
|
|
||||||
lint-md:
|
|
||||||
glob: '*.{markdown,md}'
|
|
||||||
run: >-
|
|
||||||
docker run --rm -v "$PWD:/workdir" 'ghcr.io/igorshubovych/markdownlint-cli:latest'
|
|
||||||
{staged_files}
|
|
||||||
lint-yaml:
|
|
||||||
<<: *yamllint
|
|
||||||
run: >-
|
|
||||||
docker run --rm -v "$PWD:/code" 'registry.gitlab.com/pipeline-components/yamllint:latest'
|
|
||||||
yamllint {staged_files}
|
|
||||||
|
|
||||||
commit-msg:
|
|
||||||
commands:
|
|
||||||
lint: &commitlint
|
|
||||||
# No official docker image available for now, falling back to the local
|
|
||||||
# command.
|
|
||||||
run: node_modules/.bin/commitlint --edit
|
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -3,7 +3,11 @@
|
|||||||
override venv ?= ${shell git rev-parse --show-toplevel}/.venv
|
override venv ?= ${shell git rev-parse --show-toplevel}/.venv
|
||||||
|
|
||||||
create-venv: override python_version ?= 3.11
|
create-venv: override python_version ?= 3.11
|
||||||
create-venv: override python_executable ?= ${shell which --tty-only --show-dot --show-tilde 'python${python_version}'}
|
ifeq "${shell uname}" "Darwin"
|
||||||
|
create-venv: python_executable = ${shell which 'python${python_version}'}
|
||||||
|
else
|
||||||
|
create-venv: python_executable = ${shell which --tty-only --show-dot --show-tilde 'python${python_version}'}
|
||||||
|
endif
|
||||||
create-venv: ${python_executable}
|
create-venv: ${python_executable}
|
||||||
@${python_executable} -m 'venv' '${venv}'
|
@${python_executable} -m 'venv' '${venv}'
|
||||||
@${venv}/bin/pip --require-virtualenv install -r 'requirements.txt'
|
@${venv}/bin/pip --require-virtualenv install -r 'requirements.txt'
|
||||||
|
|||||||
32
lefthook/ansible.yml
Normal file
32
lefthook/ansible.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
# No official docker images are available at the time of writing, falling back to the local command.
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
ansible-lint:
|
||||||
|
run: >-
|
||||||
|
python3 -m 'venv' '.venv'
|
||||||
|
&& .venv/bin/pip install --require-virtualenv 'ansible-lint'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
commands:
|
||||||
|
ansible: &ansible-lint
|
||||||
|
files: find . -type f -path "*ansible*" -not -path "*venv*"
|
||||||
|
glob: '*.{yaml,yml}'
|
||||||
|
run: .venv/bin/ansible-lint {files}
|
||||||
|
|
||||||
|
validate:
|
||||||
|
commands:
|
||||||
|
ansible-playbook: &ansible-playbook-syntax-check
|
||||||
|
glob: "*.{yaml,yml}"
|
||||||
|
run: .venv/bin/ansible-playbook -i 'localhost,' --syntax-check {all_files}
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
lint-ansible:
|
||||||
|
<<: *ansible-lint
|
||||||
|
validate-ansible:
|
||||||
|
<<: *ansible-playbook-syntax-check
|
||||||
|
run: .venv/bin/ansible-playbook -i 'localhost,' --syntax-check {staged_files}
|
||||||
28
lefthook/commitlint.yml
Normal file
28
lefthook/commitlint.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
# No official docker images are available at the time of writing, falling back to the local command.
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
commitlint:
|
||||||
|
run: |-
|
||||||
|
npm install --save-dev '@commitlint/cli' '@commitlint/config-conventional'
|
||||||
|
cat <<EOF > '.commitlintrc.js'
|
||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
'@commitlint/config-conventional'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
debug:
|
||||||
|
commands:
|
||||||
|
commitlint-config:
|
||||||
|
glob: '.commitlintrc.js'
|
||||||
|
run: node_modules/.bin/commitlint --print-config
|
||||||
|
|
||||||
|
|
||||||
|
commit-msg:
|
||||||
|
commands:
|
||||||
|
lint: &commitlint
|
||||||
|
run: node_modules/.bin/commitlint --edit
|
||||||
22
lefthook/docker.yml
Normal file
22
lefthook/docker.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
# Hadolint's official docker image is based on 'scratch', and takes only one input file at a time.
|
||||||
|
# I have no clue how to fix that at the time of writing so let's just use the local command.
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
hadolint:
|
||||||
|
run: brew install 'hadolint'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
commands:
|
||||||
|
docker: &hadolint
|
||||||
|
glob: "*[Dd]ockerfile*"
|
||||||
|
run: hadolint {all_files}
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
lint-docker:
|
||||||
|
<<: *hadolint
|
||||||
|
run: hadolint {staged_files}
|
||||||
24
lefthook/json.yml
Normal file
24
lefthook/json.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
jq:
|
||||||
|
run: docker pull 'ghcr.io/jqlang/jq'
|
||||||
|
|
||||||
|
validate:
|
||||||
|
commands:
|
||||||
|
json: &jq
|
||||||
|
glob: '*.json'
|
||||||
|
run: >-
|
||||||
|
docker run -i --rm -v "${PWD}:/workdir:ro" --workdir '/workdir' 'ghcr.io/jqlang/jq'
|
||||||
|
-r 'input_filename' {all_files}
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
validate-json:
|
||||||
|
<<: *jq
|
||||||
|
run: >-
|
||||||
|
docker run -i --rm -v "${PWD}:/workdir:ro" --workdir '/workdir' 'ghcr.io/jqlang/jq'
|
||||||
|
-r 'input_filename' {staged_files}
|
||||||
20
lefthook/kics.yml
Normal file
20
lefthook/kics.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
kics:
|
||||||
|
run: docker pull 'checkmarx/kics'
|
||||||
|
|
||||||
|
check-compliance:
|
||||||
|
commands:
|
||||||
|
kics: &kics
|
||||||
|
run: >-
|
||||||
|
docker run --rm --name 'kics' -v "$PWD:/app/bin/repository" 'checkmarx/kics'
|
||||||
|
scan -p 'repository'
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
check-compliance:
|
||||||
|
<<: *kics
|
||||||
27
lefthook/markdown.yml
Normal file
27
lefthook/markdown.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
markdownlint:
|
||||||
|
run: docker pull 'ghcr.io/igorshubovych/markdownlint-cli:latest'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
commands:
|
||||||
|
md: &markdownlint
|
||||||
|
files: >-
|
||||||
|
find . -type 'f'
|
||||||
|
\( -name '*.md' -or -name '*.markdown' \)
|
||||||
|
-not \( -path '*/node_modules/*' -or -path '*/*venv/*' \)
|
||||||
|
run: >-
|
||||||
|
docker run --rm -v "$PWD:/workdir:ro" 'ghcr.io/igorshubovych/markdownlint-cli:latest'
|
||||||
|
{files}
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
lint-md:
|
||||||
|
glob: '*.{markdown,md}'
|
||||||
|
run: >-
|
||||||
|
docker run --rm -v "$PWD:/workdir:ro" 'ghcr.io/igorshubovych/markdownlint-cli:latest'
|
||||||
|
{staged_files}
|
||||||
43
lefthook/yaml.yml
Normal file
43
lefthook/yaml.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
# Using the 'yq' flavour available from Python's Pipy, not mikefarah's.
|
||||||
|
# No official docker images are available for 'yq' at the time of writing, falling back to the local command.
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
commands:
|
||||||
|
yamllint:
|
||||||
|
run: docker pull 'registry.gitlab.com/pipeline-components/yamllint:latest'
|
||||||
|
yq:
|
||||||
|
run: >-
|
||||||
|
python3 -m 'venv' '.venv'
|
||||||
|
&& .venv/bin/pip install --require-virtualenv 'yq'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
commands:
|
||||||
|
yaml: &yamllint
|
||||||
|
glob: '*.{yaml,yml}'
|
||||||
|
run: >-
|
||||||
|
docker run --rm -v "$PWD:/code:ro" 'registry.gitlab.com/pipeline-components/yamllint:latest'
|
||||||
|
yamllint {all_files}
|
||||||
|
|
||||||
|
validate:
|
||||||
|
commands:
|
||||||
|
yaml: &yq
|
||||||
|
glob: '*.{yaml,yml}'
|
||||||
|
run: >-
|
||||||
|
echo '{all_files}'
|
||||||
|
| xargs -t .venv/bin/yq '.'
|
||||||
|
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
commands:
|
||||||
|
validate-yaml:
|
||||||
|
<<: *yq
|
||||||
|
run: >-
|
||||||
|
.venv/bin/yq '.' {staged_files} > /dev/null
|
||||||
|
&& echo 'All YAML files are readable'
|
||||||
|
lint-yaml:
|
||||||
|
<<: *yamllint
|
||||||
|
run: >-
|
||||||
|
docker run --rm -v "$PWD:/code:ro" 'registry.gitlab.com/pipeline-components/yamllint:latest'
|
||||||
|
yamllint {staged_files}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.3.0",
|
"@commitlint/cli": "^19.4.0",
|
||||||
"@commitlint/config-conventional": "^19.2.2"
|
"@commitlint/config-conventional": "^19.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ansible==10.1.0
|
ansible==10.3.0
|
||||||
ansible-lint==24.7.0
|
ansible-lint==24.7.0
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
pyinilint==0.17
|
pyinilint==0.17
|
||||||
|
|||||||
Reference in New Issue
Block a user