From f8bb790d593979dbff2aad464b2629491f2cf110 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 22:35:37 +0100 Subject: [PATCH 01/45] wip --- src/Cli/Infrastructure/Bootstrapper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cli/Infrastructure/Bootstrapper.cs b/src/Cli/Infrastructure/Bootstrapper.cs index 2b19720a..2e82b578 100644 --- a/src/Cli/Infrastructure/Bootstrapper.cs +++ b/src/Cli/Infrastructure/Bootstrapper.cs @@ -4,9 +4,9 @@ namespace Drift.Cli.Infrastructure; internal static class Bootstrapper { internal static Task BootstrapAsync() { - if ( !RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) ) { + /*if ( !RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) ) { throw new Exception( "Only Linux is supported" ); - } + }*/ return Task.CompletedTask; } From 3268400edf405eca83c292589c3e1b38725f0d54 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 22:55:59 +0100 Subject: [PATCH 02/45] windows ping tool implementation --- src/Cli/Infrastructure/RootCommandFactory.cs | 2 ++ src/Scanning/LinuxPingTool.cs | 1 + src/Scanning/WindowsPingTool.cs | 21 ++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/Scanning/WindowsPingTool.cs diff --git a/src/Cli/Infrastructure/RootCommandFactory.cs b/src/Cli/Infrastructure/RootCommandFactory.cs index 1161862f..ef3cdc08 100644 --- a/src/Cli/Infrastructure/RootCommandFactory.cs +++ b/src/Cli/Infrastructure/RootCommandFactory.cs @@ -131,6 +131,8 @@ private static void ConfigureDynamicCommands( private static void ConfigureNetworkScanner( IServiceCollection services ) { if ( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) ) { services.AddSingleton(); + } else if ( RuntimeInformation.IsOSPlatform( OSPlatform.Windows ) ) { + services.AddSingleton(); } else { throw new PlatformNotSupportedException(); diff --git a/src/Scanning/LinuxPingTool.cs b/src/Scanning/LinuxPingTool.cs index c8decb39..aa0c03f9 100644 --- a/src/Scanning/LinuxPingTool.cs +++ b/src/Scanning/LinuxPingTool.cs @@ -14,6 +14,7 @@ public async Task PingAsync( CancellationToken cancellationToken = default ) { var tool = new ToolWrapper( "ping" ); + // c = stop after replies, W = time to wait for response var result = await tool.ExecuteAsync( $"-c 1 -W 1 {ip}", logger, cancellationToken ); return new PingResult( result.ExitCode == 0 ); } diff --git a/src/Scanning/WindowsPingTool.cs b/src/Scanning/WindowsPingTool.cs new file mode 100644 index 00000000..59be6223 --- /dev/null +++ b/src/Scanning/WindowsPingTool.cs @@ -0,0 +1,21 @@ +using System.Net; +using System.Runtime.Versioning; +using Drift.Common; +using Microsoft.Extensions.Logging; + +namespace Drift.Scanning; + +// TODO should be possible to make internal by adding to dependency injection via this project +[SupportedOSPlatform( "windows" )] +public class WindowsPingTool : IPingTool { + public async Task PingAsync( + IPAddress ip, + ILogger logger, + CancellationToken cancellationToken = default + ) { + var tool = new ToolWrapper( "ping" ); + // n = Number of echo requests to send, w = Timeout in milliseconds to wait for each reply + var result = await tool.ExecuteAsync( $"-n 1 -w 1 {ip}", logger, cancellationToken ); + return new PingResult( result.ExitCode == 0 ); + } +} \ No newline at end of file From 66d761aec2d1d8eed8f3e816a31efa19ca094720 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:08:18 +0100 Subject: [PATCH 03/45] ci: windows workflow --- .github/actions/setup-runner/action.yml | 6 +-- .github/workflows/ci_windows.yaml | 54 +++++++++++++++++++++++++ Drift.sln | 1 + 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci_windows.yaml diff --git a/.github/actions/setup-runner/action.yml b/.github/actions/setup-runner/action.yml index 3a67909d..286ffeca 100644 --- a/.github/actions/setup-runner/action.yml +++ b/.github/actions/setup-runner/action.yml @@ -16,6 +16,6 @@ runs: with: dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Restore .NET tools - shell: bash - run: dotnet tool restore + #- name: Restore .NET tools + # shell: bash + # run: dotnet tool restore diff --git a/.github/workflows/ci_windows.yaml b/.github/workflows/ci_windows.yaml new file mode 100644 index 00000000..9b013d89 --- /dev/null +++ b/.github/workflows/ci_windows.yaml @@ -0,0 +1,54 @@ +name: 🔁 🪟 CI +permissions: + contents: read + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + inputs: + verbosity: + description: 'MSBuild verbosity level' + required: false + default: 'normal' + type: choice + options: + - 'quiet' + - 'minimal' + - 'normal' + - 'detailed' + - 'diagnostic' + +jobs: + test: + name: Test + runs-on: windows-latest + timeout-minutes: 5 + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Set up runner + uses: ./.github/actions/setup-runner + + - name: Run tests + run: | + dotnet run \ + --project ./build/_build.csproj \ + --target Test \ + --commit ${{ github.sha }} \ + --msbuildverbosity ${{ github.event.inputs.verbosity }} + + - name: Display test results + continue-on-error: true + if: always() + run: dotnet trx --verbosity normal + + # TODO fix publish warnings and re-enable check + - name: Check for warnings + run: | + dotnet run \ + --project ./build/_build.csproj \ + --target CheckBuildWarnings diff --git a/Drift.sln b/Drift.sln index d29c2422..f67db7ee 100644 --- a/Drift.sln +++ b/Drift.sln @@ -61,6 +61,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{ .github\workflows\ci.yaml = .github\workflows\ci.yaml .github\workflows\release.yaml = .github\workflows\release.yaml .github\workflows\prerelease.yaml = .github\workflows\prerelease.yaml + .github\workflows\ci_windows.yaml = .github\workflows\ci_windows.yaml EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cli.E2ETests.Abstractions", "src\Cli.E2ETests.Abstractions\Cli.E2ETests.Abstractions.csproj", "{A2CE629F-8D56-4539-9642-C31B550F7C30}" From fcfddfc48d7ceb00f4d4941028f147a101e1f1f8 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:13:54 +0100 Subject: [PATCH 04/45] linux only tests --- src/Cli.E2ETests/DriftImageFixture.cs | 1 + src/Cli.E2ETests/Installation/InstallTests.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Cli.E2ETests/DriftImageFixture.cs b/src/Cli.E2ETests/DriftImageFixture.cs index 1821460f..5186e294 100644 --- a/src/Cli.E2ETests/DriftImageFixture.cs +++ b/src/Cli.E2ETests/DriftImageFixture.cs @@ -5,6 +5,7 @@ namespace Drift.Cli.E2ETests; +[Platform("Linux")] internal abstract class DriftImageFixture { protected static QualifiedImageRef DriftImage { get; diff --git a/src/Cli.E2ETests/Installation/InstallTests.cs b/src/Cli.E2ETests/Installation/InstallTests.cs index eec1bd9d..47828bb7 100644 --- a/src/Cli.E2ETests/Installation/InstallTests.cs +++ b/src/Cli.E2ETests/Installation/InstallTests.cs @@ -10,6 +10,7 @@ namespace Drift.Cli.E2ETests.Installation; "S2325:Methods and properties that don\'t access instance data should be static", Justification = "Unimplemented test methods should not be static" )] +[Platform("Linux")] internal sealed class InstallTests { // TODO split test into at least two parts [Test] From 83dba0a04fa188c53afb02de4921f7fd21940d7d Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:20:33 +0100 Subject: [PATCH 05/45] windows multiline command backticks --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dbf0b9b8..d62598df 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,10 +38,10 @@ jobs: - name: Run tests run: | - dotnet run \ - --project ./build/_build.csproj \ - --target Test \ - --commit ${{ github.sha }} \ + dotnet run ` + --project ./build/_build.csproj ` + --target Test ` + --commit ${{ github.sha }} ` --msbuildverbosity ${{ github.event.inputs.verbosity }} - name: Display test results @@ -52,6 +52,6 @@ jobs: # TODO fix publish warnings and re-enable check - name: Check for warnings run: | - dotnet run \ - --project ./build/_build.csproj \ + dotnet run ` + --project ./build/_build.csproj ` --target CheckBuildWarnings From 29535bf6b378c2446d014ea19f321cb86246e040 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:22:50 +0100 Subject: [PATCH 06/45] oops --- .github/workflows/ci.yaml | 12 ++++++------ .github/workflows/ci_windows.yaml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d62598df..dbf0b9b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,10 +38,10 @@ jobs: - name: Run tests run: | - dotnet run ` - --project ./build/_build.csproj ` - --target Test ` - --commit ${{ github.sha }} ` + dotnet run \ + --project ./build/_build.csproj \ + --target Test \ + --commit ${{ github.sha }} \ --msbuildverbosity ${{ github.event.inputs.verbosity }} - name: Display test results @@ -52,6 +52,6 @@ jobs: # TODO fix publish warnings and re-enable check - name: Check for warnings run: | - dotnet run ` - --project ./build/_build.csproj ` + dotnet run \ + --project ./build/_build.csproj \ --target CheckBuildWarnings diff --git a/.github/workflows/ci_windows.yaml b/.github/workflows/ci_windows.yaml index 9b013d89..11e7c196 100644 --- a/.github/workflows/ci_windows.yaml +++ b/.github/workflows/ci_windows.yaml @@ -35,10 +35,10 @@ jobs: - name: Run tests run: | - dotnet run \ - --project ./build/_build.csproj \ - --target Test \ - --commit ${{ github.sha }} \ + dotnet run ` + --project ./build/_build.csproj ` + --target Test ` + --commit ${{ github.sha }} ` --msbuildverbosity ${{ github.event.inputs.verbosity }} - name: Display test results @@ -49,6 +49,6 @@ jobs: # TODO fix publish warnings and re-enable check - name: Check for warnings run: | - dotnet run \ - --project ./build/_build.csproj \ + dotnet run ` + --project ./build/_build.csproj ` --target CheckBuildWarnings From 032fa69750d165f0d8afbcd11a093c05f0736bd0 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:25:34 +0100 Subject: [PATCH 07/45] temp skip e2e on windows --- .github/workflows/ci_windows.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci_windows.yaml b/.github/workflows/ci_windows.yaml index 11e7c196..7fbdd20d 100644 --- a/.github/workflows/ci_windows.yaml +++ b/.github/workflows/ci_windows.yaml @@ -34,10 +34,12 @@ jobs: uses: ./.github/actions/setup-runner - name: Run tests + # TODO re-enable TestE2E run: | dotnet run ` --project ./build/_build.csproj ` --target Test ` + --skip TestE2E ` --commit ${{ github.sha }} ` --msbuildverbosity ${{ github.event.inputs.verbosity }} From 3f0e053defba16104cb3e926e6b8fcee27aeaaad Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:34:25 +0100 Subject: [PATCH 08/45] f --- .github/actions/setup-runner/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-runner/action.yml b/.github/actions/setup-runner/action.yml index 286ffeca..3a67909d 100644 --- a/.github/actions/setup-runner/action.yml +++ b/.github/actions/setup-runner/action.yml @@ -16,6 +16,6 @@ runs: with: dotnet-version: ${{ env.DOTNET_VERSION }} - #- name: Restore .NET tools - # shell: bash - # run: dotnet tool restore + - name: Restore .NET tools + shell: bash + run: dotnet tool restore From f72d8d48f0eeb6b877b71ccbc049f8b9bdc3dd39 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:47:52 +0100 Subject: [PATCH 09/45] platform --- src/Cli.Tests/Platform.cs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/Cli.Tests/Platform.cs diff --git a/src/Cli.Tests/Platform.cs b/src/Cli.Tests/Platform.cs new file mode 100644 index 00000000..084e6985 --- /dev/null +++ b/src/Cli.Tests/Platform.cs @@ -0,0 +1,6 @@ +namespace Drift.Cli.Tests; + +internal enum Platform { + Linux, + Windows +} \ No newline at end of file From d3d2d75628aa0d06c33cd1ad9266420f3cd1ccd3 Mon Sep 17 00:00:00 2001 From: hojmark <1203136+hojmark@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:07:24 +0100 Subject: [PATCH 10/45] f --- ...le_device_host_outputFormat=.verified.txt} | 0 ...device_host_outputFormat=log.verified.txt} | 0 ...ice_host_outputFormat=normal.verified.txt} | 0 ...gle_device_host_outputFormat=.verified.txt | 4 ++++ ..._device_host_outputFormat=log.verified.txt | 4 ++++ ...vice_host_outputFormat=normal.verified.txt | 4 ++++ ...k_single_subnet_outputFormat=.verified.txt | 2 ++ ...ingle_subnet_outputFormat=log.verified.txt | 2 ++ ...le_subnet_outputFormat=normal.verified.txt | 2 ++ ...k_single_subnet_outputFormat=.verified.txt | 2 ++ ...ingle_subnet_outputFormat=log.verified.txt | 1 + ...le_subnet_outputFormat=normal.verified.txt | 1 + ...ingle_subnet_outputFormat=log.verified.txt | 3 +-- src/Cli.Tests/Commands/LintCommandTests.cs | 21 +++++++++++++++++++ 14 files changed, 44 insertions(+), 2 deletions(-) rename src/Cli.Tests/Commands/{LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=.verified.txt => LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=.verified.txt} (100%) rename src/Cli.Tests/Commands/{LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=log.verified.txt => LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=log.verified.txt} (100%) rename src/Cli.Tests/Commands/{LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=normal.verified.txt => LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=normal.verified.txt} (100%) create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=log.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=normal.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Linux_specName=network_single_subnet_outputFormat=.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Linux_specName=network_single_subnet_outputFormat=log.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Linux_specName=network_single_subnet_outputFormat=normal.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Windows_specName=network_single_subnet_outputFormat=.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Windows_specName=network_single_subnet_outputFormat=log.verified.txt create mode 100644 src/Cli.Tests/Commands/LintCommandTests.LintValidSpec_platform=Windows_specName=network_single_subnet_outputFormat=normal.verified.txt diff --git a/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=.verified.txt b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=.verified.txt similarity index 100% rename from src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=.verified.txt rename to src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=.verified.txt diff --git a/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=log.verified.txt b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=log.verified.txt similarity index 100% rename from src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=log.verified.txt rename to src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=log.verified.txt diff --git a/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=normal.verified.txt b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=normal.verified.txt similarity index 100% rename from src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_specName=network_single_device_host_outputFormat=normal.verified.txt rename to src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Linux_specName=network_single_device_host_outputFormat=normal.verified.txt diff --git a/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=.verified.txt b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=.verified.txt new file mode 100644 index 00000000..141e68ec --- /dev/null +++ b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=.verified.txt @@ -0,0 +1,4 @@ +Validating {SolutionDirectory}src\Spec.Tests\resources\network_single_device_host.yaml +✗ Validation failed +• /: Required properties ["version"] are not present +• /network/subnets/0: Required properties ["address"] are not present diff --git a/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=log.verified.txt b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=log.verified.txt new file mode 100644 index 00000000..b7807cca --- /dev/null +++ b/src/Cli.Tests/Commands/LintCommandTests.LintInvalidSpec_platform=Windows_specName=network_single_device_host_outputFormat=log.verified.txt @@ -0,0 +1,4 @@ +[