Skip to content

Commit

Permalink
[Skymeld] Remove the left over symlinks from sibling repositories
Browse files Browse the repository at this point in the history
This was a missing behavior in Skymeld, which caused some integration tests to fail when we tried turning on Skymeld by default for Bazel. Example failure:  https://storage.googleapis.com/bazel-untrusted-buildkite-artifacts/01890719-efb9-428c-80bb-5449e92383e8/src/test/shell/bazel/bazel_proto_library_test/test_attempts/attempt_1.log

This PR fixes this bug by adding this missing behavior.

Verified that the test passed afterwards.

Closes bazelbuild#18850.

PiperOrigin-RevId: 545973135
Change-Id: Ifa7f7e1d270c187ad40eb8b92807b37b7de3e2a3
  • Loading branch information
joeleba authored and copybara-github committed Jul 6, 2023
1 parent 8480f1a commit f868582
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,7 @@ private void plantSymlinkForestMultiPackagePath(
*/
public ImmutableList<Path> plantSymlinkForest() throws IOException, AbruptExitException {
deleteTreesBelowNotPrefixed(execroot, prefix);

if (siblingRepositoryLayout) {
// Delete execroot/../<symlinks> to directories representing external repositories.
for (Path p : execroot.getParentDirectory().getDirectoryEntries()) {
if (p.isSymbolicLink()) {
p.deleteTree();
}
}
}
deleteSiblingRepositorySymlinks(siblingRepositoryLayout, execroot);

boolean shouldLinkAllTopLevelItems = false;
Map<Path, Path> mainRepoLinks = Maps.newLinkedHashMap();
Expand Down Expand Up @@ -367,6 +359,18 @@ public ImmutableList<Path> plantSymlinkForest() throws IOException, AbruptExitEx
return plantedSymlinks.build();
}

private static void deleteSiblingRepositorySymlinks(
boolean siblingRepositoryLayout, Path execroot) throws IOException {
if (siblingRepositoryLayout) {
// Delete execroot/../<symlinks> to directories representing external repositories.
for (Path p : execroot.getParentDirectory().getDirectoryEntries()) {
if (p.isSymbolicLink()) {
p.deleteTree();
}
}
}
}

/**
* Eagerly plant the symlinks from execroot to the source root provided by the single package path
* of the current build. Only works with a single package path. Before planting the new symlinks,
Expand All @@ -379,6 +383,7 @@ public static void eagerlyPlantSymlinkForestSinglePackagePath(
boolean siblingRepositoryLayout)
throws IOException {
deleteTreesBelowNotPrefixed(execroot, prefix);
deleteSiblingRepositorySymlinks(siblingRepositoryLayout, execroot);

// Plant everything under the single source root.
for (Path target : sourceRoot.getDirectoryEntries()) {
Expand Down

0 comments on commit f868582

Please sign in to comment.