Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit hook for validating release notes #937

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

aaradhak
Copy link
Member

@aaradhak aaradhak commented Aug 12, 2024

This is a pre-commit hook using pre-commit framework to validate release notes YAML files.

  • The hook checks for correct structure, formatting and required fields in the release-notes directory.
  • This ensures consistency in release notes before committing changes.

Ref:

@aaradhak aaradhak requested a review from jlebon August 12, 2024 22:43
@aaradhak aaradhak force-pushed the precommit branch 2 times, most recently from f207c1d to 5309f17 Compare August 12, 2024 22:48
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Not against this, but personally I don't feel like installing pre-commit just for this repo.

How about we also add it to the existing make syntax-check target?

@aaradhak
Copy link
Member Author

aaradhak commented Aug 19, 2024

I have made the changes to add the pre-commit hook to the make-syntax check. I think that is all would be needed. Please let me know if anything else needs to be changed.

@aaradhak aaradhak requested a review from jlebon August 19, 2024 20:49
Makefile Outdated
@@ -1,7 +1,8 @@
.PHONY: syntax-check
.PHONY: syntax-check pre-commit-check print-rollouts
Copy link
Member

Choose a reason for hiding this comment

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

Hum, why is this adding pre-commit-check here?

Copy link
Member Author

@aaradhak aaradhak Aug 20, 2024

Choose a reason for hiding this comment

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

based on the review comment earlier, I added the pre-commit check to the syntax check here.

@@ -0,0 +1,8 @@
repos:
Copy link
Member

Choose a reason for hiding this comment

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

What's using this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

This yaml is used by the pre-commit tool framework for managing pre-commit hooks. Pre-commit hooks run automatically before a commit is finalized. It requires the installation of pre-commit tool in the local environment

Makefile Outdated
Comment on lines 3 to 6
syntax-check: pre-commit-check
@find streams updates -iname '*.json' | sort | xargs -n 1 python3 -c 'import json, sys; json.load(open(sys.argv[1]))'
pre-commit-check:
pre-commit run --all-files
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
syntax-check: pre-commit-check
@find streams updates -iname '*.json' | sort | xargs -n 1 python3 -c 'import json, sys; json.load(open(sys.argv[1]))'
pre-commit-check:
pre-commit run --all-files
syntax-check: pre-commit-check
@find streams updates -iname '*.json' | sort | xargs -n 1 python3 -c 'import json, sys; json.load(open(sys.argv[1]))'
@find release-notes -iname '*.yaml' | sort | xargs -n1 python3 ci/check-release-notes.py

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for this input. I have made these changes.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Since we now have it part of syntax-check, it's already covered by the existing validate.yml workflow, so we can get rid of the validate-release-notes.yml file.

Coincidentally, it looks like validation is failing. :)

Makefile Outdated Show resolved Hide resolved
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Still need to drop GitHub workflow.

Makefile Show resolved Hide resolved
name: Validate Release Notes
entry: python ci/check-release-notes.py
language: python
files: ^release-notes/.*\.yml$
Copy link
Member

Choose a reason for hiding this comment

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

How about now we make this config use make syntax-check? That way it'll check more than just release notes.

@aaradhak aaradhak requested a review from jlebon October 1, 2024 22:02
@aaradhak aaradhak requested a review from travier October 22, 2024 19:23
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM though let's squash to a single commit?

- This is a pre-commit hook using `pre-commit` framework to validate release notes YAML files.
- The hook checks for correct structure, formatting and required fields in the `release-notes` directory.
- This ensures consistency in release notes before committing changes.
- Added release notes validation to the `make syntax-check` target

Ref: coreos#934 (comment)
@jlebon jlebon merged commit 9d127d4 into coreos:main Nov 27, 2024
1 check passed
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.

3 participants