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
Original file line number Diff line number Diff line change
Expand Up @@ -431,28 +431,30 @@ private Diff getPullRequestDiff(
LOGGER.error("Could not get git diff for PR: {}", pullRequestInfo, e);
}

try {
ChangedFiles changedFiles = configurationApi.getChangedFiles(tracerEnvironment);

// attempting to use base SHA returned by the backend to calculate git diff
if (repositoryRoot != null) {
// ensure repo is not shallow before attempting to get git diff
gitRepoUnshallow.unshallow();
Diff diff = gitClient.getGitDiff(changedFiles.getBaseSha(), tracerEnvironment.getSha());
if (diff != null) {
return diff;
if (config.isCiVisibilityImpactedTestsBackendRequestEnabled()) {
try {
ChangedFiles changedFiles = configurationApi.getChangedFiles(tracerEnvironment);

// attempting to use base SHA returned by the backend to calculate git diff
if (repositoryRoot != null) {
// ensure repo is not shallow before attempting to get git diff
gitRepoUnshallow.unshallow();
Diff diff = gitClient.getGitDiff(changedFiles.getBaseSha(), tracerEnvironment.getSha());
if (diff != null) {
return diff;
}
}
}

// falling back to file-level granularity
return new FileDiff(changedFiles.getFiles());
// falling back to file-level granularity
return new FileDiff(changedFiles.getFiles());

} catch (InterruptedException e) {
LOGGER.error("Interrupted while getting git diff for: {}", tracerEnvironment, e);
Thread.currentThread().interrupt();
} catch (InterruptedException e) {
LOGGER.error("Interrupted while getting git diff for: {}", tracerEnvironment, e);
Thread.currentThread().interrupt();

} catch (Exception e) {
LOGGER.error("Could not get git diff for: {}", tracerEnvironment, e);
} catch (Exception e) {
LOGGER.error("Could not get git diff for: {}", tracerEnvironment, e);
}
}

return LineDiff.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class MavenSmokeTest extends CiVisibilitySmokeTest {
mockBackend.givenChangedFile("src/test/java/datadog/smoke/TestSucceed.java")

def exitCode = whenRunningMavenBuild([
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_GIT_CLIENT_ENABLED)}=false" as String
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_GIT_CLIENT_ENABLED)}=false" as String,
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_IMPACTED_TESTS_BACKEND_REQUEST_ENABLED)}=true" as String
], [])
assert exitCode == 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public final class CiVisibilityConfig {
public static final String CIVISIBILITY_FLAKY_RETRY_ENABLED = "civisibility.flaky.retry.enabled";
public static final String CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED =
"civisibility.impacted.tests.detection.enabled";
public static final String CIVISIBILITY_IMPACTED_TESTS_BACKEND_REQUEST_ENABLED =
"civisibility.impacted.tests.backend.request.enabled";
public static final String CIVISIBILITY_KNOWN_TESTS_REQUEST_ENABLED =
"civisibility.known.tests.request.enabled";
public static final String CIVISIBILITY_FLAKY_RETRY_ONLY_KNOWN_FLAKES =
Expand Down
7 changes: 7 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ public static String getHostName() {
private final List<String> ciVisibilityResourceFolderNames;
private final boolean ciVisibilityFlakyRetryEnabled;
private final boolean ciVisibilityImpactedTestsDetectionEnabled;
private final boolean ciVisibilityImpactedTestsBackendRequestEnabled;
private final boolean ciVisibilityKnownTestsRequestEnabled;
private final boolean ciVisibilityFlakyRetryOnlyKnownFlakes;
private final int ciVisibilityFlakyRetryCount;
Expand Down Expand Up @@ -1501,6 +1502,8 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
configProvider.getBoolean(CIVISIBILITY_FLAKY_RETRY_ENABLED, true);
ciVisibilityImpactedTestsDetectionEnabled =
configProvider.getBoolean(CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED, true);
ciVisibilityImpactedTestsBackendRequestEnabled =
configProvider.getBoolean(CIVISIBILITY_IMPACTED_TESTS_BACKEND_REQUEST_ENABLED, false);
ciVisibilityKnownTestsRequestEnabled =
configProvider.getBoolean(CIVISIBILITY_KNOWN_TESTS_REQUEST_ENABLED, true);
ciVisibilityFlakyRetryOnlyKnownFlakes =
Expand Down Expand Up @@ -2945,6 +2948,10 @@ public boolean isCiVisibilityImpactedTestsDetectionEnabled() {
return ciVisibilityImpactedTestsDetectionEnabled;
}

public boolean isCiVisibilityImpactedTestsBackendRequestEnabled() {
return ciVisibilityImpactedTestsBackendRequestEnabled;
}

public boolean isCiVisibilityKnownTestsRequestEnabled() {
return ciVisibilityKnownTestsRequestEnabled;
}
Expand Down
Loading