Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/copilot_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
repository-locale: ${{ vars.REPOSITORY_LOCALE || 'en-US' }}
issues-locale: ${{ vars.ISSUES_LOCALE || '' }}
pull-requests-locale: ${{ vars.PULL_REQUESTS_LOCALE || '' }}
ai-ignore-files: build/*
ai-ignore-files: build/*,specs/CATALOG.md
bugbot-dry-run: ${{ vars.BUGBOT_DRY_RUN || 'false' }}
bugbot-effort: ${{ vars.BUGBOT_EFFORT || 'smart' }}
bugbot-review-drafts: ${{ vars.BUGBOT_REVIEW_DRAFTS || 'false' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot_issue_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
repository-locale: ${{ vars.REPOSITORY_LOCALE || 'en-US' }}
issues-locale: ${{ vars.ISSUES_LOCALE || '' }}
pull-requests-locale: ${{ vars.PULL_REQUESTS_LOCALE || '' }}
ai-ignore-files: build/*
ai-ignore-files: build/*,specs/CATALOG.md
debug: ${{ vars.DEBUG }}
agent-provider: ${{ vars.AGENT_PROVIDER || 'codex' }}
agent-model-provider: ${{ vars.AGENT_MODEL_PROVIDER || 'openai' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
repository-locale: ${{ vars.REPOSITORY_LOCALE || 'en-US' }}
issues-locale: ${{ vars.ISSUES_LOCALE || '' }}
pull-requests-locale: ${{ vars.PULL_REQUESTS_LOCALE || '' }}
ai-ignore-files: build/*
ai-ignore-files: build/*,specs/CATALOG.md
bugbot-severity: ${{ vars.BUGBOT_SEVERITY || 'low' }}
bugbot-comment-limit: ${{ vars.BUGBOT_COMMENT_LIMIT || '20' }}
bugbot-fix-verify-commands: ${{ vars.BUGBOT_AUTOFIX_VERIFY_COMMANDS }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot_pull_request_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
repository-locale: ${{ vars.REPOSITORY_LOCALE || 'en-US' }}
issues-locale: ${{ vars.ISSUES_LOCALE || '' }}
pull-requests-locale: ${{ vars.PULL_REQUESTS_LOCALE || '' }}
ai-ignore-files: build/*
ai-ignore-files: build/*,specs/CATALOG.md
debug: ${{ vars.DEBUG }}
agent-provider: ${{ vars.AGENT_PROVIDER || 'codex' }}
agent-model-provider: ${{ vars.AGENT_MODEL_PROVIDER || 'openai' }}
Expand Down
23 changes: 23 additions & 0 deletions scripts/validate-workflow-contract.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ const REPOSITORY_LOCALE_INPUTS = Object.freeze({
'issues-locale': "${{ vars.ISSUES_LOCALE || '' }}",
'pull-requests-locale': "${{ vars.PULL_REQUESTS_LOCALE || '' }}",
});
const REPOSITORY_BUGBOT_CONTEXT_EXCLUSIONS = 'build/*,specs/CATALOG.md';
const REPOSITORY_BUGBOT_WORKFLOW_FILES = new Set([
'copilot_issue.yml',
'copilot_issue_comment.yml',
'copilot_pull_request.yml',
'copilot_pull_request_comment.yml',
]);

function workflowFiles(directory) {
return readdirSync(directory)
Expand Down Expand Up @@ -228,6 +235,20 @@ function assertRepositoryLocaleInputs(file, workflow) {
}
}

function assertRepositoryBugbotContextExclusions(file, workflow) {
const relativeFile = relativeWorkflow(file);
if (!relativeFile.startsWith('.github/workflows/')
|| !REPOSITORY_BUGBOT_WORKFLOW_FILES.has(path.basename(file))) return;
for (const [jobId, job] of Object.entries(workflow.jobs ?? {})) {
for (const [stepIndex, step] of (job.steps ?? []).entries()) {
if (!isCopilotAction(step)) continue;
if (step.with?.['ai-ignore-files'] !== REPOSITORY_BUGBOT_CONTEXT_EXCLUSIONS) {
throw new Error(`${relativeFile} job ${jobId} step ${stepIndex + 1} must exclude generated build and specification catalog artifacts from Bugbot context exactly.`);
}
}
}
}

function assertAgentInstallationPrerequisites(file, workflow) {
const manifestFile = path.basename(file);
if (!WORKFLOW_AGENT_ROLES[manifestFile] && manifestFile !== 'agent-cli-provisioning.yml') return;
Expand Down Expand Up @@ -859,6 +880,7 @@ function validateWorkflow(file, workflow) {
assertSequentialMutationWorkflow(file, workflow);
assertAgentInputs(file, workflow);
assertRepositoryLocaleInputs(file, workflow);
assertRepositoryBugbotContextExclusions(file, workflow);
assertAgentInstallationPrerequisites(file, workflow);
assertNoJobLevelSecrets(file, workflow);
assertAgentWorkflowPermissions(file, workflow);
Expand Down Expand Up @@ -910,6 +932,7 @@ module.exports = {
assertCopilotActionInputs,
assertAgentInputs,
assertRepositoryLocaleInputs,
assertRepositoryBugbotContextExclusions,
assertAgentInstallationPrerequisites,
assertNoJobLevelSecrets,
assertAgentWorkflowPermissions,
Expand Down
28 changes: 28 additions & 0 deletions src/tooling/__tests__/validate_workflow_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface ContractModule {
assertAgentWorkflowPermissions(file: string, workflow: Record<string, unknown>): void;
assertAgentInstallationPrerequisites(file: string, workflow: Record<string, unknown>): void;
assertRepositoryLocaleInputs(file: string, workflow: Record<string, unknown>): void;
assertRepositoryBugbotContextExclusions(file: string, workflow: Record<string, unknown>): void;
assertLightweightBranchSyncWorkflow(file: string, workflow: Record<string, unknown>): void;
MIN_QUEUE_JOB_TIMEOUT_MINUTES: number;
DEPLOYMENT_VALIDATION_TIMEOUT_MINUTES: number;
Expand All @@ -37,6 +38,7 @@ const {
assertAgentWorkflowPermissions,
assertAgentInstallationPrerequisites,
assertRepositoryLocaleInputs,
assertRepositoryBugbotContextExclusions,
assertLightweightBranchSyncWorkflow,
MIN_QUEUE_JOB_TIMEOUT_MINUTES,
DEPLOYMENT_VALIDATION_TIMEOUT_MINUTES,
Expand Down Expand Up @@ -671,6 +673,32 @@ describe('workflow contract validator', () => {
);
});

it('keeps generated artifacts out of this repository Bugbot context', () => {
for (const fileName of [
'copilot_issue.yml',
'copilot_issue_comment.yml',
'copilot_pull_request.yml',
'copilot_pull_request_comment.yml',
]) {
const file = path.join(process.cwd(), '.github/workflows', fileName);
const workflow = yaml.load(readFileSync(file, 'utf8')) as MutationWorkflow;
expect(() => assertRepositoryBugbotContextExclusions(file, workflow)).not.toThrow();
}
});

it('rejects repository workflows that restore generated catalog noise', () => {
const file = path.join(process.cwd(), '.github/workflows', 'copilot_pull_request.yml');
const workflow = yaml.load(readFileSync(file, 'utf8')) as MutationWorkflow;
const action = workflow.jobs['copilot-pull-requests'].steps.find(
(step: { uses?: string }) => step.uses === './',
);
action.with['ai-ignore-files'] = 'build/*';

expect(() => validateWorkflow(file, workflow)).toThrow(
'must exclude generated build and specification catalog artifacts',
);
});

it('requires Node.js 24 before every workflow path that may install a pinned agent CLI', () => {
for (const directory of ['.github/workflows', 'setup/workflows']) {
for (const fileName of [
Expand Down