Skip to content
Closed
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
50 changes: 35 additions & 15 deletions .github/scripts/bot_comment_auth_coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ function summarizeOrganicEvidence(records = [], options = {}) {
const eventCounts = Object.create(null);
const latestByComponentEvent = Object.create(null);

if (records.length === 0) {
return {
schema: 'workflows-bot-comment-auth-organic-evidence/v1',
required_events: requiredEvents,
required_components: components,
expected_mode: expectedMode === 'unknown' ? '' : expectedMode,
event_counts: eventCounts,
blockers: [],
status: 'no-data',
};
}

for (const record of records) {
if (!record.component || !record.event_name) continue;
eventCounts[record.component] ||= {};
Expand Down Expand Up @@ -310,9 +322,19 @@ function artifactFamilyFromSelection(artifact = {}) {
return '';
}

function componentCoverageStatus(blockers, policy, latest) {
if (blockers.length === 0) return 'pass';
if (!latest && policy.missing_record_severity === 'no-data') return 'no-data';
return 'warning';
}

function isComponentMissingBlocker(blocker) {
return Object.keys(COMPONENT_POLICIES).some((component) => blocker === `missing-${component}`);
}

function summarizeBotCommentAuthCoverage(records = [], options = {}) {
const policy = normalizePolicy(options);
const parseErrors = Number(options.parse_errors || options.parseErrors || 0);
const parseErrors = Number(options.parse_errors ?? options.parseErrors ?? 0);
const artifactSelection = normalizeArtifactSelectionSummary(
options.artifact_selection_report ?? options.artifactSelectionReport
);
Expand Down Expand Up @@ -357,20 +379,14 @@ function summarizeBotCommentAuthCoverage(records = [], options = {}) {
blockers.push(`expected-${componentPolicyConfig.expected_mode}-${component}`);
}
}
let status = 'pass';
if (blockers.length > 0) {
status = componentPolicyConfig.missing_record_severity === 'no-data' && !latest
? 'no-data'
: 'warning';
}
return {
component,
record_count: componentRecords.length,
latest,
expected_mode: componentPolicyConfig.expected_mode,
invalid_expected_mode: componentPolicyConfig.invalid_expected_mode,
allowed_modes: componentPolicyConfig.allowed_modes,
status,
status: componentCoverageStatus(blockers, componentPolicyConfig, latest),
blockers,
};
});
Expand All @@ -388,9 +404,8 @@ function summarizeBotCommentAuthCoverage(records = [], options = {}) {

let coverageStatus = 'pass';
if (authRecords.length === 0) {
coverageStatus = parseErrors > 0 || artifactSelectionWarning || authArtifactInputMismatch
? 'warning'
: 'no-data';
const nonMissingBlockers = blockers.filter((blocker) => !isComponentMissingBlocker(blocker));
coverageStatus = nonMissingBlockers.length > 0 ? 'warning' : 'no-data';
} else if (blockers.length > 0) {
coverageStatus = 'warning';
}
Expand Down Expand Up @@ -494,10 +509,15 @@ function isPotentialAuthCoverageFile(file) {
const normalized = cleanString(file).split(path.sep).join('/');
const basename = path.basename(normalized);
if (!normalized.endsWith('.json')) return false;
return normalized.includes('/bot-comment-auth-coverage-wrapper-') ||
normalized.includes('/bot-comment-auth-coverage-reusable-') ||
basename === 'wrapper.json' ||
basename === 'reusable.json';
const segments = normalized.split('/');
const hasWrapperArtifactDir = segments.some((segment) =>
segment.startsWith('bot-comment-auth-coverage-wrapper-')
);
const hasReusableArtifactDir = segments.some((segment) =>
segment.startsWith('bot-comment-auth-coverage-reusable-')
);
return (basename === 'wrapper.json' && hasWrapperArtifactDir) ||
(basename === 'reusable.json' && hasReusableArtifactDir);
}

function readJsonRecords(files = []) {
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/agents-weekly-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ jobs:
${{ vars.BOT_COMMENT_AUTH_HARD_BLOCK_APPROVED || 'false' }}
BOT_COMMENT_WRAPPER_EXPECTED_AUTH_MODE: >-
${{ vars.BOT_COMMENT_WRAPPER_EXPECTED_AUTH_MODE || 'client-id' }}
BOT_COMMENT_WRAPPER_ALLOWED_AUTH_MODES: >-
${{ vars.BOT_COMMENT_WRAPPER_ALLOWED_AUTH_MODES || 'client-id' }}
BOT_COMMENT_REUSABLE_EXPECTED_AUTH_MODE: >-
${{ vars.BOT_COMMENT_REUSABLE_EXPECTED_AUTH_MODE }}
BOT_COMMENT_REUSABLE_ALLOWED_AUTH_MODES: >-
Expand Down
Loading