From a3a53277c24ce45d32a199b4d55f5ace8cee3a4f Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 9 Mar 2025 11:28:17 +0100 Subject: [PATCH 1/5] CI: run .NET Framework Integration Tests on Windows --- .github/workflows/build.yml | 50 +++++++++---------- .../TestsFixtures/InfrastructureFixture.cs | 11 ++++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 458e018c5..5b429ca1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,9 +25,6 @@ jobs: - name: Build IntegrationTests .NET run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/ - - name: Build IntegrationTests .NET Framework - run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/ - - name: Run Unit Tests .NET run: | dotnet test \ @@ -52,28 +49,6 @@ jobs: -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \ test/Renci.SshNet.IntegrationTests/ - # Also run a subset of the integration tests targeting netfx using mono. This is a temporary measure to get - # some coverage until a proper solution for running the .NET Framework integration tests in CI is found. - # Running all the tests causes problems which are not worth solving in this rare configuration. - # See https://github.com/sshnet/SSH.NET/pull/1462 and related links - - name: Run Integration Tests Mono - run: | - sudo apt-get install ca-certificates gnupg - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list - sudo apt-get update - sudo apt-get install mono-devel - dotnet test \ - -f net48 \ - --no-build \ - --logger "console;verbosity=normal" \ - --logger GitHubActions \ - -p:CollectCoverage=true \ - -p:CoverletOutputFormat=cobertura \ - -p:CoverletOutput=../../coverlet/linux_integration_test_net_48_coverage.xml \ - --filter "Name~Ecdh|Name~ECDsa|Name~Zlib|Name~Gcm" \ - test/Renci.SshNet.IntegrationTests/ - - name: Archive Coverlet Results uses: actions/upload-artifact@v4 with: @@ -81,7 +56,7 @@ jobs: path: coverlet Windows: - runs-on: windows-2022 + runs-on: windows-2025 steps: - name: Checkout uses: actions/checkout@v4 @@ -132,6 +107,29 @@ jobs: -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` test/Renci.SshNet.Tests/ + - name: Setup WSL2 + uses: vedantmgoyal9/setup-wsl2@main + + - name: Setup SSH Server + shell: wsl-run {0} + run: | + apt update && apt upgrade -y + apt-get install -y podman + podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/ + podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image + + - name: Run Integration Tests .NET Framework + run: + dotnet test ` + -f net48 ` + --no-build ` + --logger "console;verbosity=normal" ` + --logger GitHubActions ` + -p:CollectCoverage=true ` + -p:CoverletOutputFormat=cobertura ` + -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` + test\Renci.SshNet.IntegrationTests\ + - name: Archive Coverlet Results uses: actions/upload-artifact@v4 with: diff --git a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs index 47629b67f..bcdb00d76 100644 --- a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs +++ b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs @@ -38,6 +38,17 @@ private InfrastructureFixture() public async Task InitializeAsync() { + // for the .NET Framework Tests in CI, the Container is set up in WSL2 with Podman +#if NETFRAMEWORK + if (Environment.GetEnvironmentVariable("CI") == "true") + { + SshServerPort = 2222; + SshServerHostName = "localhost"; + await Task.Delay(1_000); + return; + } +#endif + var containerLogger = _loggerFactory.CreateLogger("testcontainers"); _sshServerImage = new ImageFromDockerfileBuilder() From 9d21d93d92de4d9283cdcad79ca4a487cbbdf12b Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 14 Mar 2025 20:59:05 +0100 Subject: [PATCH 2/5] use apt-get --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b429ca1d..f7748ff35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,7 +113,7 @@ jobs: - name: Setup SSH Server shell: wsl-run {0} run: | - apt update && apt upgrade -y + apt-get update && apt-get upgrade -y apt-get install -y podman podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/ podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image From bd77900375bcd054393421f55a58990b54aa9126 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 14 Mar 2025 21:04:46 +0100 Subject: [PATCH 3/5] use vampire/setup-wsl --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7748ff35..4c5033eac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,10 +108,12 @@ jobs: test/Renci.SshNet.Tests/ - name: Setup WSL2 - uses: vedantmgoyal9/setup-wsl2@main + uses: Vampire/setup-wsl@v5 + with: + distribution: Ubuntu-24.04 - name: Setup SSH Server - shell: wsl-run {0} + shell: wsl-bash {0} run: | apt-get update && apt-get upgrade -y apt-get install -y podman From 8209e1ac70b981cc19d5474deeee1f5604478af5 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Mon, 17 Mar 2025 18:25:00 +0100 Subject: [PATCH 4/5] Run Windows Integration Tests in separate job so publish doesn't depend on it --- .github/workflows/build.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c5033eac..5e8eb3095 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,6 +107,20 @@ jobs: -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` test/Renci.SshNet.Tests/ + Windows-Integration-Tests: + name: Windows Integration Tests + runs-on: windows-2025 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # needed for Nerdbank.GitVersioning + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + - name: Setup WSL2 uses: Vampire/setup-wsl@v5 with: @@ -124,7 +138,6 @@ jobs: run: dotnet test ` -f net48 ` - --no-build ` --logger "console;verbosity=normal" ` --logger GitHubActions ` -p:CollectCoverage=true ` From 732ecc9b37bcb75daaba57d019b164034b660647 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Thu, 20 Mar 2025 18:27:43 +0100 Subject: [PATCH 5/5] Ignore flakey Test from #1253 in CI --- .../OldIntegrationTests/SftpClientTest.Upload.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs index e5cd91400..c48c53211 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs @@ -77,6 +77,11 @@ public void Test_Sftp_Upload_Forbidden() [TestCategory("Sftp")] public void Test_Sftp_Multiple_Async_Upload_And_Download_10Files_5MB_Each() { + if (Environment.GetEnvironmentVariable("CI") == "true") + { + Assert.Inconclusive("Skipping because of failures in CI, see #1253"); + } + var maxFiles = 10; var maxSize = 5;