Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ecbf30d
chore: bump node to 26.12.1 and align @types/node with core
cryptodev-2s Nov 11, 2026
d832297
chore: use node 26.13.1, the latest lts
cryptodev-2s Nov 12, 2026
3694b7f
chore: use node 24 lts to keep corepack for workflows reading .nvmrc
cryptodev-2s Nov 12, 2026
431a32f
chore: upgrade yarn to 4.17.1 and replace constraints.pro with yarn.c…
cryptodev-2s Nov 11, 2026
92d5dfb
chore: align yarn.config.cjs comments with core
cryptodev-2s Nov 12, 2026
a510f9a
chore: keep the original comments and formatting in .yarnrc.yml
cryptodev-2s Nov 12, 2026
e2d6326
chore: check the single workspace in yarn.config.cjs like the old con…
cryptodev-2s Nov 16, 2026
319b41f
chore: upgrade yarn to 4.18.1
cryptodev-2s Nov 16, 2026
3361e89
chore: migrate from eslint to oxlint
cryptodev-2s Nov 11, 2026
f1eec7e
chore: prune stale oxlint suppressions
cryptodev-2s Nov 12, 2026
b2060c9
chore: limit the process.env override to .github
cryptodev-2s Nov 12, 2026
290b0b6
chore: use oxfmt instead of prettier and update the oxlint packages
cryptodev-2s Nov 12, 2026
f7ead3b
chore: turn off no-floating-promises for the node:test tests
cryptodev-2s Nov 16, 2026
fd758ab
chore: keep prettier as a dependency for the changelog tooling
cryptodev-2s Nov 16, 2026
b4eec1b
chore: format the oxlint suppressions file like core instead of ignor…
cryptodev-2s Nov 16, 2026
72497ef
chore: stop ignoring .yarn in oxfmt like core
cryptodev-2s Nov 16, 2026
c1c0295
chore: align dependencies with latest versions
cryptodev-2s Nov 11, 2026
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
4 changes: 3 additions & 1 deletion .depcheckrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@types/*",
"prettier-plugin-packagejson",
"@yarnpkg/types",
"eslint-plugin-n",
"oxlint-tsgolint",
"@swc/cli",
"@swc/core",
"ts-node",
Expand Down
64 changes: 0 additions & 64 deletions .eslintrc.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/env node

import { Octokit } from '@octokit/rest';
import { downloadArtifactZip, findFilesInZip } from './lib/artifact-download.mjs';
import { parsePlaywrightJsonReport } from './lib/parse-playwright-json.mjs';
import { createSlackBlocks, sendSlackBatched } from './lib/slack-test-health-blocks.mjs';

import {
downloadArtifactZip,
findFilesInZip,
} from './lib/artifact-download.mjs';
import { partitionSummary } from './lib/classify-report-buckets.mjs';
import { parsePlaywrightJsonReport } from './lib/parse-playwright-json.mjs';
import {
createSlackBlocks,
sendSlackBatched,
} from './lib/slack-test-health-blocks.mjs';
import { summarizeTestHealth } from './lib/summarize-test-health.mjs';
import { getDateRange, getWorkflowRuns } from './lib/workflow-runs.mjs';

Expand All @@ -28,7 +35,8 @@ const env = {
WORKFLOW_IDS: process.env.WORKFLOW_IDS,
BRANCH: process.env.BRANCH || 'main',
LOOKBACK_DAYS: parsePositiveInt(process.env.LOOKBACK_DAYS, 1),
ARTIFACT_NAME_PREFIX: process.env.ARTIFACT_NAME_PREFIX || 'playwright-json-report',
ARTIFACT_NAME_PREFIX:
process.env.ARTIFACT_NAME_PREFIX || 'playwright-json-report',
RESULTS_FILE_PATTERN: process.env.RESULTS_FILE_PATTERN || 'playwright-report',
TOP_N: parsePositiveInt(process.env.TOP_N, 15),
REPORT_TITLE: process.env.REPORT_TITLE || 'Playwright Test Health Report',
Expand All @@ -46,16 +54,22 @@ if (!env.WORKFLOW_IDS) {

function getWorkflowIds() {
return env.WORKFLOW_IDS.split(',')
.map(value => value.trim())
.map((value) => value.trim())
.filter(Boolean);
}

function isTestFailureFinding(finding) {
return finding.classification === 'broken' || finding.classification === 'flaky' || finding.classification === 'infra';
return (
finding.classification === 'broken' ||
finding.classification === 'flaky' ||
finding.classification === 'infra'
);
}

function countTestFailureRuns(findings) {
return new Set(findings.filter(isTestFailureFinding).map(finding => finding.runId)).size;
return new Set(
findings.filter(isTestFailureFinding).map((finding) => finding.runId),
).size;
}

async function getMergedWorkflowRuns(github, dateRange) {
Expand All @@ -74,7 +88,9 @@ async function getMergedWorkflowRuns(github, dateRange) {
runs.push(...workflowRuns);
}

const dedupedRuns = Array.from(new Map(runs.map(run => [run.id, run])).values());
const dedupedRuns = Array.from(
new Map(runs.map((run) => [run.id, run])).values(),
);
dedupedRuns.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
return dedupedRuns;
}
Expand All @@ -95,7 +111,9 @@ async function collectFindings(github, runs) {
},
);

const matching = artifacts.filter(artifact => artifact.name.startsWith(env.ARTIFACT_NAME_PREFIX));
const matching = artifacts.filter((artifact) =>
artifact.name.startsWith(env.ARTIFACT_NAME_PREFIX),
);
matchingArtifacts += matching.length;

if (matching.length === 0) {
Expand All @@ -113,7 +131,9 @@ async function collectFindings(github, runs) {
const jsonFiles = findFilesInZip(zip, env.RESULTS_FILE_PATTERN);

if (jsonFiles.length === 0) {
console.log(` ⚠️ No ${env.RESULTS_FILE_PATTERN} file found in ${artifact.name}`);
console.log(
` ⚠️ No ${env.RESULTS_FILE_PATTERN} file found in ${artifact.name}`,
);
continue;
}

Expand All @@ -124,17 +144,23 @@ async function collectFindings(github, runs) {
findings.push(
...parsePlaywrightJsonReport(report, {
runId: run.id,
runUrl: run.html_url || `https://github.com/${env.OWNER}/${env.REPOSITORY}/actions/runs/${run.id}`,
runUrl:
run.html_url ||
`https://github.com/${env.OWNER}/${env.REPOSITORY}/actions/runs/${run.id}`,
date: run.created_at,
artifactName: artifact.name,
}),
);
} catch (error) {
console.log(` ❌ Invalid JSON in ${artifact.name}/${file.path}: ${error.message}`);
console.log(
` ❌ Invalid JSON in ${artifact.name}/${file.path}: ${error.message}`,
);
}
}
} catch (error) {
console.log(` ❌ Failed to process artifact ${artifact.name}: ${error.message}`);
console.log(
` ❌ Failed to process artifact ${artifact.name}: ${error.message}`,
);
}
}
}
Expand Down Expand Up @@ -166,21 +192,24 @@ async function sendSlackReport(summary, dateDisplay, metadata) {
}

function logClassificationDiagnostics(summary, metadata) {
const { brokenItems, flakyItems, watchItems, infraItems } = partitionSummary(summary);
const { brokenItems, flakyItems, watchItems, infraItems } =
partitionSummary(summary);

console.log('\n🧾 Classification diagnostics');
console.log(` Lookback: ${env.LOOKBACK_DAYS} day(s)`);
console.log(` Unique tests observed: ${summary.length}`);
console.log(
` Buckets -> failing: ${brokenItems.length}, infra: ${infraItems.length}, flaky: ${flakyItems.length}, watch: ${watchItems.length}`,
);
console.log(` CI runs: ${metadata.workflowCount} | Test-failure runs: ${metadata.testFailureRunCount}`);
console.log(
` CI runs: ${metadata.workflowCount} | Test-failure runs: ${metadata.testFailureRunCount}`,
);
console.log(` Other CI failures: ${metadata.otherFailedRunCount}`);

if (watchItems.length > 0) {
const preview = watchItems
.slice(0, 5)
.map(test => {
.map((test) => {
const broken = test.historicalBrokenCount ?? 0;
const flaky = test.historicalFlakyCount ?? 0;
return `${test.name} (${test.projectName}, failed ${broken}, flaky ${flaky})`;
Expand Down Expand Up @@ -208,16 +237,24 @@ async function main() {
return;
}

const failedRunCount = workflowRuns.filter(run => run.conclusion === 'failure').length;
const { findings, matchingArtifacts } = await collectFindings(github, workflowRuns);
const failedRunCount = workflowRuns.filter(
(run) => run.conclusion === 'failure',
).length;
const { findings, matchingArtifacts } = await collectFindings(
github,
workflowRuns,
);

if (matchingArtifacts === 0) {
console.log('⚠️ No matching artifacts found.');
return;
}

const testFailureRunCount = countTestFailureRuns(findings);
const otherFailedRunCount = Math.max(0, failedRunCount - testFailureRunCount);
const otherFailedRunCount = Math.max(
0,
failedRunCount - testFailureRunCount,
);
const summary = summarizeTestHealth(findings);

logClassificationDiagnostics(summary, {
Expand All @@ -235,16 +272,20 @@ async function main() {
} catch (error) {
console.error('❌ Error:', error.message);
if (error.status === 401) {
console.log('\n💡 GitHub token is unauthorized. Ensure it has repo and actions:read permissions.');
console.log(
'\n💡 GitHub token is unauthorized. Ensure it has repo and actions:read permissions.',
);
}
if (error.status === 404) {
console.log('\n💡 One or more workflows were not found. Check WORKFLOW_IDS values.');
console.log(
'\n💡 One or more workflows were not found. Check WORKFLOW_IDS values.',
);
}
process.exit(1);
}
}

main().catch(error => {
main().catch((error) => {
console.error('\n❌ Unexpected error:', error);
process.exit(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export async function downloadArtifactZip(github, { owner, repo, artifactId }) {
}

export function findFilesInZip(zip, filePattern) {
return zip.files.filter(file => {
return zip.files.filter((file) => {
const fileName = path.basename(file.path);
return file.path.startsWith(filePattern) || fileName.startsWith(filePattern);
return (
file.path.startsWith(filePattern) || fileName.startsWith(filePattern)
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export function instabilityScore(test) {

export function partitionSummary(summary) {
const infraItems = summary
.filter(test => test.latestClassification === 'infra')
.filter((test) => test.latestClassification === 'infra')
.sort((a, b) => (b.infraCount ?? 0) - (a.infraCount ?? 0));

const brokenItems = summary
.filter(test => test.latestClassification === 'broken')
.filter((test) => test.latestClassification === 'broken')
.sort((a, b) => historicalBroken(b) - historicalBroken(a));

const flakyItems = summary
.filter(test => test.latestClassification === 'flaky')
.filter((test) => test.latestClassification === 'flaky')
.sort((a, b) => historicalFlaky(b) - historicalFlaky(a));

const watchItems = summary
.filter(
test =>
(test) =>
test.latestClassification === 'passed' &&
(historicalBroken(test) > 0 || historicalFlaky(test) > 0),
)
Expand All @@ -44,9 +44,18 @@ export function partitionSummary(summary) {
export function allocateBucketSlots(topN, counts) {
const { broken = 0, flaky = 0, watch = 0, infra = 0 } = counts;

let maxBroken = Math.min(broken, Math.max(Math.ceil(topN * 0.4), broken > 0 ? 2 : 0));
let maxFlaky = Math.min(flaky, Math.max(Math.ceil(topN * 0.25), flaky > 0 ? 2 : 0));
let maxInfra = Math.min(infra, Math.max(Math.ceil(topN * 0.1), infra > 0 ? 1 : 0));
let maxBroken = Math.min(
broken,
Math.max(Math.ceil(topN * 0.4), broken > 0 ? 2 : 0),
);
let maxFlaky = Math.min(
flaky,
Math.max(Math.ceil(topN * 0.25), flaky > 0 ? 2 : 0),
);
let maxInfra = Math.min(
infra,
Math.max(Math.ceil(topN * 0.1), infra > 0 ? 1 : 0),
);
let maxWatch = Math.min(watch, topN - maxBroken - maxFlaky - maxInfra);

let remaining = topN - (maxBroken + maxFlaky + maxWatch + maxInfra);
Expand All @@ -67,7 +76,9 @@ export function allocateBucketSlots(topN, counts) {
remaining -= extra;
}

const byKey = Object.fromEntries(buckets.map(bucket => [bucket.key, bucket.max]));
const byKey = Object.fromEntries(
buckets.map((bucket) => [bucket.key, bucket.max]),
);

return {
maxBroken: byKey.broken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function normalizeRepoFilePath(filePath, { prefix } = {}) {

let normalized = String(filePath).replace(/\\/g, '/');

const isAbsolute = normalized.startsWith('/') || /^[A-Za-z]:\//.test(normalized);
const isAbsolute =
normalized.startsWith('/') || /^[A-Za-z]:\//.test(normalized);
if (isAbsolute) {
const testsMatch = normalized.match(/(?:^|\/)(tests\/.+)$/);
if (testsMatch) {
Expand All @@ -34,7 +35,10 @@ export function normalizeRepoFilePath(filePath, { prefix } = {}) {

normalized = normalized.replace(/^\/+/, '');

const cleanPrefix = prefix?.trim().replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
const cleanPrefix = prefix
?.trim()
.replace(/\\/g, '/')
.replace(/^\/+|\/+$/g, '');
if (cleanPrefix) {
const alreadyPrefixed =
normalized === cleanPrefix ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ function extractFirstFailureError(test) {
if (!firstFailure) {
return 'No error details';
}
return firstFailure?.error?.message ?? firstFailure?.errors?.[0]?.message ?? 'No error details';
return (
firstFailure?.error?.message ??
firstFailure?.errors?.[0]?.message ??
'No error details'
);
}

function extractInfraError(error) {
Expand Down
Loading
Loading