Skip to content

Commit a3a5327

Browse files
committed
CI: run .NET Framework Integration Tests on Windows
1 parent b803932 commit a3a5327

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

.github/workflows/build.yml

Lines changed: 24 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,29 @@ jobs:
132107
-p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml `
133108
test/Renci.SshNet.Tests/
134109
110+
- name: Setup WSL2
111+
uses: vedantmgoyal9/setup-wsl2@main
112+
113+
- name: Setup SSH Server
114+
shell: wsl-run {0}
115+
run: |
116+
apt update && apt upgrade -y
117+
apt-get install -y podman
118+
podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/
119+
podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image
120+
121+
- name: Run Integration Tests .NET Framework
122+
run:
123+
dotnet test `
124+
-f net48 `
125+
--no-build `
126+
--logger "console;verbosity=normal" `
127+
--logger GitHubActions `
128+
-p:CollectCoverage=true `
129+
-p:CoverletOutputFormat=cobertura `
130+
-p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml `
131+
test\Renci.SshNet.IntegrationTests\
132+
135133
- name: Archive Coverlet Results
136134
uses: actions/upload-artifact@v4
137135
with:

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)