-
Notifications
You must be signed in to change notification settings - Fork 788
fix(ci): re-run PR gate on issue_comment and gate prepush frontend lint on changes #1123
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8b39f1a
fix(ci): re-run PR gate on issue_comment and gate prepush lint on gui…
Wibias ac8505d
fix(ci): pin issue_comment trigger and fallback checkout ref in gate …
Wibias 732f296
fix(ci): restrict issue_comment re-run to maintainers on PRs and cons…
Wibias 36c87af
fix(ci): anchor hygiene delimiters to complete lines and share the ga…
Wibias 4d13067
fix(ci): checkout dev on issue_comment reruns and fail closed on unve…
Wibias a0740f7
fix(ci): queue (not cancel) shared gate-comment writes and prove inte…
Wibias 8c4ad03
fix(test): merge duplicate comments fixture and consume hygiene in re…
Wibias 22cd62c
fix(ci): require canonical maintainer for issue_comment gate reruns
Wibias 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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Simulate eslint finding violations: non-zero exit with finding text. | ||
| process.stdout.write("2 problems (2 errors, 0 warnings)\n"); | ||
| process.exit(1); |
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,99 @@ | ||
| /** | ||
| * Run GUI eslint when this push includes gui/ changes. | ||
| * Used by `bun run prepush`. Skip with: git push --no-verify | ||
| * | ||
| * Mirrors `scripts/doctor-gui-if-changed.ts` so the local pre-push gate and | ||
| * the CI `gates` job agree: GUI lint runs only when the push actually touches | ||
| * `gui/`. Unlike doctor there is no engine to fetch, so lint findings always | ||
| * fail the push — there is no infra-degradation path to soft-skip on. | ||
| * | ||
| * Test hooks: LINT_DRY_RUN=1 prints the run/skip decision without spawning; | ||
| * LINT_FILES (newline-separated) overrides git-derived changed files; | ||
| * LINT_CMD overrides the spawned command. | ||
| */ | ||
| import { spawnSync } from "node:child_process"; | ||
| import { join, resolve } from "node:path"; | ||
|
|
||
| /** True when any changed path is the gui directory or inside it (slash-guarded). */ | ||
| function guiPathsChanged(files: string[]): boolean { | ||
| return files.some(f => f === "gui" || f.startsWith("gui/")); | ||
| } | ||
|
|
||
| if (import.meta.main) { | ||
| const repoRoot = resolve(import.meta.dirname, ".."); | ||
| const guiDir = join(repoRoot, "gui"); | ||
|
|
||
| const hasRef = (ref: string): boolean => { | ||
| try { | ||
| const probe = spawnSync("git", ["rev-parse", "--verify", ref], { | ||
| cwd: repoRoot, | ||
| stdio: "ignore", | ||
| }); | ||
| return probe.status === 0; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| const diffNames = (range: string): string[] => { | ||
| try { | ||
| const diff = spawnSync("git", ["diff", "--name-only", range], { | ||
| cwd: repoRoot, | ||
| encoding: "utf8", | ||
| }); | ||
| if (diff.status !== 0) return []; | ||
| return (diff.stdout ?? "") | ||
| .split(/\r?\n/) | ||
| .map(line => line.trim()) | ||
| .filter(Boolean); | ||
| } catch { | ||
| return []; | ||
| } | ||
| }; | ||
|
|
||
| let files: string[]; | ||
| let hadBase = true; | ||
| if (process.env.LINT_FILES !== undefined) { | ||
| files = process.env.LINT_FILES.split(/\r?\n/).map(f => f.trim()).filter(Boolean); | ||
| } else { | ||
| let range: string | null = null; | ||
| if (hasRef("@{u}")) range = "@{u}...HEAD"; | ||
| else if (hasRef("origin/main")) range = "origin/main...HEAD"; | ||
| else if (hasRef("main")) range = "main...HEAD"; | ||
| hadBase = range !== null; | ||
| files = range ? diffNames(range) : []; | ||
| } | ||
|
|
||
| // No usable base — run lint so GUI pushes still get a check. | ||
| const shouldRun = hadBase ? guiPathsChanged(files) : true; | ||
|
|
||
| if (process.env.LINT_DRY_RUN === "1") { | ||
| console.log(shouldRun ? "lint:run" : "lint:skip"); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| if (!shouldRun) { | ||
| console.log("lint:gui: skip (no gui/ changes in push range)"); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| console.log("lint:gui: gui/ changed — running eslint (scope=changed)"); | ||
| const [cmd, ...args] = process.env.LINT_CMD | ||
| ? process.env.LINT_CMD.split(" ") | ||
| : ["bun", "run", "lint"]; | ||
|
|
||
| const result = spawnSync(cmd!, args, { | ||
| cwd: guiDir, | ||
| encoding: "utf8", | ||
| stdio: "inherit", | ||
| }); | ||
|
|
||
| // Lint is local and deterministic: findings fail the push, and a failed | ||
| // spawn is a real error, not an infrastructure soft-skip. | ||
| if (result.error) { | ||
| console.error(`lint:gui: could not run eslint: ${result.error.message}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| process.exit(result.status === null ? 1 : result.status); | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.