Skip to content

Commit 071a8d5

Browse files
authored
CI: run .NET Framework Integration Tests on Windows (#1615)
* CI: run .NET Framework Integration Tests on Windows * use apt-get * use vampire/setup-wsl * Run Windows Integration Tests in separate job so publish doesn't depend on it * Ignore flakey Test from #1253 in CI
1 parent b803932 commit 071a8d5

File tree

3 files changed

+55
-26
lines changed

3 files changed

+55
-26
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
- name: Build IntegrationTests .NET
2626
run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
2727

28-
- name: Build IntegrationTests .NET Framework
29-
run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/
30-
3128
- name: Run Unit Tests .NET
3229
run: |
3330
dotnet test \
@@ -52,36 +49,14 @@ jobs:
5249
-p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
5350
test/Renci.SshNet.IntegrationTests/
5451
55-
# Also run a subset of the integration tests targeting netfx using mono. This is a temporary measure to get
56-
# some coverage until a proper solution for running the .NET Framework integration tests in CI is found.
57-
# Running all the tests causes problems which are not worth solving in this rare configuration.
58-
# See https://github.com/sshnet/SSH.NET/pull/1462 and related links
59-
- name: Run Integration Tests Mono
60-
run: |
61-
sudo apt-get install ca-certificates gnupg
62-
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
63-
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
64-
sudo apt-get update
65-
sudo apt-get install mono-devel
66-
dotnet test \
67-
-f net48 \
68-
--no-build \
69-
--logger "console;verbosity=normal" \
70-
--logger GitHubActions \
71-
-p:CollectCoverage=true \
72-
-p:CoverletOutputFormat=cobertura \
73-
-p:CoverletOutput=../../coverlet/linux_integration_test_net_48_coverage.xml \
74-
--filter "Name~Ecdh|Name~ECDsa|Name~Zlib|Name~Gcm" \
75-
test/Renci.SshNet.IntegrationTests/
76-
7752
- name: Archive Coverlet Results
7853
uses: actions/upload-artifact@v4
7954
with:
8055
name: Coverlet Results Linux
8156
path: coverlet
8257

8358
Windows:
84-
runs-on: windows-2022
59+
runs-on: windows-2025
8560
steps:
8661
- name: Checkout
8762
uses: actions/checkout@v4
@@ -132,6 +107,44 @@ jobs:
132107
-p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml `
133108
test/Renci.SshNet.Tests/
134109
110+
Windows-Integration-Tests:
111+
name: Windows Integration Tests
112+
runs-on: windows-2025
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@v4
116+
with:
117+
fetch-depth: 0 # needed for Nerdbank.GitVersioning
118+
119+
- name: Setup .NET
120+
uses: actions/setup-dotnet@v4
121+
with:
122+
dotnet-version: 9.0.x
123+
124+
- name: Setup WSL2
125+
uses: Vampire/setup-wsl@v5
126+
with:
127+
distribution: Ubuntu-24.04
128+
129+
- name: Setup SSH Server
130+
shell: wsl-bash {0}
131+
run: |
132+
apt-get update && apt-get upgrade -y
133+
apt-get install -y podman
134+
podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/
135+
podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image
136+
137+
- name: Run Integration Tests .NET Framework
138+
run:
139+
dotnet test `
140+
-f net48 `
141+
--logger "console;verbosity=normal" `
142+
--logger GitHubActions `
143+
-p:CollectCoverage=true `
144+
-p:CoverletOutputFormat=cobertura `
145+
-p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml `
146+
test\Renci.SshNet.IntegrationTests\
147+
135148
- name: Archive Coverlet Results
136149
uses: actions/upload-artifact@v4
137150
with:

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public void Test_Sftp_Upload_Forbidden()
7777
[TestCategory("Sftp")]
7878
public void Test_Sftp_Multiple_Async_Upload_And_Download_10Files_5MB_Each()
7979
{
80+
if (Environment.GetEnvironmentVariable("CI") == "true")
81+
{
82+
Assert.Inconclusive("Skipping because of failures in CI, see #1253");
83+
}
84+
8085
var maxFiles = 10;
8186
var maxSize = 5;
8287

test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ private InfrastructureFixture()
3838

3939
public async Task InitializeAsync()
4040
{
41+
// for the .NET Framework Tests in CI, the Container is set up in WSL2 with Podman
42+
#if NETFRAMEWORK
43+
if (Environment.GetEnvironmentVariable("CI") == "true")
44+
{
45+
SshServerPort = 2222;
46+
SshServerHostName = "localhost";
47+
await Task.Delay(1_000);
48+
return;
49+
}
50+
#endif
51+
4152
var containerLogger = _loggerFactory.CreateLogger("testcontainers");
4253

4354
_sshServerImage = new ImageFromDockerfileBuilder()

0 commit comments

Comments
 (0)