Fix BEP error reporting for CTs w/ deps cycles

Before this change, errors for configured targets were not correctly
reported, in particular if they depended on a dependency cycle, but also
if they depended on a configured target with an error in a different
configuration.

The reason is that ConfiguredTargetKey contains a
BuildConfiguration.Key, which does not contain enough information to
construct a BuildConfiguration EventId (for BEP). We are passing the
set of top-level ConfiguredTargetKeys to SkyframeBuildView, but not the
corresponding configurations, even though the BuildView has access to
them (that's how it's constructing the ConfiguredTargetKeys in the first
place).

The ideal fix would be to handle dependency cycle errors in Skyframe and
perform error bubbling (or something like that) to allow the top level
configuration function to catch and report the error. However, this is
not supported by Skyframe at this time.

Instead, we pass in a lookup map that allows recovering the
BuildConfiguration instances corresponding to the top-level configured
targets. In order to save effort in the common case where there is no
analysis error, we only pass in a memoized supplier.

Alternatives considered:
- call Skyframe to recover the BuildConfiguration from the key
- pass in the TargetAndConfiguration instances rather than a lookup map

I don't have any strong reasons to prefer the present approach over
either of the others.

PiperOrigin-RevId: 229568727
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisFailureEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisFailureEvent.java
index cdc26ef..05860cb 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisFailureEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisFailureEvent.java
@@ -14,6 +14,7 @@
 
 package com.google.devtools.build.lib.analysis;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.devtools.build.lib.buildeventstream.BuildEvent;
@@ -52,6 +53,11 @@
     return failedTarget;
   }
 
+  @VisibleForTesting
+  BuildEventId getConfigurationId() {
+    return configuration;
+  }
+
   /**
    * Returns the label of a single root cause. Use {@link #getRootCauses} to report all root causes.
    */