Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6980d02
remove backend request for diff
daniel-mohedano May 16, 2025
a7f738d
update PRInfo building to use partial information from CI vendors
daniel-mohedano May 20, 2025
a1238c0
synchronize repo unshallow with future, avoids performing several times
daniel-mohedano May 20, 2025
cbe2a95
add `default_branch` to settings response
daniel-mohedano May 22, 2025
b861e7f
update settings api test
daniel-mohedano May 22, 2025
cab317e
change repo unshallow synchronization from future-based to synchronized
daniel-mohedano May 22, 2025
e401549
include pr info checks to CITagsProviderTest
daniel-mohedano May 23, 2025
63e7236
add tests for prinfo merging
daniel-mohedano May 23, 2025
a109cfd
Revert "update PRInfo building to use partial information from CI ven…
daniel-mohedano Jun 2, 2025
4d18887
Revert "include pr info checks to CITagsProviderTest"
daniel-mohedano Jun 2, 2025
84e1c0f
Revert "add tests for prinfo merging"
daniel-mohedano Jun 2, 2025
ec152b6
base commit sha algorithm implementation
daniel-mohedano Jun 2, 2025
1e843af
example git repo for base commit sha testing
daniel-mohedano Jun 2, 2025
fc82fcc
simplify algo implementation for easier read
daniel-mohedano Jun 2, 2025
67339e9
implement git diff based on best candidate for base commit sha
daniel-mohedano Jun 2, 2025
bfd3ad4
add github actions cloning test
daniel-mohedano Jun 3, 2025
5ddb58c
add several testing cases and cleaned up debug messages
daniel-mohedano Jun 4, 2025
c558a86
remove repo_origin folder
daniel-mohedano Jun 4, 2025
eca82e1
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 4, 2025
0fac3ae
fix forbidden apis
daniel-mohedano Jun 4, 2025
0e6bc2d
remove smoke test (no backend implementation anymore)
daniel-mohedano Jun 4, 2025
2e3362f
remove FileDiff
daniel-mohedano Jun 5, 2025
4198fe3
correctly reset all settings tags for mock backend
daniel-mohedano Jun 5, 2025
a99cff8
create isBlank method to avoid double negation with isNotBlank
daniel-mohedano Jun 5, 2025
f060e73
clean up base branch sha logic
daniel-mohedano Jun 6, 2025
ce0da33
fix code violation
daniel-mohedano Jun 6, 2025
2970e68
junit 4 test import wildcard
daniel-mohedano Jun 6, 2025
99980be
use relative paths in remotes and add remote origin to resources
daniel-mohedano Jun 6, 2025
a738112
add javadoc and update tests for Strings.isBlank
daniel-mohedano Jun 17, 2025
612ba54
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 17, 2025
d21d3b7
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 20, 2025
67cdbe7
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 21, 2025
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
Prev Previous commit
Next Next commit
synchronize repo unshallow with future, avoids performing several times
  • Loading branch information
daniel-mohedano committed May 20, 2025
commit a1238c034b3b54deec20a700ab5c9f2e785dd6de
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private Map<String, ExecutionSettings> doCreate(
getTestManagementTestsByModule(
tracerEnvironment, testManagementSettings.isEnabled()));
Future<Diff> pullRequestDiffFuture =
executor.submit(() -> getPullRequestDiff(tracerEnvironment, impactedTestsEnabled));
executor.submit(() -> getPullRequestDiff(impactedTestsEnabled));

SkippableTests skippableTests = skippableTestsFuture.get();
Map<String, Collection<TestFQN>> flakyTestsByModule = flakyTestsFuture.get();
Expand Down Expand Up @@ -402,16 +402,15 @@ private Map<TestSetting, Map<String, Collection<TestFQN>>> getTestManagementTest
}

@Nonnull
private Diff getPullRequestDiff(
TracerEnvironment tracerEnvironment, boolean impactedTestsDetectionEnabled) {
private Diff getPullRequestDiff(boolean impactedTestsDetectionEnabled) {
if (!impactedTestsDetectionEnabled) {
return LineDiff.EMPTY;
}

try {
if (repositoryRoot != null) {
// ensure repo is not shallow before attempting to get git diff
gitRepoUnshallow.unshallow();
gitRepoUnshallow.startOrObserveUnshallow().get();
Diff diff =
gitClient.getGitDiff(
pullRequestInfo.getPullRequestBaseBranchSha(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void uploadGitData() {
LOGGER.debug("Starting git data upload, {}", gitClient);

if (!config.isCiVisibilityGitUnshallowDefer()) {
gitRepoUnshallow.unshallow();
gitRepoUnshallow.startOrObserveUnshallow().get();
}

GitInfo gitInfo = gitInfoProvider.getGitInfo(repoRoot);
Expand All @@ -112,7 +112,8 @@ private void uploadGitData() {
return;
}

if (config.isCiVisibilityGitUnshallowDefer() && gitRepoUnshallow.unshallow()) {
if (config.isCiVisibilityGitUnshallowDefer()
&& gitRepoUnshallow.startOrObserveUnshallow().get()) {
latestCommits = gitClient.getLatestCommits();
commitsToSkip = gitDataApi.searchCommits(remoteUrl, latestCommits);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import datadog.trace.api.Config;
import datadog.trace.civisibility.utils.ShellCommandExecutor;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -13,13 +15,30 @@ public class GitRepoUnshallow {

private final Config config;
private final GitClient gitClient;
private volatile CompletableFuture<Boolean> callback;

public GitRepoUnshallow(Config config, GitClient gitClient) {
this.config = config;
this.gitClient = gitClient;
}

public boolean unshallow() throws IOException, InterruptedException, TimeoutException {
public Future<Boolean> startOrObserveUnshallow() {
if (callback == null) {
synchronized (this) {
if (callback == null) {
callback = new CompletableFuture<>();
try {
callback.complete(unshallow());
} catch (Exception e) {
callback.completeExceptionally(e);
}
}
}
}
return callback;
}

private boolean unshallow() throws IOException, InterruptedException, TimeoutException {
if (!config.isCiVisibilityGitUnshallowEnabled() || !gitClient.isShallow()) {
return false;
}
Expand Down