From ea2794d5d103e0ab3e8387e4ad1fd5613fd64086 Mon Sep 17 00:00:00 2001 From: Dylan <67774922+heavymachinery@users.noreply.github.com> Date: Thu, 9 Jan 2025 01:41:50 +0000 Subject: [PATCH 1/2] Print immutable action package details in set up job logs --- 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 f32cad28ea9..ef779a4f512 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -775,7 +775,19 @@ private async Task DownloadRepositoryActionAsync(IExecutionContext executionCont // 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($"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 a6b0749f65a..b4ade98872e 100644 --- a/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs +++ b/src/Sdk/DTWebApi/WebApi/ActionDownloadInfo.cs @@ -9,6 +9,9 @@ public class ActionDownloadInfo [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 @@ public class ActionDownloadAuthentication [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 41a67113e00..7b896fd758e 100644 --- a/src/Sdk/WebApi/WebApi/LaunchContracts.cs +++ b/src/Sdk/WebApi/WebApi/LaunchContracts.cs @@ -29,6 +29,9 @@ public class ActionDownloadInfoResponse { [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 @@ public class ActionDownloadAuthenticationResponse 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 bf2f4c00ecf..6ba06a6a052 100644 --- a/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs +++ b/src/Sdk/WebApi/WebApi/LaunchHttpClient.cs @@ -91,6 +91,7 @@ private static ActionDownloadInfo ToServerData(ActionDownloadInfoResponse action TarballUrl = actionDownloadInfoResponse.TarUrl, Ref = actionDownloadInfoResponse.Version, ZipballUrl = actionDownloadInfoResponse.ZipUrl, + PackageDetails = ToServerData(actionDownloadInfoResponse.PackageDetails) }; } @@ -108,6 +109,21 @@ private static ActionDownloadInfo ToServerData(ActionDownloadInfoResponse action }; } + + 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; From c089349e1137904245bade976ca4b20520de08e1 Mon Sep 17 00:00:00 2001 From: Dylan <67774922+heavymachinery@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:07:18 +0000 Subject: [PATCH 2/2] "Source commit SHA" instead of "Commit SHA" for immutable actions logs --- src/Runner.Worker/ActionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index ef779a4f512..47a66dd12fa 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -781,7 +781,7 @@ private async Task DownloadRepositoryActionAsync(IExecutionContext executionCont 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($"Commit SHA: {downloadInfo.ResolvedSha}"); + executionContext.Output($"Source commit SHA: {downloadInfo.ResolvedSha}"); executionContext.Output("##[endgroup]"); } else