Skip to content

Commit

Permalink
Enable test retry for daily builds (#13086)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Jan 24, 2025
1 parent 834aea2 commit 8aa2584
Show file tree
Hide file tree
Showing 9 changed files with 403 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/repository-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ for [`dependabot/**/**`](https://github.com/open-telemetry/community/blob/main/d
- Key is associated with [@trask](https://github.com/trask)'s gmail address
- `SONATYPE_KEY` - owned by [@trask](https://github.com/trask)
- `SONATYPE_USER` - owned by [@trask](https://github.com/trask)
- `FLAKY_TEST_REPORTER_ACCESS_KEY` - owned by [@laurit](https://github.com/laurit)

### Organization secrets

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/build-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,36 @@ jobs:
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt

- name: Get current job url
id: jobs
if: ${{ !cancelled() }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
matrix: ${{ toJson(matrix) }}
with:
result-encoding: string
script: |
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100
});
const matrix = JSON.parse(process.env.matrix);
const job_name = `common / test${ matrix['test-partition'] } (${ matrix['test-java-version'] }, ${ matrix.vm })`;
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
- name: Flaky test report
if: ${{ !cancelled() }}
env:
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
JOB_URL: ${{ steps.jobs.outputs.result }}
run: |
if [ -s build-scan.txt ]; then
export BUILD_SCAN_URL=$(cat build-scan.txt)
fi
./gradlew :test-report:reportFlakyTests
- name: Upload deadlock detector artifacts if any
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-daily-no-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ jobs:
common:
uses: ./.github/workflows/build-common.yml
with:
max-test-retries: 0
no-build-cache: true

test-latest-deps:
uses: ./.github/workflows/reusable-test-latest-deps.yml
with:
max-test-retries: 0
no-build-cache: true

test-indy:
uses: ./.github/workflows/reusable-test-indy.yml
with:
max-test-retries: 0
no-build-cache: true

# muzzle is not included here because it doesn't use gradle cache anyway and so is already covered
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ on:
jobs:
common:
uses: ./.github/workflows/build-common.yml
with:
max-test-retries: 0

test-latest-deps:
uses: ./.github/workflows/reusable-test-latest-deps.yml
with:
max-test-retries: 0

test-indy:
uses: ./.github/workflows/reusable-test-indy.yml
with:
max-test-retries: 0

muzzle:
uses: ./.github/workflows/reusable-muzzle.yml
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/reusable-test-indy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,33 @@ jobs:
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt

- name: Get current job url
id: jobs
if: ${{ !cancelled() }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
matrix: ${{ toJson(matrix) }}
with:
result-encoding: string
script: |
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100
});
const matrix = JSON.parse(process.env.matrix);
const job_name = `test-indy / testIndy${ matrix['test-partition'] }`;
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
- name: Flaky test report
if: ${{ !cancelled() }}
env:
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
JOB_URL: ${{ steps.jobs.outputs.result }}
run: |
if [ -s build-scan.txt ]; then
export BUILD_SCAN_URL=$(cat build-scan.txt)
fi
./gradlew :test-report:reportFlakyTests
30 changes: 30 additions & 0 deletions .github/workflows/reusable-test-latest-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,36 @@ jobs:
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt

- name: Get current job url
id: jobs
if: ${{ !cancelled() }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
matrix: ${{ toJson(matrix) }}
with:
result-encoding: string
script: |
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100
});
const matrix = JSON.parse(process.env.matrix);
const job_name = `test-latest-deps / testLatestDeps${ matrix['test-partition'] }`;
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
- name: Flaky test report
if: ${{ !cancelled() }}
env:
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
JOB_URL: ${{ steps.jobs.outputs.result }}
run: |
if [ -s build-scan.txt ]; then
export BUILD_SCAN_URL=$(cat build-scan.txt)
fi
./gradlew :test-report:reportFlakyTests
- name: Upload deadlock detector artifacts if any
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ develocity {
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")

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

// misc
include(":dependencyManagement")
include(":test-report")
include(":testing:agent-exporter")
include(":testing:agent-for-testing")
include(":testing:armeria-shaded-for-testing")
Expand Down
27 changes: 27 additions & 0 deletions test-report/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
id("otel.java-conventions")
}

dependencies {
implementation("com.google.api-client:google-api-client:2.7.1")
implementation("com.google.apis:google-api-services-sheets:v4-rev20250106-2.0.0")
implementation("com.google.auth:google-auth-library-oauth2-http:1.30.1")
}

otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}

tasks {
val reportFlakyTests by registering(JavaExec::class) {
dependsOn(classes)

mainClass.set("io.opentelemetry.instrumentation.testreport.FlakyTestReporter")
classpath(sourceSets["main"].runtimeClasspath)

systemProperty("scanPath", project.rootDir)
systemProperty("googleSheetsAccessKey", System.getenv("FLAKY_TEST_REPORTER_ACCESS_KEY"))
systemProperty("buildScanUrl", System.getenv("BUILD_SCAN_URL"))
systemProperty("jobUrl", System.getenv("JOB_URL"))
}
}
Loading

0 comments on commit 8aa2584

Please sign in to comment.