Skip to content

Commit 8aa2584

Browse files
authored
Enable test retry for daily builds (#13086)
1 parent 834aea2 commit 8aa2584

File tree

9 files changed

+403
-10
lines changed

9 files changed

+403
-10
lines changed

.github/repository-settings.md

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ for [`dependabot/**/**`](https://github.com/open-telemetry/community/blob/main/d
7575
- Key is associated with [@trask](https://github.com/trask)'s gmail address
7676
- `SONATYPE_KEY` - owned by [@trask](https://github.com/trask)
7777
- `SONATYPE_USER` - owned by [@trask](https://github.com/trask)
78+
- `FLAKY_TEST_REPORTER_ACCESS_KEY` - owned by [@laurit](https://github.com/laurit)
7879

7980
### Organization secrets
8081

.github/workflows/build-common.yml

+30
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,36 @@ jobs:
290290
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
291291
run: cat build-scan.txt
292292

293+
- name: Get current job url
294+
id: jobs
295+
if: ${{ !cancelled() }}
296+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
297+
env:
298+
matrix: ${{ toJson(matrix) }}
299+
with:
300+
result-encoding: string
301+
script: |
302+
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
303+
owner: context.repo.owner,
304+
repo: context.repo.repo,
305+
run_id: context.runId,
306+
per_page: 100
307+
});
308+
const matrix = JSON.parse(process.env.matrix);
309+
const job_name = `common / test${ matrix['test-partition'] } (${ matrix['test-java-version'] }, ${ matrix.vm })`;
310+
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
311+
312+
- name: Flaky test report
313+
if: ${{ !cancelled() }}
314+
env:
315+
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
316+
JOB_URL: ${{ steps.jobs.outputs.result }}
317+
run: |
318+
if [ -s build-scan.txt ]; then
319+
export BUILD_SCAN_URL=$(cat build-scan.txt)
320+
fi
321+
./gradlew :test-report:reportFlakyTests
322+
293323
- name: Upload deadlock detector artifacts if any
294324
if: failure()
295325
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

.github/workflows/build-daily-no-build-cache.yml

-3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ jobs:
1010
common:
1111
uses: ./.github/workflows/build-common.yml
1212
with:
13-
max-test-retries: 0
1413
no-build-cache: true
1514

1615
test-latest-deps:
1716
uses: ./.github/workflows/reusable-test-latest-deps.yml
1817
with:
19-
max-test-retries: 0
2018
no-build-cache: true
2119

2220
test-indy:
2321
uses: ./.github/workflows/reusable-test-indy.yml
2422
with:
25-
max-test-retries: 0
2623
no-build-cache: true
2724

2825
# muzzle is not included here because it doesn't use gradle cache anyway and so is already covered

.github/workflows/build-daily.yml

-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ on:
99
jobs:
1010
common:
1111
uses: ./.github/workflows/build-common.yml
12-
with:
13-
max-test-retries: 0
1412

1513
test-latest-deps:
1614
uses: ./.github/workflows/reusable-test-latest-deps.yml
17-
with:
18-
max-test-retries: 0
1915

2016
test-indy:
2117
uses: ./.github/workflows/reusable-test-indy.yml
22-
with:
23-
max-test-retries: 0
2418

2519
muzzle:
2620
uses: ./.github/workflows/reusable-muzzle.yml

.github/workflows/reusable-test-indy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,33 @@ jobs:
8686
- name: Build scan
8787
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
8888
run: cat build-scan.txt
89+
90+
- name: Get current job url
91+
id: jobs
92+
if: ${{ !cancelled() }}
93+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
94+
env:
95+
matrix: ${{ toJson(matrix) }}
96+
with:
97+
result-encoding: string
98+
script: |
99+
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
run_id: context.runId,
103+
per_page: 100
104+
});
105+
const matrix = JSON.parse(process.env.matrix);
106+
const job_name = `test-indy / testIndy${ matrix['test-partition'] }`;
107+
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
108+
109+
- name: Flaky test report
110+
if: ${{ !cancelled() }}
111+
env:
112+
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
113+
JOB_URL: ${{ steps.jobs.outputs.result }}
114+
run: |
115+
if [ -s build-scan.txt ]; then
116+
export BUILD_SCAN_URL=$(cat build-scan.txt)
117+
fi
118+
./gradlew :test-report:reportFlakyTests

.github/workflows/reusable-test-latest-deps.yml

+30
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,36 @@ jobs:
8585
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
8686
run: cat build-scan.txt
8787

88+
- name: Get current job url
89+
id: jobs
90+
if: ${{ !cancelled() }}
91+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
92+
env:
93+
matrix: ${{ toJson(matrix) }}
94+
with:
95+
result-encoding: string
96+
script: |
97+
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
98+
owner: context.repo.owner,
99+
repo: context.repo.repo,
100+
run_id: context.runId,
101+
per_page: 100
102+
});
103+
const matrix = JSON.parse(process.env.matrix);
104+
const job_name = `test-latest-deps / testLatestDeps${ matrix['test-partition'] }`;
105+
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
106+
107+
- name: Flaky test report
108+
if: ${{ !cancelled() }}
109+
env:
110+
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
111+
JOB_URL: ${{ steps.jobs.outputs.result }}
112+
run: |
113+
if [ -s build-scan.txt ]; then
114+
export BUILD_SCAN_URL=$(cat build-scan.txt)
115+
fi
116+
./gradlew :test-report:reportFlakyTests
117+
88118
- name: Upload deadlock detector artifacts if any
89119
if: failure()
90120
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

settings.gradle.kts

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ develocity {
5454
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
5555
termsOfUseAgree.set("yes")
5656

57-
if (!gradle.startParameter.taskNames.contains("listTestsInPartition")) {
57+
if (!gradle.startParameter.taskNames.contains("listTestsInPartition") &&
58+
!gradle.startParameter.taskNames.contains(":test-report:reportFlakyTests")) {
5859
buildScanPublished {
5960
File("build-scan.txt").printWriter().use { writer ->
6061
writer.println(buildScanUri)
@@ -97,6 +98,7 @@ include(":instrumentation-annotations-support-testing")
9798

9899
// misc
99100
include(":dependencyManagement")
101+
include(":test-report")
100102
include(":testing:agent-exporter")
101103
include(":testing:agent-for-testing")
102104
include(":testing:armeria-shaded-for-testing")

test-report/build.gradle.kts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plugins {
2+
id("otel.java-conventions")
3+
}
4+
5+
dependencies {
6+
implementation("com.google.api-client:google-api-client:2.7.1")
7+
implementation("com.google.apis:google-api-services-sheets:v4-rev20250106-2.0.0")
8+
implementation("com.google.auth:google-auth-library-oauth2-http:1.30.1")
9+
}
10+
11+
otelJava {
12+
minJavaVersionSupported.set(JavaVersion.VERSION_17)
13+
}
14+
15+
tasks {
16+
val reportFlakyTests by registering(JavaExec::class) {
17+
dependsOn(classes)
18+
19+
mainClass.set("io.opentelemetry.instrumentation.testreport.FlakyTestReporter")
20+
classpath(sourceSets["main"].runtimeClasspath)
21+
22+
systemProperty("scanPath", project.rootDir)
23+
systemProperty("googleSheetsAccessKey", System.getenv("FLAKY_TEST_REPORTER_ACCESS_KEY"))
24+
systemProperty("buildScanUrl", System.getenv("BUILD_SCAN_URL"))
25+
systemProperty("jobUrl", System.getenv("JOB_URL"))
26+
}
27+
}

0 commit comments

Comments
 (0)