Repository navigation
ci: fix engineer bot formatting and publication checks #570
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
vuanhphung
wants to merge
30
commits into
main
Choose a base branch
from
ci/engineer-bot-changelog-style-checks
base: main
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
30 commits
Select commit
Hold shift + click to select a range
db1db00
ci: require engineer bot changelog and style checks
vuanhphung 07d218d
ci: fix bot formatter tracking and validation isolation
vuanhphung 75df5f1
ci: validate recorded bot edits and nested configuration
vuanhphung d867255
ci: isolate bot lint config and clarify unsupported deletions
vuanhphung 9e8bbdc
ci: verify bot validation dependencies before running checks
vuanhphung b1eb40b
ci: clarify bot validation failures and enforce changelog order
vuanhphung 988b222
test: keep engineer bot publication checks covered in CI
vuanhphung 70ed95b
ci: load bot validation scripts from the committed tree
vuanhphung 414c3b1
ci: isolate validation scripts from child process stdin
vuanhphung 15b182b
ci: pin engineer bot validation to the pre-agent commit
vuanhphung c763f40
ci: reject new bot suppression directives and YAML package config
vuanhphung 6ec100f
ci: preserve pending changelog entries and detect hidden config
vuanhphung 5d35036
ci: check every suppression comment and inline rule config
vuanhphung a2753f7
ci: isolate validation Git settings and recognize directive forms
vuanhphung 15c74b9
ci: tolerate baseline changelog quirks and verify cache isolation
vuanhphung 2e64e09
ci: ignore cosmetic changes to existing suppression directives
vuanhphung 88bff2f
ci: isolate validator imports and invoke pinned style tools
vuanhphung 95d3f07
docs: clarify engineer bot validation trust boundary
vuanhphung 4783c10
ci: preserve eslint enable directives by rule key
vuanhphung 52ac877
ci: preserve structured pending notes and explain deletion limits
vuanhphung 2d42bd6
ci: pin engineer bot Python to the validated version
vuanhphung ae2119a
ci: document engine outputs and clarify validation failures
vuanhphung fa76455
Merge main into engineer bot validation updates
vuanhphung 8622c96
ci: require changelog updates for engineer bot mentions
vuanhphung a10950c
ci: align bot instructions with publication constraints
vuanhphung 8ff39fb
ci: accept Markdown bullets and scope bot integrity checks
vuanhphung f24779d
ci: document bot runtime and integrity check coupling
vuanhphung a1487f0
ci: verify bot style commands match package scripts
vuanhphung 23d9edf
ci: state author publication constraints before edits
vuanhphung b48feaf
ci: clarify mandatory author release-note policy
vuanhphung 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
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
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,90 @@ | ||
| const fs = require('fs'); | ||
| const { execFileSync } = require('child_process'); | ||
| const ts = require('typescript'); | ||
|
|
||
| function directives(filename, text) { | ||
| const comments = new Map(); | ||
| if (/\.[cm]?[jt]sx?$/.test(filename)) { | ||
| const source = ts.createSourceFile(filename, text, ts.ScriptTarget.Latest, true); | ||
| const collect = (start, end) => { | ||
| comments.set(`${start}:${end}`, text.slice(start, end)); | ||
| }; | ||
| const visit = (node) => { | ||
| ts.forEachLeadingCommentRange(text, node.pos, collect); | ||
| ts.forEachTrailingCommentRange(text, node.end, collect); | ||
| node.getChildren(source).forEach(visit); | ||
| }; | ||
| visit(source); | ||
| } else { | ||
| for (const match of text.matchAll(/^[ \t]*(?:<!--|\/\*|\/\/|#)\s*prettier-ignore[^\r\n]*/gm)) { | ||
| comments.set(match.index, match[0].trim()); | ||
| } | ||
| } | ||
| const counts = new Map(); | ||
| const add = (directive) => { | ||
| counts.set(directive, (counts.get(directive) || 0) + 1); | ||
| }; | ||
| for (const comment of comments.values()) { | ||
| const value = comment | ||
| .replace(/^(?:\/\/|\/\*|<!--|#)/, '') | ||
|
vuanhphung marked this conversation as resolved.
Resolved
|
||
| .replace(/(?:\*\/|-->)$/, '') | ||
| .trim() | ||
| .replace(/\s+/g, ' '); | ||
| const eslintDirective = | ||
| /^eslint-disable-(?:next-line|line)(?:\s|$)/.test(value) || | ||
| (comment.startsWith('/*') && /^(?:eslint(?:-disable|-enable|-env)?|globals?|exported)(?:\s|$)/.test(value)); | ||
| if (eslintDirective) { | ||
| let directive = value.split(/\s-{2,}\s/, 1)[0]; | ||
| const disable = /^(eslint-(?:disable(?:-next-line|-line)?|enable))(?:\s+(.*))?$/.exec(directive); | ||
| if (disable) { | ||
| const rules = (disable[2] || '') | ||
| .split(',') | ||
| .map((rule) => rule.trim().replace(/^(['"])(.*)\1$/, '$2')) | ||
| .filter(Boolean) | ||
| .sort(); | ||
| directive = `${disable[1]} ${rules.join(',')}`.trim(); | ||
| } | ||
| add(directive); | ||
| } else if (/^prettier-ignore(?:-[a-z-]+)?\b/.test(value)) { | ||
| add(value); | ||
| } | ||
| for (const line of comment.split(/\r?\n/)) { | ||
| const directive = /^[\s/*]*(@ts-(?:ignore|expect-error|nocheck))\b/.exec(line); | ||
| if (directive) add(directive[1]); | ||
| } | ||
| } | ||
| return counts; | ||
| } | ||
|
|
||
| for (const filename of JSON.parse(process.env.GATE_PATHS)) { | ||
| let previous = ''; | ||
| try { | ||
| previous = execFileSync('git', ['show', `${process.env.BASE_SHA}:${filename}`], { | ||
| encoding: 'utf8', | ||
| stdio: ['ignore', 'pipe', 'ignore'], | ||
| }); | ||
| } catch { | ||
| // New files have no baseline comments. | ||
| } | ||
| // Counts allow directives to move with refactored code; coverage still needs diff review. | ||
| const before = directives(filename, previous); | ||
| const after = directives(filename, fs.readFileSync(filename, 'utf8')); | ||
| for (const [directive, count] of before) { | ||
| if (!/^eslint-enable(?:\s|$)/.test(directive)) continue; | ||
| const removedEnables = Math.max(0, count - (after.get(directive) || 0)); | ||
| const disable = directive.replace(/^eslint-enable/, 'eslint-disable'); | ||
| const removedDisables = Math.max(0, (before.get(disable) || 0) - (after.get(disable) || 0)); | ||
| if (removedEnables > removedDisables) { | ||
| console.error( | ||
| `::error::Do not remove eslint-enable directives while keeping matching block disables: ${filename}`, | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| } | ||
| for (const [directive, count] of after) { | ||
|
vuanhphung marked this conversation as resolved.
Resolved
|
||
| if (!/^eslint-enable(?:\s|$)/.test(directive) && count > (before.get(directive) || 0)) { | ||
|
vuanhphung marked this conversation as resolved.
Resolved
vuanhphung marked this conversation as resolved.
Resolved
|
||
| console.error(`::error::Do not add lint, formatting, or type-check suppression directives: ${filename}`); | ||
| 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,4 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner -cf - node_modules | sha256sum |
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.