mirror of
https://github.com/gradle/actions.git
synced 2025-04-19 01:09:20 +08:00
Record build failure for task failure in included build
This commit is contained in:
parent
d9e39adac8
commit
b9c6da94c2
@ -41,7 +41,7 @@ abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder
|
||||
// Got EVALUATE SETTINGS event: not a config-cache hit"
|
||||
configCacheHit = false
|
||||
}
|
||||
if (buildOperation.details in RunRootBuildWorkBuildOperationType.Details) {
|
||||
if (buildOperation.metadata == BuildOperationCategory.RUN_WORK) {
|
||||
if (finishEvent.failure != null) {
|
||||
buildFailed = true
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ if (isTopLevelBuild) {
|
||||
|
||||
def atLeastGradle3 = version >= GradleVersion.version("3.0")
|
||||
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
||||
def atLeastGradle7 = version >= GradleVersion.version("7.0")
|
||||
|
||||
def invocationId = "-${System.currentTimeMillis()}"
|
||||
|
||||
if (atLeastGradle6) {
|
||||
// By default, use standard mechanisms to capture build results
|
||||
def useBuildService = version >= GradleVersion.version("6.6")
|
||||
if (useBuildService) {
|
||||
// Use BuildService for modern Gradle versions
|
||||
if (atLeastGradle7) {
|
||||
captureUsingBuildService(invocationId)
|
||||
} else {
|
||||
captureUsingBuildFinished(gradle, invocationId, resultsWriter)
|
||||
|
@ -23,7 +23,6 @@ class BaseInitScriptTest extends Specification {
|
||||
static final TestGradleVersion GRADLE_4_X = new TestGradleVersion(GradleVersion.version('4.10.3'), 7, 10)
|
||||
static final TestGradleVersion GRADLE_5_X = new TestGradleVersion(GradleVersion.version('5.6.4'), 8, 12)
|
||||
static final TestGradleVersion GRADLE_6_0 = new TestGradleVersion(GradleVersion.version('6.0.1'), 8, 13)
|
||||
static final TestGradleVersion GRADLE_6_NO_BUILD_SERVICE = new TestGradleVersion(GradleVersion.version('6.5.1'), 8, 14)
|
||||
static final TestGradleVersion GRADLE_6_X = new TestGradleVersion(GradleVersion.version('6.9.4'), 8, 15)
|
||||
static final TestGradleVersion GRADLE_7_1 = new TestGradleVersion(GradleVersion.version('7.1.1'), 8, 16)
|
||||
static final TestGradleVersion GRADLE_7_X = new TestGradleVersion(GradleVersion.version('7.6.2'), 8, 19)
|
||||
@ -35,7 +34,6 @@ class BaseInitScriptTest extends Specification {
|
||||
GRADLE_4_X,
|
||||
GRADLE_5_X,
|
||||
GRADLE_6_0,
|
||||
GRADLE_6_NO_BUILD_SERVICE, // Last version without build service support
|
||||
GRADLE_6_X,
|
||||
GRADLE_7_1,
|
||||
GRADLE_7_X,
|
||||
|
@ -34,6 +34,42 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
||||
testGradleVersion << ALL_VERSIONS
|
||||
}
|
||||
|
||||
def "produces build results file for build that fails in included build with #testGradleVersion"() {
|
||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||
|
||||
when:
|
||||
def includedBuildRoot = new File(testProjectDir, 'included-build')
|
||||
includedBuildRoot.mkdir()
|
||||
def includedSettings = new File(includedBuildRoot, 'settings.gradle')
|
||||
def includedBuild = new File(includedBuildRoot, 'build.gradle')
|
||||
|
||||
includedSettings << """
|
||||
rootProject.name = 'included-build'
|
||||
"""
|
||||
includedBuild << '''
|
||||
task expectFailure {
|
||||
doLast {
|
||||
throw new RuntimeException("Expected to fail in included build")
|
||||
}
|
||||
}
|
||||
'''
|
||||
settingsFile << """
|
||||
includeBuild('included-build')
|
||||
"""
|
||||
buildFile << """
|
||||
task expectFailure {
|
||||
dependsOn(gradle.includedBuild('included-build').task(':expectFailure'))
|
||||
}
|
||||
"""
|
||||
runAndFail(testGradleVersion.gradleVersion)
|
||||
|
||||
then:
|
||||
assertResults('expectFailure', testGradleVersion, true)
|
||||
|
||||
where:
|
||||
testGradleVersion << ALL_VERSIONS
|
||||
}
|
||||
|
||||
def "produces build results file for build with --configuration-cache on #testGradleVersion"() {
|
||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user