From 7dfb5b950df536ef7430f6dec0da3e30bab67290 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Mon, 24 Apr 2023 21:58:05 +0200 Subject: [PATCH 1/2] RemoteExecutionService: Action.Command to set output_paths This is a follow-up to https://github.com/bazelbuild/bazel/pull/18198/ Make Bazel compatible with newer version of Remote Api by setting output_paths along-side output_directories and output_files. The latter 2 are deprecated in newer REAPI specification. --- .../devtools/build/lib/remote/RemoteExecutionService.java | 2 ++ .../devtools/build/lib/remote/RemoteExecutionServiceTest.java | 2 ++ .../lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java | 1 + 3 files changed, 5 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index 14144e0584fb29..058cf7884a918f 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -236,7 +236,9 @@ static Command buildCommand( Collections.sort(outputFiles); Collections.sort(outputDirectories); command.addAllOutputFiles(outputFiles); + command.addAllOutputPaths(outputFiles); command.addAllOutputDirectories(outputDirectories); + command.addAllOutputPaths(outputDirectories); if (platform != null) { command.setPlatform(platform); diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java index 3f15557ffc6b16..8cac5f3c305933 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java @@ -193,6 +193,7 @@ public void buildRemoteAction_withRegularFileAsOutput() throws Exception { RemoteAction remoteAction = service.buildRemoteAction(spawn, context); assertThat(remoteAction.getCommand().getOutputFilesList()).containsExactly(execPath.toString()); + assertThat(remoteAction.getCommand().getOutputPathsList()).containsExactly(execPath.toString()); assertThat(remoteAction.getCommand().getOutputDirectoriesList()).isEmpty(); } @@ -228,6 +229,7 @@ public void buildRemoteAction_withUnresolvedSymlinkAsOutput() throws Exception { assertThat(remoteAction.getCommand().getOutputFilesList()).containsExactly("path/to/link"); assertThat(remoteAction.getCommand().getOutputDirectoriesList()).isEmpty(); + assertThat(remoteAction.getCommand().getOutputPathsList()).containsExactly("path/to/link"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java index 7088859f7653da..11a14cba5a7ff2 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java @@ -342,6 +342,7 @@ public int maxConcurrency() { .setValue("value") .build()) .addAllOutputFiles(ImmutableList.of("bar", "foo")) + .addAllOutputPaths(ImmutableList.of("bar", "foo")) .build(); cmdDigest = DIGEST_UTIL.compute(command); channel.release(); From 596073a911520745a6ee64d0913eedfe391c5cc1 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 27 Apr 2023 11:24:31 +0200 Subject: [PATCH 2/2] Ensure outputPaths are sorted --- .../devtools/build/lib/remote/RemoteExecutionService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index 058cf7884a918f..60fd8411e392bb 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -225,6 +225,7 @@ static Command buildCommand( Command.Builder command = Command.newBuilder(); ArrayList outputFiles = new ArrayList<>(); ArrayList outputDirectories = new ArrayList<>(); + ArrayList outputPaths = new ArrayList<>(); for (ActionInput output : outputs) { String pathString = decodeBytestringUtf8(remotePathResolver.localPathToOutputPath(output)); if (output.isDirectory()) { @@ -232,13 +233,14 @@ static Command buildCommand( } else { outputFiles.add(pathString); } + outputPaths.add(pathString); } Collections.sort(outputFiles); Collections.sort(outputDirectories); + Collections.sort(outputPaths); command.addAllOutputFiles(outputFiles); - command.addAllOutputPaths(outputFiles); command.addAllOutputDirectories(outputDirectories); - command.addAllOutputPaths(outputDirectories); + command.addAllOutputPaths(outputPaths); if (platform != null) { command.setPlatform(platform);