From 8bf52ffe7d5e8103b797c113ec357dbfd5eed717 Mon Sep 17 00:00:00 2001 From: Dylan <67774922+heavymachinery@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:25:12 -0600 Subject: [PATCH] Print immutable action package details in set up job logs (#3645) * Print immutable action package details in set up job logs * "Source commit SHA" instead of "Commit SHA" for immutable actions logs --------- Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com> --- src/Runner.Worker/ActionManager.cs | 14 +++++++++++++- src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs | 13 +++++++++++++ src/Sdk/WebApi/WebApi/LaunchContracts.cs | 14 ++++++++++++++ src/Sdk/WebApi/WebApi/LaunchHttpClient.cs | 16 ++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index f32cad28e..47a66dd12 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -775,7 +775,19 @@ namespace GitHub.Runner.Worker // make sure we get a clean folder ready to use. IOUtil.DeleteDirectory(destDirectory, executionContext.CancellationToken); Directory.CreateDirectory(destDirectory); - executionContext.Output($"Download action repository '{downloadInfo.NameWithOwner}@{downloadInfo.Ref}' (SHA:{downloadInfo.ResolvedSha})"); + + if (downloadInfo.PackageDetails != null) + { + executionContext.Output($"##[group]Download immutable action package '{downloadInfo.NameWithOwner}@{downloadInfo.Ref}'"); + executionContext.Output($"Version: {downloadInfo.PackageDetails.Version}"); + executionContext.Output($"Digest: {downloadInfo.PackageDetails.ManifestDigest}"); + executionContext.Output($"Source commit SHA: {downloadInfo.ResolvedSha}"); + executionContext.Output("##[endgroup]"); + } + else + { + executionContext.Output($"Download action repository '{downloadInfo.NameWithOwner}@{downloadInfo.Ref}' (SHA:{downloadInfo.ResolvedSha})"); + } } //download and extract action in a temp folder and rename it on success diff --git a/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs b/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs index a6b0749f6..b4ade9887 100644 --- a/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs +++ b/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs @@ -9,6 +9,9 @@ namespace GitHub.DistributedTask.WebApi [DataMember(EmitDefaultValue = false)] public ActionDownloadAuthentication Authentication { get; set; } + [DataMember(EmitDefaultValue = false)] + public ActionDownloadPackageDetails PackageDetails { get; set; } + [DataMember(EmitDefaultValue = false)] public string NameWithOwner { get; set; } @@ -37,4 +40,14 @@ namespace GitHub.DistributedTask.WebApi [DataMember(EmitDefaultValue = false)] public string Token { get; set; } } + + [DataContract] + public class ActionDownloadPackageDetails + { + [DataMember(EmitDefaultValue = false)] + public string Version { get; set; } + + [DataMember(EmitDefaultValue = false)] + public string ManifestDigest { get; set; } + } } diff --git a/src/Sdk/WebApi/WebApi/LaunchContracts.cs b/src/Sdk/WebApi/WebApi/LaunchContracts.cs index 41a67113e..7b896fd75 100644 --- a/src/Sdk/WebApi/WebApi/LaunchContracts.cs +++ b/src/Sdk/WebApi/WebApi/LaunchContracts.cs @@ -29,6 +29,9 @@ namespace GitHub.Services.Launch.Contracts { [DataMember(EmitDefaultValue = false, Name = "authentication")] public ActionDownloadAuthenticationResponse Authentication { get; set; } + + [DataMember(EmitDefaultValue = false, Name = "package_details")] + public ActionDownloadPackageDetailsResponse PackageDetails { get; set; } [DataMember(EmitDefaultValue = false, Name = "name")] public string Name { get; set; } @@ -59,6 +62,17 @@ namespace GitHub.Services.Launch.Contracts public string Token { get; set; } } + + [DataContract] + public class ActionDownloadPackageDetailsResponse + { + [DataMember(EmitDefaultValue = false, Name = "version")] + public string Version { get; set; } + + [DataMember(EmitDefaultValue = false, Name = "manifest_digest")] + public string ManifestDigest { get; set; } + } + [DataContract] public class ActionDownloadInfoResponseCollection { diff --git a/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs b/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs index bf2f4c00e..6ba06a6a0 100644 --- a/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs +++ b/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs @@ -91,6 +91,7 @@ namespace GitHub.Services.Launch.Client TarballUrl = actionDownloadInfoResponse.TarUrl, Ref = actionDownloadInfoResponse.Version, ZipballUrl = actionDownloadInfoResponse.ZipUrl, + PackageDetails = ToServerData(actionDownloadInfoResponse.PackageDetails) }; } @@ -108,6 +109,21 @@ namespace GitHub.Services.Launch.Client }; } + + private static ActionDownloadPackageDetails? ToServerData(ActionDownloadPackageDetailsResponse? actionDownloadPackageDetails) + { + if (actionDownloadPackageDetails == null) + { + return null; + } + + return new ActionDownloadPackageDetails + { + Version = actionDownloadPackageDetails.Version, + ManifestDigest = actionDownloadPackageDetails.ManifestDigest + }; + } + private MediaTypeFormatter m_formatter; private Uri m_launchServiceUrl; private string m_token;