Validate change-notes as a PR check - #4116
Conversation
|
Closing this to re-work these changes after a migration to the |
This commit also introduces the 'empty' home directory for future change-notes.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Michael B. Gale <mbg@github.com>
f2789ac to
ef0cd9e
Compare
mbg
left a comment
There was a problem hiding this comment.
Appreciate that this is a draft pending the changes in the other PRs, but some drive-by comments since I saw this and you could look at incorporating the feedback when updating this PR once the others are merged.
| working-directory: pr-checks | ||
| # "unreleased-change-notes" resolves to a path relative to scripts/changetool. | ||
| # So, we need to pass the absolute path to the directory by prefixing $GITHUB_WORKSPACE. | ||
| run: npx tsx validate-changelog.ts "$GITHUB_WORKSPACE/unreleased-change-notes" |
There was a problem hiding this comment.
Alternatively you could not set working-directory and specify pr-checks/validate-changelog.ts as the script path. That works around the need to use $GITHUB_WORKSPACE and the lengthy explanation.
Even better, however, would be to add a constant to pr-checks/config.ts for the path joined onto REPO_ROOT and use that as the path (assuming it will always be that path).
| }, | ||
| { | ||
| files: ["**/*.ts", "**/*.js"], | ||
| files: ["**/*.ts", "**/*.js", "**/*.mts"], |
| * @param filepath The path to the change-note file or directory to validate. | ||
| * @returns True if the path is valid, false otherwise. | ||
| */ | ||
| export function isValidChangenoteFileOrDir(filepath: string): boolean { |
There was a problem hiding this comment.
Minor: no strong need to change this, but consider decoupling I/O from the validation logic when writing functions like this to avoid having to create real directories / files in the unit tests. Alternatively, consider stubbing the I/O operations for the tests to return the hard-coded test data, but that has the downside that it breaks test parallelism.
This PR extends the behavior of the recently added
scripts/changetooltool by adding:changetoolwill scan its contents (ignoring.gitkeep) for change-note files to validate. This feature is used directly in...pr-checks.ymlworkflow file for executingchangetoolin PRs as a check.This PR also introduces an "empty" top-level directory,
unreleased-change-notes, to be the destination of future change-note files. This can be changed if another location is more suitable.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
Products:
Environments:
How did/will you validate this change?
.test.tsfiles).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist