feat(ql3): close cluster alpha milestone

This commit is contained in:
whyour
2026-08-28 00:25:04 +08:00
parent a7308c78f9
commit 07d1dd97c1
13 changed files with 2080 additions and 50 deletions
+14 -2
View File
@@ -465,6 +465,18 @@ function countOccurrences(contents, token) {
return contents.split(token).length - 1;
}
function jobBlock(workflow, jobName) {
const header = `\n ${jobName}:\n`;
const start = workflow.indexOf(header);
if (start < 0) return '';
const remaining = workflow.slice(start + header.length);
const nextMatch = /\n [a-z0-9-]+:\n/u.exec(remaining);
const end = nextMatch
? start + header.length + nextMatch.index
: workflow.length;
return workflow.slice(start, end);
}
function auditLocalAlphaMilestoneWorkflow(root = DEFAULT_ROOT) {
const workflowPath = path.join(
fs.realpathSync(path.resolve(root)),
@@ -473,7 +485,7 @@ function auditLocalAlphaMilestoneWorkflow(root = DEFAULT_ROOT) {
const workflow = fs.readFileSync(workflowPath, 'utf8');
const findings = [];
const milestoneStart = workflow.indexOf('\n local-alpha-milestone:\n');
const milestone = milestoneStart >= 0 ? workflow.slice(milestoneStart) : '';
const milestone = jobBlock(workflow, 'local-alpha-milestone');
const requiredWorkflowTokens = [
'alpha_artifact_scope:',
'default: local',
@@ -492,7 +504,7 @@ function auditLocalAlphaMilestoneWorkflow(root = DEFAULT_ROOT) {
"github.event_name == 'workflow_dispatch' && inputs.produce_alpha_artifacts && (inputs.alpha_artifact_scope == 'cluster' || inputs.alpha_artifact_scope == 'all')";
if (
countOccurrences(workflow, localScopeCondition) !== 3 ||
countOccurrences(workflow, clusterScopeCondition) !== 2
countOccurrences(workflow, clusterScopeCondition) !== 3
) {
findings.push('MILESTONE_SCOPE_CONTRACT_DRIFT');
}