[Tooling] CHANGELOG and Version Bump PreCommit Hook#397
[Tooling] CHANGELOG and Version Bump PreCommit Hook#397Olshansk merged 21 commits intopokt-network:mainfrom h5law:changelog-verify
Conversation
… versions are correct
… all pull-request opens, reopens, edits and synchronisations
Olshansk
left a comment
There was a problem hiding this comment.
@h5law First off, thank you! Love the clear explanation, documentation, videos, quality of work and how just got it frikkin done 💯
_My only request (if you plan on contributing in the future) is just to leave a comment on the issue (#93) next time to check with the team that it’s still relevant or to make sure you have a lock on the task._
My bash-foo is not so strong, so I don't have any real feedback unfortunately other than some nits 🙇. It's pretty easy to follow, the comments are helpful and clear enough to let us make changes if/when need be.
Left a couple minor comments and also shared with the team internally!
|
I have addressed the comments you gave @Olshansk you didn't mention it so I think it will be fine but if you want me to stop checking for changes in the root directory (no real code there + no changelog) and any others let me know I can quickly do this if needed. |
…ation marks to echos
Olshansk
left a comment
There was a problem hiding this comment.
A couple more comments, a question and then good to go
|
@Olshansk I have addressed the issues you brought up in the documentation file and added a third job to run after the validation step in the workflow. If this job sees that the validation step failed, it will automatically add the 'do not merge' label, which should trigger the pre-existing do-not-merge workflow to prevent any merging until the label is removed. I don't think automatically removing the label if the test passes would be a good idea as it may be applied for some other reason besides a CHANGELOG so I left it at simply applying the label. |
Do we really need to do this? I figured that the existing If that's the case, I think its simpler to remove the workflow of adding the label, and then merge it in! |
… - 1 fail or 0 success
I misunderstood the question sorry. I have removed the From my understanding whether or not a failed test prevents the PR being merged is decided in the repository settings. However I am not 100% on this, I am getting this from the documentation I linked in a previous message. I believe the I hope this is all alright 😃 |
Appreciate you for bearing on the back-and-forth :)
That is correct, and is the case for us.
This isn't "mission critical" and I have high-confidence in the changes after the review. If there's a small update/change we need to make after merging, would you be able to help us out?
🤝 |
Yeah of course, I hope I can get more involved anyway |
|
To address those final commits - I realised the I also removed the dependency on the date command (past the basic usage that is portable across linux/osx/bsd) and am now comparing the dates from the changelog as a string against today's date. Finally I have updated the relevant changelog in |
Olshansk
left a comment
There was a problem hiding this comment.
To address those final commits - I realised the CHANGELOG.md file detection was wrong as the CHANGELOGs are stored in different sub directories (root of module, doc, docs) and so to address this when a CHANGELOG.md is detected in the path of a file the script will now add this path to a list and loop through that instead of trying to "build" the CHANGELOG.md path itself.
Could you update the comment in the pre-commit if you think its relevant to add more details?
I also removed the dependency on the date command (past the basic usage that is portable across linux/osx/bsd) and am now comparing the dates from the changelog as a string against today's date.
Nice
Finally I have updated the relevant changelog in utility/doc/CHANGELOG.md as Jessica requested.
Left a comment about this.
Sorry for the large number of commits 😅
No worries assuming your okay with the back-and-forth! Let's get it right :)
Either way, what we do is a "squash & merge" where the git message is the PR description, so commit as many times as you want while working in progress.
utility/doc/CHANGELOG.md
Outdated
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [0.0.0.14] - 2022-12-20 |
There was a problem hiding this comment.
We don't actually have a CHANGELOG for infra/tooling.
Putting this under build seems wrong (irrelevant), but creating a CHANGELOG under root also seems wrong (it's just tooling).
Since I don't have a good answer for it for now. Seems that your script checks for a CHANGELOG under root, which we don't have yet. DO you want to add it?
There was a problem hiding this comment.
This was a question I posed in the original PR, I don't see the need to create a CHANGELOG simply for this one piece of tooling. I have removed the root directory check as there is nothing there. I think it is probably better in my opinion to remove this check as there isn't really a need for it.
If you want me to remove the changes I made to utility/doc/CHANGELOG.md I can but I don't see the point in making a new root level CHANGELOG.md as it probably will not see any updates besides this - there is no top-level code. All the other modules have their own as well so let me know what you think about this. I can if that's what you are looking for.
There was a problem hiding this comment.
Adding the root changelog would mean that for any update to a module that requires go.mod or go.sum to change then both the module and root CHANGELOG.md files would need to be included - which would be an pointless repetition. We could get around this by having the script ignore all files in the root directory - as they don't require a changelog really. But this is the same as not checking it at all...
There was a problem hiding this comment.
I don't see the need to create a CHANGELOG simply for this one piece of tooling
Agreed
. I think it is probably better in my opinion to remove this check as there isn't really a need for it.
Since I'm not 100% sure at the moment, but I can see us adding a root changelog soon (for main releases), can you add a ROOT_CHANGELOG_ENABLE=0 with a comment explaining that it should be enabled once a root CHANGELOG is added. We get to keep the code and document why it is off at the moment.
There was a problem hiding this comment.
can you add a
ROOT_CHANGELOG_ENABLE=0with a comment explaining that it should be enabled once a root CHANGELOG is added. We get to keep the code and document why it is off at the moment.
So instead of this I have the script check the root level ONLY for a CHANGELOG.md file. This avoids having to do the full root level check/ignore certain files but allows for the root-level CHANGELOG.md - only when included to be validated.
This does mean there can never be an error situation for not including it in a commit. However it means that there doesn't need to be any code changes when the CHANGELOG gets implemented.
I would be happy to implement a checking system when the CHANGELOG is made and the circumstances defining when and when not to include it in a commit are clearly defined. But for now if its included it will be validated (date+version) like the rest but if not there will be no errors.
Olshansk
left a comment
There was a problem hiding this comment.
Left one comment here: https://github.com/pokt-network/pocket/pull/397/files#r1053724399
Wdyt of this compromise (best of both words w/ optionality) and then we'd be good to merge?
utility/doc/CHANGELOG.md
Outdated
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [0.0.0.14] - 2022-12-20 |
There was a problem hiding this comment.
I don't see the need to create a CHANGELOG simply for this one piece of tooling
Agreed
. I think it is probably better in my opinion to remove this check as there isn't really a need for it.
Since I'm not 100% sure at the moment, but I can see us adding a root changelog soon (for main releases), can you add a ROOT_CHANGELOG_ENABLE=0 with a comment explaining that it should be enabled once a root CHANGELOG is added. We get to keep the code and document why it is off at the moment.
I have implemented something similar I explained the details in the reply to the comment above - but simply instead of having a hard "toggle" which would require an update when the CHANGELOG is implemented at root level the script now just checks for the presence of a root-level changelog and if its there it will validate it. No errors if its not there. I have also removed the changes made to the |
Olshansk
left a comment
There was a problem hiding this comment.
Thank you @h5law and appreciate your collaboration on the back-and-forth. I learnt a few things along the way so lmk if you'd be interested in picking up more tasks in the future :)
As I mentioned earlier, we usually do a "Squash & Merge" + Put the PR description as the body so I will go ahead and do so!
Description
This PR contains the pre-commit logic to check and validate whether the relevant
CHANGELOG.mdfiles have (1) been included in the commit and (2) contain up-to-date versioning. This is in response to Issue #93.Git Hook:
The client-side logic is contained in the bash script
.githooks/pre-commitfor it to actually perform this verification check prior to a commit it must be copied into.git/hooksand be executable.As it is a git hook, it can be disabled locally by running
git commitwith the--no-verifyor-nflag:The script will detect if a
CHANGELOG.mdis present and if it is it will check whether (1) the latest version in the changelog is greater than the one before it and (2) that the date alongside the latest version is the current date. If any of these checks fail (no changelog, invalid version, not current date) then the script will block the commit.To verify the changelog's version is correct it converts the string
[0.0.0.8]to0008and then strips the leading zeros and compares the number against the next version found if it is less than or equal to the one previous it sees this as an error. This is done by extracting the versions and dates from theCHANGELOG.mdfile usingsed. It then compares the date of the newest version against today's date and if they aren't equal and it sees this as an error.Currently, the script uses the directories
.githooks.githubdocsbinas ignored directories and does not check for aCHANGELOG.mdfile in these subdirs.Dependencies:
This script requires
bashto be installed and requiressed,headanddatecommands - these should be present on all Linux/OSX/BSD systems. The script uses sed Basic Regular Expressions that are portable across GNU sed and FreeBSD sed (used by OSX as well) and also usesdateformatting that is consistent across Linux/OSX/BSD versions of the command. Currently, there is no support for Windows when run locally.GitHub Workflow:
The GitHub workflow will run the
pre-commitscript however it will populate the edited files by instead passing them as arguments to the script. This cannot be disabled and will run on all PRs when they are opened, reopened and synchronised. The jobs are configured to run onubuntu-latestso there are no issues with dependencies as all the required binaries are present on ubuntu installs.The files in question are found in:
Issue
Fixes #93
Type of change
Please mark the relevant option(s):
List of changes
pre-commitgit hook to validate changelogs presence in commits & correct versioningpre-commitlogic on all PRs [opened, reopened, synchronised]pre-commithook todocs/development/README.mdutility/doc/CHANGELOG.mdTesting
Videos:
changelog-verify-test-video.webm
github-workflow-test-video1.webm
github-workflow-test-video2.webm
Required Checklist
If Applicable Checklist
shared/docs/*if I updatedshared/*README(s)