mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 12:05:27 +08:00
feat(ql3): close cluster alpha milestone
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user