Skip to content

Commit 778def8

Browse files
authored
update flakiness report with min occurrences and merge matrix runs (#5900)
1 parent 65e18d0 commit 778def8

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.github/workflows/flakiness.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Flakiness Report
22

33
on:
44
schedule:
5-
- cron: '0 6 * * *'
5+
- cron: '0 6 * * 1'
66

77
jobs:
88
flakiness:
@@ -11,6 +11,8 @@ jobs:
1111
actions: read
1212
env:
1313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
DAYS: '7'
15+
OCCURRENCES: '2'
1416
steps:
1517
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1618
with:

scripts/flakiness.mjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { Octokit } from 'octokit'
66

7-
const { DAYS = '1' } = process.env
7+
const { DAYS = '1', OCCURRENCES = '1' } = process.env
88

99
const ONE_DAY = 24 * 60 * 60 * 1000
1010

@@ -24,6 +24,7 @@ const workflows = [
2424
]
2525

2626
const flaky = {}
27+
const reported = new Set()
2728

2829
async function checkWorkflowRuns (id, page = 1) {
2930
const response = await octokit.rest.actions.listWorkflowRuns({
@@ -79,10 +80,15 @@ async function checkWorkflowJobs (id, page = 1) {
7980
if (job.conclusion !== 'failure') continue
8081

8182
const workflow = job.workflow_name
83+
const name = job.name.split(' ')[0] // Merge matrix runs of same job together.
8284

83-
flaky[workflow] = flaky[workflow] || {}
84-
flaky[workflow][job.name] = flaky[workflow][job.name] || []
85-
flaky[workflow][job.name].push(job.html_url)
85+
flaky[workflow] ??= {}
86+
flaky[workflow][name] ??= []
87+
flaky[workflow][name].push(job.html_url)
88+
89+
if (flaky[workflow][name].length >= OCCURRENCES) {
90+
reported.add(workflow)
91+
}
8692
}
8793

8894
return checkWorkflowJobs(id, page + 1)
@@ -92,15 +98,17 @@ await Promise.all(workflows.map(w => checkWorkflowRuns(w)))
9298

9399
// TODO: Report this somewhere useful instead.
94100
if (Object.keys(flaky).length === 0) {
95-
console.log(`*No flaky jobs seen in the last ${DAYS > 1 ? `${DAYS} days` : 'day'}*`)
101+
console.log(`*No flaky jobs with at least ${OCCURRENCES} seen in the last ${DAYS > 1 ? `${DAYS} days` : 'day'}*`)
96102
} else {
97-
console.log(`*Flaky jobs seen in the last ${DAYS > 1 ? `${DAYS} days` : 'day'}*`)
103+
console.log(`*Flaky jobs with at least ${OCCURRENCES} seen in the last ${DAYS > 1 ? `${DAYS} days` : 'day'}*`)
98104
for (const [workflow, jobs] of Object.entries(flaky).sort()) {
105+
if (!reported.has(workflow)) continue
99106
console.log(`* ${workflow}`)
100107
for (const [job, urls] of Object.entries(jobs).sort()) {
108+
if (urls.length < OCCURRENCES) continue
101109
console.log(` * ${job}`)
102110
for (const url of urls.sort()) {
103-
console.log(` * ${url}`)
111+
console.log(` * [${url.replace('https://github.com/DataDog/', '')}](${url})`)
104112
}
105113
}
106114
}

0 commit comments

Comments
 (0)