-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-2.25] pre-commit: make hooks self contained + ci config (#11359
) * Use alternate self-sufficient shellcheck precommit This pre-commit does not require prerequisite on the host, making it easier to run in CI workflows. * Switch to upstream ansible-lint pre-commit hook This way, the hook is self contained and does not depend on a previous virtualenv installation. * pre-commit: fix hooks dependencies - ansible-syntax-check - tox-inventory-builder - jinja-syntax-check * Fix ci-matrix pre-commit hook - Remove dependency of pydblite which fails to setup on recent pythons - Discard shell script and put everything into pre-commit * pre-commit: apply autofixes hooks and fix the rest manually - markdownlint (manual fix) - end-of-file-fixer - requirements-txt-fixer - trailing-whitespace * Convert check_typo to pre-commit + use maintained version client9/misspell is unmaintained, and has been forked by the golangci team, see client9/misspell#197 (comment). They haven't yet added a pre-commit config, so use my fork with the pre-commit hook config until the pull request is merged. * collection-build-install convert to pre-commit * Run pre-commit hooks in dynamic pipeline Use gitlab dynamic child pipelines feature to have one source of truth for the pre-commit jobs, the pre-commit config file. Use one cache per pre-commit. This should reduce the "fetching cache" time steps in gitlab-ci, since each job will have a separate cache with only its hook installed. * Remove gitlab-ci job done in pre-commit * pre-commit: adjust mardownlint default, md fixes Use a style file as recommended by upstream. This makes for only one source of truth. Conserve previous upstream default for MD007 (upstream default changed here markdownlint/markdownlint#373) * Update pre-commit hooks --------- Co-authored-by: Max Gautier <[email protected]>
- Loading branch information
1 parent
8d80b99
commit 9b122fb
Showing
58 changed files
with
151 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
--- | ||
yamllint: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
variables: | ||
LANG: C.UTF-8 | ||
script: | ||
- yamllint --strict . | ||
except: ['triggers', 'master'] | ||
generate-pre-commit: | ||
image: 'mikefarah/yq@sha256:bcb889a1f9bdb0613c8a054542d02360c2b1b35521041be3e1bd8fbd0534d411' | ||
stage: build | ||
before_script: [] | ||
script: | ||
- > | ||
yq -r < .pre-commit-config.yaml '.repos[].hooks[].id' | | ||
sed 's/^/ - /' | | ||
cat .gitlab-ci/pre-commit-dynamic-stub.yml - > pre-commit-generated.yml | ||
artifacts: | ||
paths: | ||
- pre-commit-generated.yml | ||
|
||
run-pre-commit: | ||
stage: unit-tests | ||
trigger: | ||
include: | ||
- artifact: pre-commit-generated.yml | ||
job: generate-pre-commit | ||
strategy: depend | ||
|
||
vagrant-validate: | ||
extends: .job | ||
|
@@ -19,108 +30,11 @@ vagrant-validate: | |
- ./tests/scripts/vagrant-validate.sh | ||
except: ['triggers', 'master'] | ||
|
||
ansible-lint: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
script: | ||
- ansible-lint -v | ||
except: ['triggers', 'master'] | ||
|
||
jinja-syntax-check: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
script: | ||
- "find -name '*.j2' -exec tests/scripts/check-templates.py {} +" | ||
except: ['triggers', 'master'] | ||
|
||
syntax-check: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
variables: | ||
ANSIBLE_INVENTORY: inventory/local-tests.cfg | ||
ANSIBLE_REMOTE_USER: root | ||
ANSIBLE_BECOME: "true" | ||
ANSIBLE_BECOME_USER: root | ||
ANSIBLE_VERBOSITY: "3" | ||
script: | ||
- ansible-playbook --syntax-check cluster.yml | ||
- ansible-playbook --syntax-check playbooks/cluster.yml | ||
- ansible-playbook --syntax-check upgrade-cluster.yml | ||
- ansible-playbook --syntax-check playbooks/upgrade_cluster.yml | ||
- ansible-playbook --syntax-check reset.yml | ||
- ansible-playbook --syntax-check playbooks/reset.yml | ||
- ansible-playbook --syntax-check extra_playbooks/upgrade-only-k8s.yml | ||
except: ['triggers', 'master'] | ||
|
||
collection-build-install-sanity-check: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
variables: | ||
ANSIBLE_COLLECTIONS_PATH: "./ansible_collections" | ||
script: | ||
- ansible-galaxy collection build | ||
- ansible-galaxy collection install kubernetes_sigs-kubespray-$(grep "^version:" galaxy.yml | awk '{print $2}').tar.gz | ||
- ansible-galaxy collection list $(egrep -i '(name:\s+|namespace:\s+)' galaxy.yml | awk '{print $2}' | tr '\n' '.' | sed 's|\.$||g') | grep "^kubernetes_sigs.kubespray" | ||
- test -f ansible_collections/kubernetes_sigs/kubespray/playbooks/cluster.yml | ||
- test -f ansible_collections/kubernetes_sigs/kubespray/playbooks/reset.yml | ||
except: ['triggers', 'master'] | ||
|
||
tox-inventory-builder: | ||
stage: unit-tests | ||
tags: [light] | ||
extends: .job | ||
before_script: | ||
- ./tests/scripts/rebase.sh | ||
script: | ||
- pip3 install tox | ||
- cd contrib/inventory_builder && tox | ||
except: ['triggers', 'master'] | ||
|
||
markdownlint: | ||
stage: unit-tests | ||
tags: [light] | ||
image: node | ||
before_script: | ||
- npm install -g [email protected] | ||
script: | ||
- markdownlint $(find . -name '*.md' | grep -vF './.git') --ignore docs/_sidebar.md --ignore contrib/dind/README.md | ||
|
||
generate-sidebar: | ||
extends: .job | ||
stage: unit-tests | ||
tags: [light] | ||
script: | ||
- scripts/gen_docs_sidebar.sh | ||
- git diff --exit-code | ||
|
||
check-readme-versions: | ||
stage: unit-tests | ||
tags: [light] | ||
image: python:3 | ||
script: | ||
- tests/scripts/check_readme_versions.sh | ||
|
||
# TODO: convert to pre-commit hook | ||
check-galaxy-version: | ||
stage: unit-tests | ||
tags: [light] | ||
image: python:3 | ||
script: | ||
- tests/scripts/check_galaxy_version.sh | ||
|
||
check-typo: | ||
stage: unit-tests | ||
tags: [light] | ||
image: python:3 | ||
script: | ||
- tests/scripts/check_typo.sh | ||
|
||
ci-matrix: | ||
stage: unit-tests | ||
tags: [light] | ||
image: python:3 | ||
script: | ||
- tests/scripts/md-table/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
# stub pipeline for dynamic generation | ||
pre-commit: | ||
tags: | ||
- light | ||
image: 'ghcr.io/pre-commit-ci/runner-image@sha256:aaf2c7b38b22286f2d381c11673bec571c28f61dd086d11b43a1c9444a813cef' | ||
variables: | ||
PRE_COMMIT_HOME: /pre-commit-cache | ||
script: | ||
- pre-commit run -a $HOOK_ID | ||
cache: | ||
key: pre-commit-$HOOK_ID | ||
paths: | ||
- /pre-commit-cache | ||
parallel: | ||
matrix: | ||
- HOOK_ID: |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
all | ||
exclude_rule 'MD013' | ||
exclude_rule 'MD029' | ||
rule 'MD007', :indent => 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
style "#{File.dirname(__FILE__)}/.md_style.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ server_groups = { | |
# ] | ||
# anti_affinity_policy = "yes" | ||
# } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,4 +106,4 @@ variable "server_groups" { | |
anti_affinity_policy = string | ||
servers = list(string) | ||
})) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ server_groups = { | |
# ] | ||
# anti_affinity_policy = "yes" | ||
# } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
# OpenStack | ||
|
||
## Known compatible public clouds | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.