Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-2163: Disable dependencies check task by default #102

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
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ class DdAndroidGradlePlugin @Inject constructor(
extension,
variant
)
if (extensionConfiguration.checkProjectDependencies == SdkCheckLevel.NONE) {
if (extensionConfiguration.checkProjectDependencies == SdkCheckLevel.NONE ||
extensionConfiguration.checkProjectDependencies == null
) {
return null
}
val checkDepsTaskName = "checkSdkDeps${variant.name.capitalize()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ open class DdExtensionConfiguration(

/**
* This property controls if plugin should check if Datadog SDK is included in the dependencies
* and if it is not: "none" - ignore, "warn" - log a warning, "fail" - fail the build
* with an error (default).
* and if it is not: "none" - ignore (default), "warn" - log a warning, "fail" - fail the build
* with an error.
*/
// TODO RUMM-2344
var checkProjectDependencies: SdkCheckLevel? = null

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.testkit.runner.internal.PluginUnderTestMetadataReading
import org.junit.Ignore
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.Extensions
Expand Down Expand Up @@ -201,13 +201,14 @@ internal class DdAndroidGradlePluginFunctionalTest {
.isEqualTo(TaskOutcome.SUCCESS)
}

@Ignore(
@Disabled(
"This test is ignored for now because of these tasks: " +
"collect[Flavour1][Flavour2]ReleaseDependencies. This is caused under the hood" +
"by this task: PerModuleReportDependenciesTask which accesses the project object" +
"inside the action method. " +
"There is already an opened issue here: /~https://github.com/gradle/gradle/issues/12871"
)
@Test
fun `M success W assembleRelease { configuration cache, checkProjectDependencies enabled }`() {
// TODO: https://datadoghq.atlassian.net/browse/RUMM-1894

Expand All @@ -229,12 +230,13 @@ internal class DdAndroidGradlePluginFunctionalTest {
.isEqualTo(TaskOutcome.SUCCESS)
}

@Ignore(
@Disabled(
"This test is ignored for now as we are using the Configuration object at the " +
"task action level in our DdCheckSdkDepsTask and this is breaking " +
"the --configuration-cache. There is no workaround this yet and this is " +
"also present in some internal build.gradle tasks (see the test comment above)"
)
@Test
fun `M success W assembleDebug { configuration cache, checkProjectDependencies enabled }`() {
// TODO: https://datadoghq.atlassian.net/browse/RUMM-1893

Expand Down Expand Up @@ -277,13 +279,14 @@ internal class DdAndroidGradlePluginFunctionalTest {
.isEqualTo(TaskOutcome.SUCCESS)
}

@Ignore(
@Disabled(
"This test is ignored for now because of these tasks: " +
"collect[Flavour1][Flavour2]ReleaseDependencies. This is caused under the hood" +
"by this task: PerModuleReportDependenciesTask which accesses the project object" +
"inside the action method. " +
"There is already an opened issue here: /~https://github.com/gradle/gradle/issues/12871"
)
@Test
fun `M success W assembleRelease { configuration cache, checkDependencies disabled }`() {
// TODO: https://datadoghq.atlassian.net/browse/RUMM-1894

Expand Down Expand Up @@ -357,6 +360,7 @@ internal class DdAndroidGradlePluginFunctionalTest {
}
}

@Disabled("RUMM-2344")
@Test
fun `M fail W assembleRelease { Datadog SDK not in deps }`() {
// Given
Expand All @@ -373,6 +377,7 @@ internal class DdAndroidGradlePluginFunctionalTest {
.buildAndFail()
}

@Disabled("RUMM-2344")
@Test
fun `M fail W assembleDebug { Datadog SDK not in deps }`() {
// Given
Expand All @@ -389,6 +394,48 @@ internal class DdAndroidGradlePluginFunctionalTest {
.buildAndFail()
}

// TODO remove once RUMM-2344 is done
@Test
fun `M success W assembleRelease { Datadog SDK not in deps }`() {
// Given
stubGradleBuildFromResourceFile(
"build_without_datadog_dep.gradle",
appBuildGradleFile
)

// When
val result = GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments(":samples:app:assembleRelease")
.withPluginClasspath(getTestConfigurationClasspath())
.build()

// Then
assertThat(result.task(":samples:app:assembleRelease")?.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
}

// TODO remove once RUMM-2344 is done
@Test
fun `M success W assembleDebug { Datadog SDK not in deps }`() {
// Given
stubGradleBuildFromResourceFile(
"build_without_datadog_dep.gradle",
appBuildGradleFile
)

// When
val result = GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments(":samples:app:assembleDebug")
.withPluginClasspath(getTestConfigurationClasspath())
.build()

// Then
assertThat(result.task(":samples:app:assembleDebug")?.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
}

// endregion

// region Upload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,9 @@ internal class DdAndroidGradlePluginTest {

// region configureVariantForSdkCheck

// TODO RUMM-2344 switch back to FAIL
@Test
fun `𝕄 use FAIL when configuring checkDepsTask { checkProjectDependencies not set }`(
fun `𝕄 use NONE when configuring checkDepsTask { checkProjectDependencies not set }`(
@StringForgery(case = Case.LOWER) flavorName: String,
@StringForgery(case = Case.LOWER) buildTypeName: String,
@StringForgery versionName: String,
Expand Down Expand Up @@ -780,15 +781,7 @@ internal class DdAndroidGradlePluginTest {
fakeExtension
)

val task = checkSdkDepsTaskProvider?.get()

assertThat(task).isNotNull()
assertThat(task?.sdkCheckLevel?.get())
.isEqualTo(SdkCheckLevel.FAIL)
assertThat(task?.configurationName?.get())
.isEqualTo(configurationName)
assertThat(task?.variantName?.get())
.isEqualTo(variantName)
assertThat(checkSdkDepsTaskProvider).isNull()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ android {
datadog {
checkProjectDependencies = "warn"
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
demo {
Expand All @@ -60,6 +56,10 @@ android {
}
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

datadog {
remoteRepositoryUrl = "http://github.com:fakeapp/repository.git"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
demo {
Expand All @@ -59,3 +55,7 @@ android {
}
}
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation(project(':samples:lib-module'))
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
demo {
Expand All @@ -60,3 +55,8 @@ android {
}
}
}

dependencies {
implementation(project(':samples:lib-module'))
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
demo {
Expand All @@ -52,3 +48,7 @@ android {
}
}
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
demo {
Expand All @@ -60,6 +56,10 @@ android {
}
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

datadog {
mappingFilePackageAliases = ["java.lang": "jl"]
mappingFileTrimIndents = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

flavorDimensions("version", "colour")
productFlavors {
pro {
Expand All @@ -55,6 +51,10 @@ android {
}
}

dependencies {
implementation("com.datadoghq:dd-sdk-android:1.14.0-beta1")
}

datadog {
remoteRepositoryUrl = "http://github.com:fakeapp/repository.git"

Expand Down