Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
# --continue: Keep running even if a test fails
# -PcommitId Prevent the Git SHA being written into the jar files (which breaks caching)
timeout-minutes: 180 # 3 hours
continue-on-error: true
run: |
./gradlew --build-cache --scan --continue \
-PtestLoggingEvents=started,passed,skipped,failed \
Expand Down
43 changes: 33 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ext {
maxTestForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : Runtime.runtime.availableProcessors()
maxScalacThreads = project.hasProperty('maxScalacThreads') ? maxScalacThreads.toInteger() :
Math.min(Runtime.runtime.availableProcessors(), 8)
userIgnoreFailures = project.hasProperty('ignoreFailures') ? ignoreFailures : false
userIgnoreFailures = project.hasProperty('ignoreFailures') ? ignoreFailures.toBoolean() : false

userMaxTestRetries = project.hasProperty('maxTestRetries') ? maxTestRetries.toInteger() : 0
userMaxTestRetryFailures = project.hasProperty('maxTestRetryFailures') ? maxTestRetryFailures.toInteger() : 0
Expand Down Expand Up @@ -470,8 +470,13 @@ subprojects {
def testsToExclude = ['**/*Suite.class']

test {
ext {
isGithubActions = System.getenv('GITHUB_ACTIONS') != null
hadFailure = false // Used to track if any tests failed, see afterSuite below
}

maxParallelForks = maxTestForks
ignoreFailures = userIgnoreFailures
ignoreFailures = userIgnoreFailures || ext.isGithubActions

maxHeapSize = defaultMaxHeapSize
jvmArgs = defaultJvmArgs
Expand Down Expand Up @@ -499,6 +504,32 @@ subprojects {
maxFailures = userMaxTestRetryFailures
}
}

// As we process results, check if there were any test failures.
afterSuite { desc, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
Comment thread
chia7712 marked this conversation as resolved.
ext.hadFailure = true
}
}

// This closure will copy JUnit XML files out of the sub-project's build directory and into
// a top-level build/junit-xml directory. This is necessary to avoid reporting on tests which
// were not run, but instead were restored via FROM-CACHE. See KAFKA-17479 for more details.
doLast {
if (ext.isGithubActions) {
def dest = rootProject.layout.buildDirectory.dir("junit-xml/${project.name}").get().asFile
println "Copy JUnit XML for ${project.name} to $dest"
ant.copy(todir: "$dest") {
ant.fileset(dir: "${test.reports.junitXml.entryPoint}")
}

// If there were any test failures, we want to fail the task to prevent the failures
// from being cached.
if (ext.hadFailure) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the retry issue is still existent in normal PR. We can't use the "retry" to convert the result from "failed" to "successful". Maybe we can remove the -PmaxTestRetries=1 -PmaxTestRetryFailures=10 directly? Personally, I'd like to make tests stable instead of retry.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'd like to make tests stable instead of retry.

Yes, agreed. 😄 Until we get the tests in better shape, I think the retry thing is okay.

It seems the retry issue is still existent in normal PR

Normal PR will look like:

  • Any failure (flaky or not) will cause Gradle to exit with 1
  • continue-on-error: true will mark that step green (I think... need to verify this)
  • "Parse JUnit tests" will process the results correctly and exit 0 if only flaky, exit 1 if any true failures

So the overall CI workflow will be green if there are only flaky failures. Red if there are any real failures.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the overall CI workflow will be green if there are only flaky failures. Red if there are any real failures.

Got it. Thanks for detailed explanation

throw new GradleException("Failing this task since '${project.name}:${name}' had test failures.")
}
}
}
}

task integrationTest(type: Test, dependsOn: compileJava) {
Expand Down Expand Up @@ -569,14 +600,6 @@ subprojects {
delete t.reports.junitXml.outputLocation
delete t.reports.html.outputLocation
}

doLast {
def dest = rootProject.layout.buildDirectory.dir("junit-xml/${project.name}").get().asFile
println "Copy JUnit XML for ${project.name} to $dest"
ant.copy(todir: "$dest") {
ant.fileset(dir: "${test.reports.junitXml.entryPoint}")
}
}
}

jar {
Expand Down