forked from abhigyanpatwari/GitNexus
-
Notifications
You must be signed in to change notification settings - Fork 0
ci(release): require protected manual publishing #83
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
Open
100yenadmin
wants to merge
4
commits into
reconcile/r19a-vector-delete-reopen
Choose a base branch
from
reconcile/r22-release-governance
base: reconcile/r19a-vector-delete-reopen
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
51ca6f8
ci(release): require protected manual publishing
5a617ad
fix(embeddings): resume partial checkpoint windows
cb49871
Merge branch 'reconcile/r19a-vector-delete-reopen' into reconcile/r22…
bb307bd
Merge branch 'reconcile/r19a-vector-delete-reopen' into reconcile/r22…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { parse } from 'yaml'; | ||
|
|
||
| const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); | ||
| const readWorkflow = (filename) => | ||
| parse(fs.readFileSync(path.join(repoRoot, '.github/workflows', filename), 'utf8')); | ||
| const workflow = readWorkflow('publish.yml'); | ||
|
|
||
| const fail = (message) => { | ||
| process.stderr.write(`release governance check failed: ${message}\n`); | ||
| process.exitCode = 1; | ||
| }; | ||
|
|
||
| const triggers = workflow.on; | ||
| if (!triggers || typeof triggers !== 'object') { | ||
| fail('publish.yml must declare structured triggers'); | ||
| } else { | ||
| const push = triggers.push; | ||
| if (!push || typeof push !== 'object') { | ||
| fail('publish.yml must retain stable tag publishing'); | ||
| } else { | ||
| if ('branches' in push || 'branches-ignore' in push) { | ||
| fail('publish.yml must not publish from branch pushes'); | ||
| } | ||
| const tags = Array.isArray(push.tags) ? push.tags : []; | ||
| if (!tags.includes('v*') || !tags.includes('!v*-rc.*')) { | ||
| fail('publish.yml must accept stable tags and reject self-produced RC tags'); | ||
| } | ||
| } | ||
| if (!('workflow_dispatch' in triggers)) { | ||
| fail('publish.yml must retain an explicit manual RC trigger'); | ||
| } | ||
| if ('pull_request' in triggers || 'pull_request_target' in triggers) { | ||
| fail('publish.yml must never publish from pull request events'); | ||
| } | ||
| } | ||
|
|
||
| const publishJob = workflow.jobs?.publish; | ||
| const environment = | ||
| typeof publishJob?.environment === 'string' | ||
| ? publishJob.environment | ||
| : publishJob?.environment?.name; | ||
| if (environment !== 'internal-release') { | ||
| fail('the publish job must require the internal-release environment'); | ||
| } | ||
|
|
||
| for (const filename of [ | ||
| 'ci.yml', | ||
| 'codeql.yml', | ||
| 'gitleaks.yml', | ||
| 'dependency-review.yml', | ||
| 'workflow-lint.yml', | ||
| ]) { | ||
| const candidate = readWorkflow(filename); | ||
| const pullRequest = candidate.on?.pull_request; | ||
| if (!pullRequest || typeof pullRequest !== 'object') { | ||
| fail(`${filename} must run for pull requests`); | ||
| continue; | ||
| } | ||
| const branches = Array.isArray(pullRequest.branches) ? pullRequest.branches : []; | ||
| if (!branches.includes('main')) { | ||
| fail(`${filename} must run for main-targeted pull requests`); | ||
| } | ||
| if ('paths' in pullRequest || 'paths-ignore' in pullRequest) { | ||
| fail(`${filename} must not omit required checks through path filters`); | ||
| } | ||
| } | ||
|
|
||
| if (!process.exitCode) { | ||
| process.stdout.write('release governance check passed\n'); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Missing workflow file crashes script instead of failing gracefully
readWorkflow() (line 9-10) calls fs.readFileSync without a try/catch. In the loop at line 51-71, if any of ci.yml, codeql.yml, gitleaks.yml, dependency-review.yml, or workflow-lint.yml is absent on a branch (e.g. a long-lived branch predating one of these workflows, or a fork that removed one), the script throws an uncaught ENOENT with a stack trace rather than emitting a governance 'fail()' message and exitCode=1. The effect is still a CI failure, so this is cosmetic, but wrapping readWorkflow in a try/catch that calls fail(
${filename} could not be read: ...) would produce a legible governance error consistent with the script's own messaging contract.Category: Runtime correctness
Why this matters: A stack trace from a missing-file ENOENT is a confusing CI signal for a governance check; the script already has a fail() channel designed exactly for this. Low impact because all five files exist on main and this branch.