Change signatures to DerivedArtifact, and get Labels from non-Artifact sources when possible.

In tests, try to get artifacts directly from the actual configured target, rather than creating fresh ones.

This change should be a prod functional no-op, just changing signatures. Split out from the follow-up to reduce the diff.

PiperOrigin-RevId: 250527865
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index 2020379..aef63fe 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -338,14 +338,16 @@
 
   @Test
   public void testCodec() throws Exception {
+    Artifact.DerivedArtifact artifact =
+        (Artifact.DerivedArtifact) ActionsTestUtil.createArtifact(rootDir, "src/a");
     ArtifactRoot anotherRoot =
         ArtifactRoot.asDerivedRoot(scratch.getFileSystem().getPath("/"), scratch.dir("/src"));
-    new SerializationTester(
-            ActionsTestUtil.createArtifact(rootDir, "src/a"),
-            new Artifact.DerivedArtifact(
-                anotherRoot,
-                anotherRoot.getExecPath().getRelative("src/c"),
-                new LabelArtifactOwner(Label.parseAbsoluteUnchecked("//foo:bar"))))
+    Artifact.DerivedArtifact anotherArtifact =
+        new Artifact.DerivedArtifact(
+            anotherRoot,
+            anotherRoot.getExecPath().getRelative("src/c"),
+            new LabelArtifactOwner(Label.parseAbsoluteUnchecked("//foo:bar")));
+    new SerializationTester(artifact, anotherArtifact)
         .addDependency(FileSystem.class, scratch.getFileSystem())
         .runTests();
   }