Skip to content

Commit

Permalink
ci(PRE-COMMIT): update to cicd-tools 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Mar 20, 2024
1 parent 164efb1 commit 8424f47
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/job-50-test-precommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ util() {
main() {

pushd "${TEST_PROJECT_NAME}" >> /dev/null
poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
poetry run pre-commit run --hook-stage manual spelling-vale-sync
scenario "${1}"
popd >> /dev/null

Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/workflow-cookiecutter-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,27 @@ jobs:
COMMAND: |
CICD_COMMIT_MESSAGES_FILE="$(mktemp XXXXXXXX.git_history_file)"
git log --pretty=format:%s "${PUSHED_COMMIT_REV_RANGE}" > "${CICD_COMMIT_MESSAGES_FILE}"
poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
poetry run pre-commit run --hook-stage manual spelling-vale-sync
poetry run pre-commit run --hook-stage commit-msg spelling-commit-message --commit-msg-filename "${CICD_COMMIT_MESSAGES_FILE}"
COMMAND_NAME: "Commit Message Spelling"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"

git_conflict_markers:
needs: [configuration]
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: "git-conflict-markers"
PRECOMMIT_HOOK_NAME: "Git conflict markers"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"

json_metaschema_lint:
needs:
- configuration
Expand Down Expand Up @@ -159,7 +172,7 @@ jobs:
uses: ./.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRE_HOOK_COMMAND: poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
PRE_HOOK_COMMAND: poetry run pre-commit run --hook-stage manual spelling-vale-sync
PRECOMMIT_HOOK_ID: "spelling-markdown"
PRECOMMIT_HOOK_NAME: "Markdown Spelling"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
Expand Down Expand Up @@ -189,6 +202,19 @@ jobs:
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"

spelling_vocabularies:
needs: [configuration]
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: "spelling-vale-vocab"
PRECOMMIT_HOOK_NAME: "Spelling vocabularies"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"

toml_lint:
needs:
- configuration
Expand Down Expand Up @@ -249,6 +275,7 @@ jobs:
- commit_lint
- commit_spell_check
- commitizen_hooks
- git_conflict_markers
- json_metaschema_lint
- json_schema_lint
- markdown_links
Expand All @@ -257,6 +284,7 @@ jobs:
- pre-commit_hooks
- security
- shell_lint
- spelling_vocabularies
- start
- toml_lint
- workflow_lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-meta_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ jobs:
COMMAND: |
CICD_COMMIT_MESSAGES_FILE="$(mktemp XXXXXXXX.git_history_file)"
git log --pretty=format:%s "${PUSHED_COMMIT_REV_RANGE}" > "${CICD_COMMIT_MESSAGES_FILE}"
poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
poetry run pre-commit run --hook-stage manual spelling-vale-sync
poetry run pre-commit run --hook-stage commit-msg spelling-commit-message --commit-msg-filename "${CICD_COMMIT_MESSAGES_FILE}"
COMMAND_NAME: "Commit Message Spelling"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
Expand Down
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/cicd-tools-org/pre-commit.git
rev: 0.4.0
rev: 0.5.0
hooks:
- id: format-shell
args:
Expand All @@ -32,6 +32,7 @@ repos:
- "-ci"
- "-sr"
exclude: "^{{cookiecutter\\.project_slug}}/.+$|^\\.cicd-tools/boxes/.+$"
- id: git-conflict-markers
- id: format-toml
- id: lint-github-workflow
exclude: "^{{cookiecutter\\.project_slug}}/.+$"
Expand All @@ -53,7 +54,8 @@ repos:
- id: spelling-commit-message
- id: spelling-markdown
exclude: "^{{cookiecutter\\.project_slug}}/.+$"
- id: spelling-vale-synchronize
- id: spelling-vale-sync
- id: spelling-vale-vocab
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
Expand All @@ -63,10 +65,3 @@ repos:
- "./{{cookiecutter.project_slug}}/.yamllint.yml"
exclude: "^{{cookiecutter\\.project_slug}}/.+$"
stages: [commit]
- repo: local
hooks:
- id: spelling-vale-vocab
name: "spelling-vale-vocab"
entry: /bin/bash -c 'for FILE in "$@"; do sort -u -o ${FILE} ${FILE}; done' --
files: "^.vale/Vocab/.+/(accept|reject)\\.txt$"
language: system
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
#!/usr/bin/make -f

.PHONY: help fmt lint format-shell format-toml lint-markdown lint-shell lint-workflows lint-yaml security spelling
.PHONY: help clean fmt lint security spelling clean-fit format-shell format-toml lint-markdown lint-shell lint-workflows lint-yaml security-leaks spelling-add spelling-markdown spelling-sync

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " fmt to format all files"
@echo " lint to lint all files"
@echo " clean-git to run git clean"
@echo " format-shell to format shell scripts"
@echo " format-toml to format TOML files"
@echo " lint-markdown to lint Markdown files"
@echo " lint-shell to lint shell scripts"
@echo " lint-workflows to lint GitHub workflows"
@echo " lint-yaml to lint YAML files"
@echo " security to check for credential leaks"
@echo " spelling to check spelling"

@echo " security-leaks to check for credential leaks"
@echo " spelling-add to add a regex to the ignore patterns"
@echo " spelling-markdown to spellcheck markdown files"
@echo " spelling-sync to synchronize vale packages"

clean: clean-git
fmt: format-shell format-toml
hog: security
lint: lint-markdown lint-shell lint-workflows lint-yaml
security: security-leaks
spelling: spelling-markdown

clean-git:
@echo "Cleaning git content ..."
@git clean -fd
@echo "Done."

format-shell:
@echo "Checking shell scripts ..."
Expand Down Expand Up @@ -51,12 +58,21 @@ lint-yaml:
@poetry run bash -c "pre-commit run yamllint --all-files --verbose"
@echo "Done."

security:
spelling-add:
@echo "Adding word ..."
@echo "${MAKE_ARGS}" >> ".vale/Vocab/${PROJECT_NAME}/accept.txt"
@sort -u -o ".vale/Vocab/${PROJECT_NAME}/accept.txt" ".vale/Vocab/${PROJECT_NAME}/accept.txt"

security-leaks:
@echo "Checking security ..."
@poetry run bash -c "pre-commit run security-credentials --all-files --verbose"
@echo "Done."

spelling:
spelling-markdown:
@echo "Checking spelling ..."
@poetry run bash -c "pre-commit run spelling-markdown --all-files --verbose"
@echo "Done."

spelling-sync:
@echo "Synchronizing vale ..."
@poetry run bash -c "pre-commit run --hook-stage manual spelling-vale-synchronize --all-files --verbose"
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ util() {
main() {

pushd "${TEST_PROJECT_NAME}" >> /dev/null
poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
poetry run pre-commit run --hook-stage manual spelling-vale-sync
scenario "${1}"
popd >> /dev/null

Expand Down
32 changes: 30 additions & 2 deletions {{cookiecutter.project_slug}}/.github/workflows/workflow-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,27 @@ jobs:
COMMAND: |
CICD_COMMIT_MESSAGES_FILE="$(mktemp XXXXXXXX.git_history_file)"
git log --pretty=format:%s "${PUSHED_COMMIT_REV_RANGE}" > "${CICD_COMMIT_MESSAGES_FILE}"
poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
poetry run pre-commit run --hook-stage manual spelling-vale-sync
poetry run pre-commit run --hook-stage commit-msg spelling-commit-message --commit-msg-filename "${CICD_COMMIT_MESSAGES_FILE}"
COMMAND_NAME: "Commit Message Spelling"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_concurrency_limit }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_python_versions) }}
REV_RANGE: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_commit_spelling_rev_range }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_verbose_notifications }}

git_conflict_markers:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: cicd-tools-org/cicd-tools/.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml@main
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_concurrency_limit }}
PRECOMMIT_HOOK_ID: "git-conflict-markers"
PRECOMMIT_HOOK_NAME: "Git conflict markers"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_python_versions) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_verbose_notifications }}

json_schema_lint:
needs:
- configuration
Expand Down Expand Up @@ -130,7 +143,7 @@ jobs:
uses: cicd-tools-org/cicd-tools/.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml@main
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_concurrency_limit }}
PRE_HOOK_COMMAND: poetry run pre-commit run --hook-stage manual spelling-vale-synchronize
PRE_HOOK_COMMAND: poetry run pre-commit run --hook-stage manual spelling-vale-sync
PRECOMMIT_HOOK_ID: "spelling-markdown"
PRECOMMIT_HOOK_NAME: "Markdown Spelling"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_python_versions) }}
Expand Down Expand Up @@ -158,6 +171,19 @@ jobs:
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_python_versions) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_verbose_notifications }}

spelling_vocabularies:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: cicd-tools-org/cicd-tools/.github/workflows/job-80-poetry-precommit_commit_stage_hook.yml@main
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_concurrency_limit }}
PRECOMMIT_HOOK_ID: "spelling-vale-vocab"
PRECOMMIT_HOOK_NAME: "Spelling vocabularies"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_python_versions) }}
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.JSON_FILE_DATA).ci_verbose_notifications }}

{%- endraw %}{% if cookiecutter.optional_toml_linting == 'true' %}{% raw %}

toml_lint:
Expand Down Expand Up @@ -220,13 +246,15 @@ jobs:
- commit_lint
- commit_spell_check
- configuration
- git_conflict_markers
- json_schema_lint
- markdown_links
- markdown_lint
- markdown_spelling
- pre-commit_hooks
- security
- shell_lint
- spelling_vocabularies
- start
{%- endraw %}{% if cookiecutter.optional_toml_linting == 'true' %}
- toml_lint
Expand Down
19 changes: 7 additions & 12 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/cicd-tools-org/pre-commit.git
rev: 0.4.0
rev: 0.5.0
hooks:
- id: format-shell
args:
Expand All @@ -30,9 +30,7 @@ repos:
{%- if cookiecutter.optional_toml_linting == 'true' %}
- id: format-toml
{%- endif %}
- id: lint-ansible
args:
- ansible_role
- id: git-conflict-markers
{%- if cookiecutter.optional_workflow_linting == 'true' %}
- id: lint-github-workflow-header
- id: lint-github-workflow
Expand All @@ -50,7 +48,11 @@ repos:
- id: security-credentials
- id: spelling-commit-message
- id: spelling-markdown
- id: spelling-vale-synchronize
- id: spelling-vale-sync
- id: spelling-vale-vocab
- id: poetry-lint-ansible
args:
- ansible_role
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
Expand All @@ -59,10 +61,3 @@ repos:
- "-c"
- "./.yamllint.yml"
stages: [commit]
- repo: local
hooks:
- id: spelling-vale-vocab
name: "spelling-vale-vocab"
entry: /bin/bash -c 'for FILE in "$@"; do sort -u -o ${FILE} ${FILE}; done' --
files: "^.vale/Vocab/.+/(accept|reject)\\.txt$"
language: system

0 comments on commit 8424f47

Please sign in to comment.