Skip to content

feat: add pre-commit hooks#798

Merged
markgoddard merged 12 commits into
stackhpc/2023.1from
add-pre-commit-hooks
Sep 4, 2024
Merged

feat: add pre-commit hooks#798
markgoddard merged 12 commits into
stackhpc/2023.1from
add-pre-commit-hooks

Conversation

@jackhodgkiss
Copy link
Copy Markdown
Contributor

Add a simple playbook that can install pre-commits and register a few simple hooks. This process is implemented as a hook that will run post control host bootstrap.

  • check-yaml: perform basic yaml syntax linting
  • end-of-file-fixer: identify and automatically fix missing newline
  • trailing-whitespace: identify and automatically fix excessive white space
  • ripsecrets: identify and prevent secrets from being committed to the branch

Note: this is currently configured as an opt-in feature and will only install and register hooks if enable_pre_commit_hooks is set to true in install-pre-commit-hooks.yml

@jackhodgkiss jackhodgkiss requested a review from a team as a code owner November 23, 2023 16:17
Comment thread releasenotes/notes/add-pre-commit-hooks-07ce3b82bbe1d7a3.yaml Outdated
Comment thread releasenotes/notes/add-pre-commit-hooks-07ce3b82bbe1d7a3.yaml Outdated
Alex-Welsh
Alex-Welsh previously approved these changes Feb 12, 2024
Copy link
Copy Markdown
Contributor

@markgoddard markgoddard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we expecting this to be used? Is it something that would be enabled for everyone in a given Kayobe config, or opted into per-person?

Copy link
Copy Markdown
Contributor

@markgoddard markgoddard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to provide some simple docs on this in the contributor guide.

Comment thread etc/kayobe/ansible/install-pre-commit-hooks.yml Outdated
Comment thread etc/kayobe/ansible/install-pre-commit-hooks.yml Outdated
@jackhodgkiss
Copy link
Copy Markdown
Contributor Author

How are we expecting this to be used? Is it something that would be enabled for everyone in a given Kayobe config, or opted into per-person?

I think having it is as an opt-in at least within SKC it the sensible move. If individual engineers want to enable it within their own checkout of the site config they can do and in situations where their is a single checkout shared enabling it would a group decision.

Alex-Welsh
Alex-Welsh previously approved these changes Apr 12, 2024
Copy link
Copy Markdown
Member

@Alex-Welsh Alex-Welsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My one lingering concern is that false positives could break things but they can be skipped with --no-verify so I think the benefits outweigh the risks

@jackhodgkiss jackhodgkiss force-pushed the add-pre-commit-hooks branch from eb12139 to 8355d55 Compare April 15, 2024 09:17
Comment thread etc/kayobe/ansible/install-pre-commit-hooks.yml Outdated
Comment thread etc/kayobe/ansible/install-pre-commit-hooks.yml Outdated
Comment thread doc/source/contributor/pre-commit.rst
@markgoddard markgoddard requested a review from Alex-Welsh April 15, 2024 15:36
@markgoddard markgoddard dismissed priteau’s stale review April 15, 2024 15:37

Requested change has been applied

Copy link
Copy Markdown
Contributor

@markgoddard markgoddard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually perhaps this should go to antelope only?

@Alex-Welsh
Copy link
Copy Markdown
Member

@jackhodgkiss should we get this merged? I'm happy to rebase it on antelope for you if you're busy

@markgoddard markgoddard changed the base branch from stackhpc/yoga to stackhpc/2023.1 August 21, 2024 11:25
@markgoddard markgoddard force-pushed the add-pre-commit-hooks branch from 7eb0dcf to 5e7a63a Compare August 21, 2024 11:25
Comment thread etc/kayobe/ansible/install-pre-commit-hooks.yml Outdated
Comment thread .pre-commit-config.yaml
jackhodgkiss and others added 7 commits August 22, 2024 13:10
Initally `pre-commit` hooks were installed due the presense of a hook
for `control host bootstrap` and when `enable_pre_commit_hooks` was set
to `true`. However now `pre-commit` hooks are only installed when the
hook is present or the playbook is called, no requirement for an
`Ansible` conditional to be true.
@markgoddard markgoddard merged commit 65b4b98 into stackhpc/2023.1 Sep 4, 2024
@markgoddard markgoddard deleted the add-pre-commit-hooks branch September 4, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants