diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index 383ec7a10f5..d68d5cdf695 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -280,10 +280,6 @@ 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 DotNet8CompatibilityOutputLength = "system.dotNet8CompatibilityOutputLength"; - public static readonly string DotNet8CompatibilityOutputPattern = "system.dotNet8CompatibilityOutputPattern"; - public static readonly string DotNet8CompatibilityWarning = "system.dotNet8CompatibilityWarning"; } } diff --git a/src/Runner.Worker/JobExtension.cs b/src/Runner.Worker/JobExtension.cs index e111a77aac5..1aa79c925c8 100644 --- a/src/Runner.Worker/JobExtension.cs +++ b/src/Runner.Worker/JobExtension.cs @@ -127,10 +127,6 @@ public async Task> InitializeJob(IExecutionContext jobContext, Pipel } } - // Check OS warning - var osWarningChecker = HostContext.GetService(); - await osWarningChecker.CheckOSAsync(context); - try { var tokenPermissions = jobContext.Global.Variables.Get("system.github.token.permissions") ?? ""; diff --git a/src/Runner.Worker/OSWarningChecker.cs b/src/Runner.Worker/OSWarningChecker.cs deleted file mode 100644 index 765a41a5215..00000000000 --- a/src/Runner.Worker/OSWarningChecker.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using GitHub.DistributedTask.WebApi; -using GitHub.Runner.Common; -using GitHub.Runner.Sdk; - -namespace GitHub.Runner.Worker -{ - [ServiceLocator(Default = typeof(OSWarningChecker))] - public interface IOSWarningChecker : IRunnerService - { - Task CheckOSAsync(IExecutionContext context); - } - - public sealed class OSWarningChecker : RunnerService, IOSWarningChecker - { - private static TimeSpan s_regexTimeout = TimeSpan.FromSeconds(1); - - public async Task CheckOSAsync(IExecutionContext context) - { - ArgUtil.NotNull(context, nameof(context)); - if (!context.Global.Variables.System_TestDotNet8Compatibility) - { - return; - } - - context.Output("Testing runner upgrade compatibility"); - List output = new(); - object outputLock = new(); - try - { - using (var process = HostContext.CreateService()) - { - process.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout) - { - if (!string.IsNullOrEmpty(stdout.Data)) - { - lock (outputLock) - { - output.Add(stdout.Data); - Trace.Info(stdout.Data); - } - } - }; - - process.ErrorDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stderr) - { - if (!string.IsNullOrEmpty(stderr.Data)) - { - lock (outputLock) - { - output.Add(stderr.Data); - Trace.Error(stderr.Data); - } - } - }; - - using (var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) - { - 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)) - { - var pattern = context.Global.Variables.System_DotNet8CompatibilityOutputPattern; - if (!string.IsNullOrEmpty(pattern)) - { - var regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant, s_regexTimeout); - if (!regex.IsMatch(outputStr)) - { - return; - } - } - - var warningMessage = context.Global.Variables.System_DotNet8CompatibilityWarning; - if (!string.IsNullOrEmpty(warningMessage)) - { - 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(context, output)}" }); - } - } - } - } - 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(context, output)}'" }); - } - } - - private static string GetShortOutput(IExecutionContext context, List output) - { - var length = context.Global.Variables.System_DotNet8CompatibilityOutputLength ?? 200; - var outputStr = string.Join("\n", output).Trim(); - return outputStr.Length > length ? string.Concat(outputStr.Substring(0, length), "[...]") : outputStr; - } - } -} diff --git a/src/Runner.Worker/Variables.cs b/src/Runner.Worker/Variables.cs index 7627ec37984..916b82dc6a1 100644 --- a/src/Runner.Worker/Variables.cs +++ b/src/Runner.Worker/Variables.cs @@ -72,16 +72,8 @@ 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_DotNet8CompatibilityOutputPattern => Get(Constants.Variables.System.DotNet8CompatibilityOutputPattern); - - public int? System_DotNet8CompatibilityOutputLength => GetInt(Constants.Variables.System.DotNet8CompatibilityOutputLength); - 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/Test/L0/Worker/JobExtensionL0.cs b/src/Test/L0/Worker/JobExtensionL0.cs index 5db32d47a30..9ce99070bf6 100644 --- a/src/Test/L0/Worker/JobExtensionL0.cs +++ b/src/Test/L0/Worker/JobExtensionL0.cs @@ -140,7 +140,6 @@ private TestHostContext CreateTestContext([CallerMemberName] String testName = " hc.SetSingleton(_diagnosticLogManager.Object); hc.SetSingleton(_jobHookProvider.Object); hc.SetSingleton(_snapshotOperationProvider.Object); - hc.SetSingleton(new Mock().Object); hc.EnqueueInstance(_logger.Object); // JobExecutionContext hc.EnqueueInstance(_logger.Object); // job start hook hc.EnqueueInstance(_logger.Object); // Initial Job diff --git a/src/TestDotNet8Compatibility/Program.cs b/src/TestDotNet8Compatibility/Program.cs deleted file mode 100644 index 0d231953003..00000000000 --- a/src/TestDotNet8Compatibility/Program.cs +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 246b690a1ae..00000000000 --- a/src/TestDotNet8Compatibility/TestDotNet8Compatibility.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net8.0 - Exe - win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 - true - true - $(Version) - false - true - - - - portable - - - diff --git a/src/TestDotNet8Compatibility/dir.proj b/src/TestDotNet8Compatibility/dir.proj deleted file mode 100644 index fa8200ba95a..00000000000 --- a/src/TestDotNet8Compatibility/dir.proj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/TestDotNet8Compatibility/global.json b/src/TestDotNet8Compatibility/global.json deleted file mode 100644 index ff3b5e098b3..00000000000 --- a/src/TestDotNet8Compatibility/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "8.0.403" - } -} diff --git a/src/dev.sh b/src/dev.sh index 2c4c0cff358..795c135a232 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -19,8 +19,6 @@ PACKAGE_DIR="$SCRIPT_DIR/../_package" DOTNETSDK_ROOT="$SCRIPT_DIR/../_dotnetsdk" DOTNETSDK_VERSION="8.0.403" DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION" -DOTNET8SDK_VERSION="8.0.403" -DOTNET8SDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNET8SDK_VERSION" RUNNER_VERSION=$(cat runnerversion) pushd "$SCRIPT_DIR" @@ -127,19 +125,6 @@ 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 () @@ -158,18 +143,6 @@ 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 () @@ -252,32 +225,6 @@ 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