From fb6d1adb430a6c96407c5857854a40662af439c8 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Wed, 7 Aug 2024 16:53:00 -0500 Subject: [PATCH] .NET 8 OS compatibility test (#3422) * Revert "Warn for soon to be deprecated OS versions (#3413)" This reverts commit ae04147f960f2232d0a888c89d3e128f92f21677. * Add .NET 8 OS compatibility test * feedback --- src/Runner.Common/Constants.cs | 2 + src/Runner.Worker/JobExtension.cs | 2 +- src/Runner.Worker/OSWarningChecker.cs | 113 ++++---- src/Runner.Worker/Variables.cs | 4 + .../Pipelines/AgentJobRequestMessage.cs | 26 -- src/Sdk/DTPipelines/Pipelines/OSWarning.cs | 44 --- src/Test/L0/Listener/JobDispatcherL0.cs | 3 +- src/Test/L0/Listener/RunnerL0.cs | 2 +- src/Test/L0/Worker/ActionCommandManagerL0.cs | 2 +- .../L0/Worker/CreateStepSummaryCommandL0.cs | 2 +- src/Test/L0/Worker/ExecutionContextL0.cs | 32 +-- src/Test/L0/Worker/JobExtensionL0.cs | 2 +- src/Test/L0/Worker/JobRunnerL0.cs | 1 - src/Test/L0/Worker/OSWarningCheckerL0.cs | 271 ------------------ src/Test/L0/Worker/WorkerL0.cs | 2 +- src/TestDotNet8Compatibility/Program.cs | 13 + .../TestDotNet8Compatibility.csproj | 19 ++ src/TestDotNet8Compatibility/dir.proj | 22 ++ src/TestDotNet8Compatibility/global.json | 5 + src/dev.sh | 54 ++++ 20 files changed, 203 insertions(+), 418 deletions(-) delete mode 100644 src/Sdk/DTPipelines/Pipelines/OSWarning.cs delete mode 100644 src/Test/L0/Worker/OSWarningCheckerL0.cs create mode 100644 src/TestDotNet8Compatibility/Program.cs create mode 100644 src/TestDotNet8Compatibility/TestDotNet8Compatibility.csproj create mode 100644 src/TestDotNet8Compatibility/dir.proj create mode 100644 src/TestDotNet8Compatibility/global.json diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index d68d5cdf695..849228b8741 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -280,6 +280,8 @@ public static class System public static readonly string PhaseDisplayName = "system.phaseDisplayName"; public static readonly string JobRequestType = "system.jobRequestType"; public static readonly string OrchestrationId = "system.orchestrationId"; + public static readonly string TestDotNet8Compatibility = "system.testDotNet8Compatibility"; + public static readonly string DotNet8CompatibilityWarning = "system.dotNet8CompatibilityWarning"; } } diff --git a/src/Runner.Worker/JobExtension.cs b/src/Runner.Worker/JobExtension.cs index 4ca06b90c94..a36e4beb4d8 100644 --- a/src/Runner.Worker/JobExtension.cs +++ b/src/Runner.Worker/JobExtension.cs @@ -129,7 +129,7 @@ public async Task> InitializeJob(IExecutionContext jobContext, Pipel // Check OS warning var osWarningChecker = HostContext.GetService(); - await osWarningChecker.CheckOSAsync(context, message.OSWarnings); + await osWarningChecker.CheckOSAsync(context); try { diff --git a/src/Runner.Worker/OSWarningChecker.cs b/src/Runner.Worker/OSWarningChecker.cs index 900f8f1f0eb..bd1ccc70297 100644 --- a/src/Runner.Worker/OSWarningChecker.cs +++ b/src/Runner.Worker/OSWarningChecker.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading; using System.Threading.Tasks; -using System.Text.RegularExpressions; using GitHub.DistributedTask.WebApi; -using GitHub.DistributedTask.Pipelines; using GitHub.Runner.Common; using GitHub.Runner.Sdk; @@ -13,75 +12,85 @@ namespace GitHub.Runner.Worker [ServiceLocator(Default = typeof(OSWarningChecker))] public interface IOSWarningChecker : IRunnerService { - Task CheckOSAsync(IExecutionContext context, IList osWarnings); + Task CheckOSAsync(IExecutionContext context); } -#if OS_WINDOWS || OS_OSX public sealed class OSWarningChecker : RunnerService, IOSWarningChecker { - public Task CheckOSAsync(IExecutionContext context, IList osWarnings) + public async Task CheckOSAsync(IExecutionContext context) { ArgUtil.NotNull(context, nameof(context)); - ArgUtil.NotNull(osWarnings, nameof(osWarnings)); - return Task.CompletedTask; - } - } -#else - public sealed class OSWarningChecker : RunnerService, IOSWarningChecker - { - private static readonly TimeSpan s_matchTimeout = TimeSpan.FromMilliseconds(100); - private static readonly RegexOptions s_regexOptions = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase; - - public async Task CheckOSAsync(IExecutionContext context, IList osWarnings) - { - ArgUtil.NotNull(context, nameof(context)); - ArgUtil.NotNull(osWarnings, nameof(osWarnings)); - foreach (var osWarning in osWarnings) + if (!context.Global.Variables.System_TestDotNet8Compatibility) { - if (string.IsNullOrEmpty(osWarning.FilePath)) - { - Trace.Error("The file path is not specified in the OS warning check."); - continue; - } + return; + } - if (string.IsNullOrEmpty(osWarning.RegularExpression)) + context.Output("Testing runner upgrade compatibility"); + List output = new(); + object outputLock = new(); + try + { + using (var process = HostContext.CreateService()) { - Trace.Error("The regular expression is not specified in the OS warning check."); - continue; - } + process.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout) + { + if (!string.IsNullOrEmpty(stdout.Data)) + { + lock (outputLock) + { + output.Add(stdout.Data); + Trace.Info(stdout.Data); + } + } + }; - if (string.IsNullOrEmpty(osWarning.Warning)) - { - Trace.Error("The warning message is not specified in the OS warning check."); - continue; - } + process.ErrorDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stderr) + { + if (!string.IsNullOrEmpty(stderr.Data)) + { + lock (outputLock) + { + output.Add(stderr.Data); + Trace.Error(stderr.Data); + } + } + }; - try - { - if (File.Exists(osWarning.FilePath)) + using (var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { - var lines = await File.ReadAllLinesAsync(osWarning.FilePath, context.CancellationToken); - var regex = new Regex(osWarning.RegularExpression, s_regexOptions, s_matchTimeout); - foreach (var line in lines) + int exitCode = await process.ExecuteAsync( + workingDirectory: HostContext.GetDirectory(WellKnownDirectory.Root), + fileName: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "testDotNet8Compatibility", $"TestDotNet8Compatibility{IOUtil.ExeExtension}"), + arguments: string.Empty, + environment: null, + cancellationToken: cancellationTokenSource.Token); + + var outputStr = string.Join("\n", output).Trim(); + if (exitCode != 0 || !string.Equals(outputStr, "Hello from .NET 8!", StringComparison.Ordinal)) { - if (regex.IsMatch(line)) + var warningMessage = context.Global.Variables.System_DotNet8CompatibilityWarning; + if (!string.IsNullOrEmpty(warningMessage)) { - context.Warning(osWarning.Warning); - context.Global.JobTelemetry.Add(new JobTelemetry() { Type = JobTelemetryType.General, Message = $"OS warning: {osWarning.Warning}" }); - return; + context.Warning(warningMessage); } + + context.Global.JobTelemetry.Add(new JobTelemetry() { Type = JobTelemetryType.General, Message = $".NET 8 OS compatibility test failed with exit code '{exitCode}' and output: {GetShortOutput(output)}" }); } } } - catch (Exception ex) - { - Trace.Error("An error occurred while checking OS warnings for file '{0}' and regex '{1}'.", osWarning.FilePath, osWarning.RegularExpression); - Trace.Error(ex); - context.Global.JobTelemetry.Add(new JobTelemetry() { Type = JobTelemetryType.General, Message = $"An error occurred while checking OS warnings for file '{osWarning.FilePath}' and regex '{osWarning.RegularExpression}': {ex.Message}" }); - } + } + catch (Exception ex) + { + Trace.Error("An error occurred while testing .NET 8 compatibility'"); + Trace.Error(ex); + context.Global.JobTelemetry.Add(new JobTelemetry() { Type = JobTelemetryType.General, Message = $".NET 8 OS compatibility test encountered exception type '{ex.GetType().FullName}', message: '{ex.Message}', process output: '{GetShortOutput(output)}'" }); } } + + private static string GetShortOutput(List output) + { + var outputStr = string.Join("\n", output).Trim(); + return outputStr.Length > 200 ? string.Concat(outputStr.Substring(0, 200), "[...]") : outputStr; + } } -#endif } - diff --git a/src/Runner.Worker/Variables.cs b/src/Runner.Worker/Variables.cs index 916b82dc6a1..a30cd3c39e7 100644 --- a/src/Runner.Worker/Variables.cs +++ b/src/Runner.Worker/Variables.cs @@ -72,8 +72,12 @@ public Variables(IHostContext hostContext, IDictionary co public bool? Step_Debug => GetBoolean(Constants.Variables.Actions.StepDebug); + public string System_DotNet8CompatibilityWarning => Get(Constants.Variables.System.DotNet8CompatibilityWarning); + public string System_PhaseDisplayName => Get(Constants.Variables.System.PhaseDisplayName); + public bool System_TestDotNet8Compatibility => GetBoolean(Constants.Variables.System.TestDotNet8Compatibility) ?? false; + public string Get(string name) { Variable variable; diff --git a/src/Sdk/DTPipelines/Pipelines/AgentJobRequestMessage.cs b/src/Sdk/DTPipelines/Pipelines/AgentJobRequestMessage.cs index 030f1d82610..070d86ee24f 100644 --- a/src/Sdk/DTPipelines/Pipelines/AgentJobRequestMessage.cs +++ b/src/Sdk/DTPipelines/Pipelines/AgentJobRequestMessage.cs @@ -44,7 +44,6 @@ public AgentJobRequestMessage( IList defaults, ActionsEnvironmentReference actionsEnvironment, TemplateToken snapshot, - IList osWarnings, String messageType = JobRequestMessageTypes.PipelineAgentJobRequest) { this.MessageType = messageType; @@ -74,11 +73,6 @@ public AgentJobRequestMessage( m_defaults = new List(defaults); } - if (osWarnings?.Count > 0) - { - m_osWarnings = new List(osWarnings); - } - this.ContextData = new Dictionary(StringComparer.OrdinalIgnoreCase); if (contextData?.Count > 0) { @@ -294,18 +288,6 @@ public IList FileTable } } - public IList OSWarnings - { - get - { - if (m_osWarnings == null) - { - m_osWarnings = new List(); - } - return m_osWarnings; - } - } - // todo: remove after feature-flag DistributedTask.EvaluateContainerOnRunner is enabled everywhere public void SetJobSidecarContainers(IDictionary value) { @@ -443,11 +425,6 @@ private void OnSerializing(StreamingContext context) { JobContainer = new StringToken(null, null, null, m_jobContainerResourceAlias); } - - if (m_osWarnings?.Count == 0) - { - m_osWarnings = null; - } } [DataMember(Name = "EnvironmentVariables", EmitDefaultValue = false)] @@ -472,9 +449,6 @@ private void OnSerializing(StreamingContext context) [DataMember(Name = "JobSidecarContainers", EmitDefaultValue = false)] private IDictionary m_jobSidecarContainers; - [DataMember(Name = "OSWarnings", EmitDefaultValue = false)] - private List m_osWarnings; - // todo: remove after feature-flag DistributedTask.EvaluateContainerOnRunner is enabled everywhere [IgnoreDataMember] private string m_jobContainerResourceAlias; diff --git a/src/Sdk/DTPipelines/Pipelines/OSWarning.cs b/src/Sdk/DTPipelines/Pipelines/OSWarning.cs deleted file mode 100644 index 7eb4168b26f..00000000000 --- a/src/Sdk/DTPipelines/Pipelines/OSWarning.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace GitHub.DistributedTask.Pipelines -{ - /// - /// Information to check whether the OS is going to be deprecated soon - /// - [DataContract] - [EditorBrowsable(EditorBrowsableState.Never)] - public sealed class OSWarning - { - /// - /// Gets or sets the file to check - /// - [DataMember(EmitDefaultValue = false)] - public String FilePath - { - get; - set; - } - - /// - /// Gets or sets the regular expression to match - /// - [DataMember(EmitDefaultValue = false)] - public String RegularExpression - { - get; - set; - } - - /// - /// Gets or sets the warning annotation message, if the regular expression matches the content of the file - /// - [DataMember(EmitDefaultValue = false)] - public String Warning - { - get; - set; - } - } -} diff --git a/src/Test/L0/Listener/JobDispatcherL0.cs b/src/Test/L0/Listener/JobDispatcherL0.cs index c1d5346fe0a..cc50c180456 100644 --- a/src/Test/L0/Listener/JobDispatcherL0.cs +++ b/src/Test/L0/Listener/JobDispatcherL0.cs @@ -41,7 +41,7 @@ private Pipelines.AgentJobRequestMessage CreateJobRequestMessage() TaskOrchestrationPlanReference plan = new(); TimelineReference timeline = null; Guid jobId = Guid.NewGuid(); - var result = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "someJob", "someJob", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var result = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "someJob", "someJob", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); result.ContextData["github"] = new Pipelines.ContextData.DictionaryContextData(); return result; } @@ -810,7 +810,6 @@ private static AgentJobRequestMessage GetAgentJobRequestMessage() null, new List(), new ActionsEnvironmentReference("env"), - null, null ); return message; diff --git a/src/Test/L0/Listener/RunnerL0.cs b/src/Test/L0/Listener/RunnerL0.cs index 3010dcb402a..b29f8835c2b 100644 --- a/src/Test/L0/Listener/RunnerL0.cs +++ b/src/Test/L0/Listener/RunnerL0.cs @@ -44,7 +44,7 @@ private Pipelines.AgentJobRequestMessage CreateJobRequestMessage(string jobName) TaskOrchestrationPlanReference plan = new(); TimelineReference timeline = null; Guid jobId = Guid.NewGuid(); - return new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + return new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); } private JobCancelMessage CreateJobCancelMessage() diff --git a/src/Test/L0/Worker/ActionCommandManagerL0.cs b/src/Test/L0/Worker/ActionCommandManagerL0.cs index 8be95ae4da5..3a1f8f70fe9 100644 --- a/src/Test/L0/Worker/ActionCommandManagerL0.cs +++ b/src/Test/L0/Worker/ActionCommandManagerL0.cs @@ -232,7 +232,7 @@ public void EchoProcessCommandDebugOn() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, diff --git a/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs b/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs index 972d6843bd7..185f44b3865 100644 --- a/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs +++ b/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs @@ -193,7 +193,7 @@ private TestHostContext Setup([CallerMemberName] string name = "") TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "Summary Job"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, diff --git a/src/Test/L0/Worker/ExecutionContextL0.cs b/src/Test/L0/Worker/ExecutionContextL0.cs index 0054c969938..08abcd09585 100644 --- a/src/Test/L0/Worker/ExecutionContextL0.cs +++ b/src/Test/L0/Worker/ExecutionContextL0.cs @@ -29,7 +29,7 @@ public void AddIssue_CountWarningsErrors() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -106,7 +106,7 @@ public void ApplyContinueOnError_CheckResultAndOutcome() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -162,7 +162,7 @@ public void AddIssue_TrimMessageSize() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -216,7 +216,7 @@ public void AddIssue_OverrideLogMessage() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -271,7 +271,7 @@ public void AddIssue_AddStepAndLineNumberInformation() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -322,7 +322,7 @@ public void Debug_Multilines() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -373,7 +373,7 @@ public void RegisterPostJobAction_ShareState() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -471,7 +471,7 @@ public void RegisterPostJobAction_NotRegisterPostTwice() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -555,7 +555,7 @@ public void ActionResult_Lowercase() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -610,7 +610,7 @@ public void PublishStepTelemetry_RegularStep_NoOpt() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -653,7 +653,7 @@ public void PublishStepTelemetry_RegularStep() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -717,7 +717,7 @@ public void PublishStepTelemetry_EmbeddedStep() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -781,7 +781,7 @@ public void PublishStepResult_EmbeddedStep() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -969,7 +969,7 @@ public void ActionVariables_AddedToVarsContext() TimelineReference timeline = new(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -1014,7 +1014,7 @@ public void ActionVariables_DebugUsingVars() TimelineReference timeline = new TimelineReference(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, @@ -1057,7 +1057,7 @@ public void ActionVariables_SecretsPrecedenceForDebugUsingVars() TimelineReference timeline = new TimelineReference(); Guid jobId = Guid.NewGuid(); string jobName = "some job name"; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, null, null); jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource() { Alias = Pipelines.PipelineConstants.SelfAlias, diff --git a/src/Test/L0/Worker/JobExtensionL0.cs b/src/Test/L0/Worker/JobExtensionL0.cs index 6ada9143dc3..4f5834fbe69 100644 --- a/src/Test/L0/Worker/JobExtensionL0.cs +++ b/src/Test/L0/Worker/JobExtensionL0.cs @@ -114,7 +114,7 @@ private TestHostContext CreateTestContext([CallerMemberName] String testName = " }; Guid jobId = Guid.NewGuid(); - _message = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), steps, null, null, null, null, null, null); + _message = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), steps, null, null, null, null, null); GitHubContext github = new(); github["repository"] = new Pipelines.ContextData.StringContextData("actions/runner"); github["secret_source"] = new Pipelines.ContextData.StringContextData("Actions"); diff --git a/src/Test/L0/Worker/JobRunnerL0.cs b/src/Test/L0/Worker/JobRunnerL0.cs index c1021150c6f..e8011b9b051 100644 --- a/src/Test/L0/Worker/JobRunnerL0.cs +++ b/src/Test/L0/Worker/JobRunnerL0.cs @@ -102,7 +102,6 @@ private Pipelines.AgentJobRequestMessage GetMessage(String messageType = JobRequ testName, null, null, null, new Dictionary(), new List(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List(), null, null, null, new ActionsEnvironmentReference("staging"), null, - null, messageType: messageType); message.Variables[Constants.Variables.System.Culture] = "en-US"; message.Resources.Endpoints.Add(new ServiceEndpoint() diff --git a/src/Test/L0/Worker/OSWarningCheckerL0.cs b/src/Test/L0/Worker/OSWarningCheckerL0.cs deleted file mode 100644 index 7f4d0f32ee2..00000000000 --- a/src/Test/L0/Worker/OSWarningCheckerL0.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using GitHub.DistributedTask.Pipelines; -using GitHub.DistributedTask.WebApi; -using GitHub.Runner.Worker; -using Moq; -using Xunit; - -namespace GitHub.Runner.Common.Tests.Worker -{ - public sealed class OSWarningCheckerL0 - { - private CancellationTokenSource _ecTokenSource; - private Mock _ec; - private TestHostContext _hc; - private OSWarningChecker _osWarningChecker; - private List _issues; - private string _workFolder; - - [Fact] - [Trait("Level", "L0")] - [Trait("Category", "Worker")] - public async void CheckOS_FileNotExists() - { - try - { - // Arrange - Setup(); - var osWarnings = new List - { - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release"), - RegularExpression = "some OS version", - Warning = "Some OS version will be deprecated soon" - }, - }; - - // Act - await _osWarningChecker.CheckOSAsync(_ec.Object, osWarnings); - - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(0, _ec.Object.Global.JobTelemetry.Count); - } - finally - { - Teardown(); - } - } - - [Fact] - [Trait("Level", "L0")] - [Trait("Category", "Worker")] - public async void CheckOS_CaseInsensitive() - { - try - { - // Arrange - Setup(); - var osWarnings = new List - { - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release"), - RegularExpression = "some OS verSION", - Warning = "Some OS version will be deprecated soon" - }, - }; - File.WriteAllText(Path.Combine(_workFolder, "os-release"), "some OS version\n"); - - // Act - await _osWarningChecker.CheckOSAsync(_ec.Object, osWarnings); - -#if OS_WINDOWS || OS_OSX - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(0, _ec.Object.Global.JobTelemetry.Count); -#else - // Assert - Assert.Equal(1, _issues.Count); - Assert.Equal(IssueType.Warning, _issues[0].Type); - Assert.Equal("Some OS version will be deprecated soon", _issues[0].Message); - Assert.Equal(1, _ec.Object.Global.JobTelemetry.Count); - Assert.Equal(JobTelemetryType.General, _ec.Object.Global.JobTelemetry[0].Type); - Assert.Equal("OS warning: Some OS version will be deprecated soon", _ec.Object.Global.JobTelemetry[0].Message); -#endif - } - finally - { - Teardown(); - } - } - - [Fact] - [Trait("Level", "L0")] - [Trait("Category", "Worker")] - public async void CheckOS_MatchesOnceWithinAFile() - { - try - { - // Arrange - Setup(); - var osWarnings = new List - { - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release"), - RegularExpression = "some OS version", - Warning = "Some OS version will be deprecated soon" - }, - }; - File.WriteAllText(Path.Combine(_workFolder, "os-release"), "some OS version\nsome OS version\n"); - - // Act - await _osWarningChecker.CheckOSAsync(_ec.Object, osWarnings); - -#if OS_WINDOWS || OS_OSX - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(0, _ec.Object.Global.JobTelemetry.Count); -#else - // Assert - Assert.Equal(1, _issues.Count); - Assert.Equal(IssueType.Warning, _issues[0].Type); - Assert.Equal("Some OS version will be deprecated soon", _issues[0].Message); - Assert.Equal(1, _ec.Object.Global.JobTelemetry.Count); - Assert.Equal(JobTelemetryType.General, _ec.Object.Global.JobTelemetry[0].Type); - Assert.Equal("OS warning: Some OS version will be deprecated soon", _ec.Object.Global.JobTelemetry[0].Message); -#endif - } - finally - { - Teardown(); - } - } - - [Fact] - [Trait("Level", "L0")] - [Trait("Category", "Worker")] - public async void CheckOS_MatchesOnceAcrossFiles() - { - try - { - // Arrange - Setup(); - var osWarnings = new List - { - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release"), - RegularExpression = "some OS version", - Warning = "Some OS version will be deprecated soon" - }, - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release-2"), - RegularExpression = "some OS version", - Warning = "Some OS version will be deprecated soon" - }, - }; - File.WriteAllText(Path.Combine(_workFolder, "os-release"), "some OS version\n"); - File.WriteAllText(Path.Combine(_workFolder, "os-release-2"), "some OS version\n"); - - // Act - await _osWarningChecker.CheckOSAsync(_ec.Object, osWarnings); - -#if OS_WINDOWS || OS_OSX - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(0, _ec.Object.Global.JobTelemetry.Count); -#else - // Assert - Assert.Equal(1, _issues.Count); - Assert.Equal(IssueType.Warning, _issues[0].Type); - Assert.Equal("Some OS version will be deprecated soon", _issues[0].Message); - Assert.Equal(1, _ec.Object.Global.JobTelemetry.Count); - Assert.Equal(JobTelemetryType.General, _ec.Object.Global.JobTelemetry[0].Type); - Assert.Equal("OS warning: Some OS version will be deprecated soon", _ec.Object.Global.JobTelemetry[0].Message); -#endif - } - finally - { - Teardown(); - } - } - - [Fact] - [Trait("Level", "L0")] - [Trait("Category", "Worker")] - public async void CheckOS_LogsTelemetryUponException() - { - try - { - // Arrange - Setup(); - var osWarnings = new List - { - new OSWarning - { - FilePath = Path.Combine(_workFolder, "os-release"), - RegularExpression = "abc[", // Invalid pattern - Warning = "Some OS version will be deprecated soon" - }, - }; - File.WriteAllText(Path.Combine(_workFolder, "os-release"), "some OS version\n"); - - // Act - await _osWarningChecker.CheckOSAsync(_ec.Object, osWarnings); - -#if OS_WINDOWS || OS_OSX - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(0, _ec.Object.Global.JobTelemetry.Count); -#else - // Assert - Assert.Equal(0, _issues.Count); - Assert.Equal(1, _ec.Object.Global.JobTelemetry.Count); - Assert.Equal(JobTelemetryType.General, _ec.Object.Global.JobTelemetry[0].Type); - Assert.Equal( - $"An error occurred while checking OS warnings for file '{osWarnings[0].FilePath}' and regex '{osWarnings[0].RegularExpression}': Invalid pattern 'abc[' at offset 4. Unterminated [] set.", - _ec.Object.Global.JobTelemetry[0].Message); -#endif - } - finally - { - Teardown(); - } - } - - private void Setup([CallerMemberName] string name = "") - { - _issues = new List(); - - // Test host context - _hc = new TestHostContext(this, name); - - // Random work folder - _workFolder = _hc.GetDirectory(WellKnownDirectory.Work); - Directory.CreateDirectory(_workFolder); - - // Execution context token source - _ecTokenSource?.Dispose(); - _ecTokenSource = new CancellationTokenSource(); - - // Execution context - _ec = new Mock(); - _ec.Setup(x => x.Global).Returns(new GlobalContext()); - _ec.Setup(x => x.CancellationToken).Returns(_ecTokenSource.Token); - _ec.Object.Global.JobTelemetry = new List(); - _ec.Setup(x => x.AddIssue(It.IsAny(), It.IsAny())).Callback((Issue issue, ExecutionContextLogOptions logOptions) => { _issues.Add(issue); }); - - // OS warning checker - _osWarningChecker = new OSWarningChecker(); - _osWarningChecker.Initialize(_hc); - } - - private void Teardown() - { - _hc?.Dispose(); - if (!string.IsNullOrEmpty(_workFolder) && Directory.Exists(_workFolder)) - { - Directory.Delete(_workFolder, recursive: true); - } - } - } -} diff --git a/src/Test/L0/Worker/WorkerL0.cs b/src/Test/L0/Worker/WorkerL0.cs index ba6a933afdd..defcc981404 100644 --- a/src/Test/L0/Worker/WorkerL0.cs +++ b/src/Test/L0/Worker/WorkerL0.cs @@ -67,7 +67,7 @@ private Pipelines.AgentJobRequestMessage CreateJobRequestMessage(string jobName) new Pipelines.ContextData.DictionaryContextData() }, }; - var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, JobId, jobName, jobName, new StringToken(null, null, null, "ubuntu"), sidecarContainers, null, variables, new List(), resources, context, null, actions, null, null, null, null, null, null); + var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, JobId, jobName, jobName, new StringToken(null, null, null, "ubuntu"), sidecarContainers, null, variables, new List(), resources, context, null, actions, null, null, null, null, null); return jobRequest; } diff --git a/src/TestDotNet8Compatibility/Program.cs b/src/TestDotNet8Compatibility/Program.cs new file mode 100644 index 00000000000..0d231953003 --- /dev/null +++ b/src/TestDotNet8Compatibility/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace TestDotNet8Compatibility +{ + public static class Program + { + public static int Main(string[] args) + { + Console.WriteLine("Hello from .NET 8!"); + return 0; + } + } +} diff --git a/src/TestDotNet8Compatibility/TestDotNet8Compatibility.csproj b/src/TestDotNet8Compatibility/TestDotNet8Compatibility.csproj new file mode 100644 index 00000000000..5fb8e44a1cf --- /dev/null +++ b/src/TestDotNet8Compatibility/TestDotNet8Compatibility.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 + true + true + true + $(Version) + false + true + + + + portable + + + diff --git a/src/TestDotNet8Compatibility/dir.proj b/src/TestDotNet8Compatibility/dir.proj new file mode 100644 index 00000000000..fa8200ba95a --- /dev/null +++ b/src/TestDotNet8Compatibility/dir.proj @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/TestDotNet8Compatibility/global.json b/src/TestDotNet8Compatibility/global.json new file mode 100644 index 00000000000..fd07d882ad3 --- /dev/null +++ b/src/TestDotNet8Compatibility/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.303" + } +} diff --git a/src/dev.sh b/src/dev.sh index 0fc58761e53..71c80637c02 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -19,6 +19,8 @@ PACKAGE_DIR="$SCRIPT_DIR/../_package" DOTNETSDK_ROOT="$SCRIPT_DIR/../_dotnetsdk" DOTNETSDK_VERSION="6.0.421" DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION" +DOTNET8SDK_VERSION="8.0.303" +DOTNET8SDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNET8SDK_VERSION" RUNNER_VERSION=$(cat runnerversion) pushd "$SCRIPT_DIR" @@ -125,6 +127,19 @@ function build () { heading "Building ..." dotnet msbuild -t:Build -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed build + + # Build TestDotNet8Compatibility + heading "Building .NET 8 compatibility test" + echo "Prepend ${DOTNET8SDK_INSTALLDIR} to %PATH%" # Prepend .NET 8 SDK to PATH + PATH_BAK=$PATH + export PATH=${DOTNET8SDK_INSTALLDIR}:$PATH + pushd "$SCRIPT_DIR/TestDotNet8Compatibility" > /dev/null # Working directory + pwd + echo "Dotnet 8 SDK Version" + dotnet --version + dotnet msbuild -t:Build -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed build + popd > /dev/null # Restore working directory + export PATH=$PATH_BAK # Restore PATH } function layout () @@ -143,6 +158,18 @@ function layout () heading "Setup externals folder for $RUNTIME_ID runner's layout" bash ./Misc/externals.sh $RUNTIME_ID || checkRC externals.sh + + # Build TestDotNet8Compatibility + echo "Prepend ${DOTNET8SDK_INSTALLDIR} to %PATH%" # Prepend .NET 8 SDK to PATH + PATH_BAK=$PATH + export PATH=${DOTNET8SDK_INSTALLDIR}:$PATH + pushd "$SCRIPT_DIR/TestDotNet8Compatibility" > /dev/null # Working directory + heading "Dotnet 8 SDK Version" + dotnet --version + heading "Building .NET 8 compatibility test" + dotnet msbuild -t:layout -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed build + popd > /dev/null # Restore working directory + export PATH=$PATH_BAK # Restore PATH } function runtest () @@ -199,6 +226,7 @@ function package () popd > /dev/null } +# Install .NET SDK if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}") || (! -e "${DOTNETSDK_INSTALLDIR}/dotnet") ]]; then # Download dotnet SDK to ../_dotnetsdk directory @@ -224,6 +252,32 @@ if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTN echo "${DOTNETSDK_VERSION}" > "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}" fi +# Install .NET 8 SDK +if [[ (! -d "${DOTNET8SDK_INSTALLDIR}") || (! -e "${DOTNET8SDK_INSTALLDIR}/.${DOTNET8SDK_VERSION}") || (! -e "${DOTNET8SDK_INSTALLDIR}/dotnet") ]]; then + + # Download dotnet 8 SDK to ../_dotnetsdk directory + heading "Ensure Dotnet 8 SDK" + + # _dotnetsdk + # \1.0.x + # \dotnet + # \.1.0.x + echo "Download dotnet8sdk into ${DOTNET8SDK_INSTALLDIR}" + rm -Rf "${DOTNETSDK_DIR}" + + # run dotnet-install.ps1 on windows, dotnet-install.sh on linux + if [[ ("$CURRENT_PLATFORM" == "windows") ]]; then + echo "Convert ${DOTNET8SDK_INSTALLDIR} to Windows style path" + sdkinstallwindow_path=${DOTNET8SDK_INSTALLDIR:1} + sdkinstallwindow_path=${sdkinstallwindow_path:0:1}:${sdkinstallwindow_path:1} + $POWERSHELL -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& \"./Misc/dotnet-install.ps1\" -Version ${DOTNET8SDK_VERSION} -InstallDir \"${sdkinstallwindow_path}\" -NoPath; exit \$LastExitCode;" || checkRC dotnet-install.ps1 + else + bash ./Misc/dotnet-install.sh --version ${DOTNET8SDK_VERSION} --install-dir "${DOTNET8SDK_INSTALLDIR}" --no-path || checkRC dotnet-install.sh + fi + + echo "${DOTNET8SDK_VERSION}" > "${DOTNET8SDK_INSTALLDIR}/.${DOTNET8SDK_VERSION}" +fi + echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%" export PATH=${DOTNETSDK_INSTALLDIR}:$PATH