Allow the EventHandler returned by ActionExecutionContext to be different from the global one in BlazeExecutor. Instead, it can be one from SkyframeActionExecutor that suppresses ProgressLike messages. This allows an action that was rewound to execute without emitting any progress-like events.

Deprecate ActionExecutionContext#getEventBus: posts should go over the handler, allowing them to be easily filtered.

Also do this for ActionCachedContext, although I suspect that most (not all) of the uses of ActionCachedContext could be dealt with by using Skyframe-level caching, rather than a NotifyOnActionCacheHit action.

PiperOrigin-RevId: 225861266
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
index 2238942..9fa6ae3 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
@@ -63,6 +63,7 @@
         actionKeyContext,
         null,
         outErr,
+        executor.getEventHandler(),
         ImmutableMap.<String, String>of(),
         ImmutableMap.of(),
         null,
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index 41e90a9..7054d57b 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -144,6 +144,7 @@
         actionKeyContext,
         metadataHandler,
         fileOutErr,
+        executor != null ? executor.getEventHandler() : null,
         ImmutableMap.copyOf(clientEnv),
         ImmutableMap.of(),
         actionGraph == null
@@ -160,6 +161,7 @@
       Path execRoot,
       MetadataHandler metadataHandler,
       BuildDriver buildDriver) {
+    ExtendedEventHandler eventHandler = executor != null ? executor.getEventHandler() : null;
     return ActionExecutionContext.forInputDiscovery(
         executor,
         new SingleBuildFileCache(execRoot.getPathString(), execRoot.getFileSystem()),
@@ -167,9 +169,9 @@
         actionKeyContext,
         metadataHandler,
         fileOutErr,
+        eventHandler,
         ImmutableMap.of(),
-        new BlockingSkyFunctionEnvironment(
-            buildDriver, executor == null ? null : executor.getEventHandler()),
+        new BlockingSkyFunctionEnvironment(buildDriver, eventHandler),
         /*actionFileSystem=*/ null);
   }
 
@@ -182,6 +184,7 @@
         new ActionKeyContext(),
         null,
         null,
+        eventHandler,
         ImmutableMap.of(),
         ImmutableMap.of(),
         createDummyArtifactExpander(),
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
index e22ed44..32f6fa1 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
@@ -68,6 +68,7 @@
             actionKeyContext,
             null,
             new FileOutErr(),
+            executor.getEventHandler(),
             ImmutableMap.<String, String>of(),
             ImmutableMap.of(),
             null,
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
index b736576..7625475 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
@@ -200,6 +200,7 @@
         actionKeyContext,
         null,
         new FileOutErr(),
+        executor.getEventHandler(),
         ImmutableMap.<String, String>of(),
         ImmutableMap.of(),
         artifactExpander,
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
index e901936..2068150 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
@@ -86,6 +86,7 @@
                 actionKeyContext,
                 null,
                 null,
+                executor.getEventHandler(),
                 ImmutableMap.<String, String>of(),
                 ImmutableMap.of(),
                 null,
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
index b7fc6c7..3495ad1 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
@@ -189,7 +189,8 @@
         actionKeyContext,
         null,
         new FileOutErr(),
-        ImmutableMap.<String, String>of(),
+        executor.getEventHandler(),
+        ImmutableMap.of(),
         ImmutableMap.of(),
         null,
         /*actionFileSystem=*/ null,
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index 74245b9..fe61a5c 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -2209,6 +2209,7 @@
           actionKeyContext,
           /*metadataHandler=*/ null,
           actionLogBufferPathGenerator.generate(ArtifactPathResolver.IDENTITY),
+          reporter,
           clientEnv,
           ImmutableMap.of(),
           artifactExpander,
diff --git a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
index e643331..b499f26 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
@@ -93,6 +93,7 @@
           new ActionKeyContext(),
           /* metadataHandler= */ null,
           fileOutErr,
+          /*eventHandler=*/ null,
           /* clientEnv= */ ImmutableMap.of(),
           /* topLevelFilesets= */ ImmutableMap.of(),
           /* artifactExpander= */ null,
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
index e84c832..04768d3 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
@@ -116,7 +116,17 @@
   private ActionExecutionContext makeDummyContext() {
     DummyExecutor executor = new DummyExecutor(fileSystem, rootDirectory);
     return new ActionExecutionContext(
-        executor, null, null, null, null, null, ImmutableMap.of(), ImmutableMap.of(), null, null,
+        executor,
+        null,
+        null,
+        null,
+        null,
+        null,
+        executor.getEventHandler(),
+        ImmutableMap.of(),
+        ImmutableMap.of(),
+        null,
+        null,
         null);
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LtoBackendActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LtoBackendActionTest.java
index 6b57a30..eddcc43 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LtoBackendActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LtoBackendActionTest.java
@@ -87,6 +87,7 @@
             actionKeyContext,
             null,
             new FileOutErr(),
+            executor.getEventHandler(),
             ImmutableMap.<String, String>of(),
             ImmutableMap.of(),
             null,
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
index c74e140..9e3abc0 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
@@ -791,6 +791,7 @@
             actionKeyContext,
             null,
             null,
+            null,
             ImmutableMap.<String, String>of(),
             ImmutableMap.of(),
             DUMMY_ARTIFACT_EXPANDER,
@@ -843,7 +844,8 @@
             actionKeyContext,
             null,
             null,
-            ImmutableMap.<String, String>of(),
+            null,
+            ImmutableMap.of(),
             ImmutableMap.of(),
             DUMMY_ARTIFACT_EXPANDER,
             null,
diff --git a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
index db31a40..8272493 100644
--- a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
@@ -192,6 +192,7 @@
         new ActionKeyContext(),
         null,
         outErr,
+        executor.getEventHandler(),
         ImmutableMap.<String, String>of(),
         ImmutableMap.of(),
         SIMPLE_ARTIFACT_EXPANDER,