|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
| 6 | + - workflow_dispatch |
| 7 | + |
| 8 | +jobs: |
| 9 | + Linux: |
| 10 | + runs-on: ubuntu-24.04 |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 # needed for Nerdbank.GitVersioning |
| 16 | + |
| 17 | + - name: Setup .NET |
| 18 | + uses: actions/setup-dotnet@v4 |
| 19 | + with: |
| 20 | + dotnet-version: 8.0.x |
| 21 | + |
| 22 | + - name: Build Unit Tests .NET |
| 23 | + run: dotnet build -f net8.0 test/Renci.SshNet.Tests/ |
| 24 | + |
| 25 | + - name: Build IntegrationTests .NET |
| 26 | + run: dotnet build -f net8.0 test/Renci.SshNet.IntegrationTests/ |
| 27 | + |
| 28 | + - name: Build IntegrationTests .NET Framework |
| 29 | + run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/ |
| 30 | + |
| 31 | + - name: Run Unit Tests .NET |
| 32 | + run: | |
| 33 | + dotnet test \ |
| 34 | + -f net8.0 \ |
| 35 | + --no-build \ |
| 36 | + --logger "console;verbosity=normal" \ |
| 37 | + --logger GitHubActions \ |
| 38 | + -p:CollectCoverage=true \ |
| 39 | + -p:CoverletOutputFormat=cobertura \ |
| 40 | + -p:CoverletOutput=../../coverlet/linux_unit_test_net_8_coverage.xml \ |
| 41 | + test/Renci.SshNet.Tests/ |
| 42 | +
|
| 43 | + - name: Run Integration Tests .NET |
| 44 | + run: | |
| 45 | + dotnet test \ |
| 46 | + -f net8.0 \ |
| 47 | + --no-build \ |
| 48 | + --logger "console;verbosity=normal" \ |
| 49 | + --logger GitHubActions \ |
| 50 | + -p:CollectCoverage=true \ |
| 51 | + -p:CoverletOutputFormat=cobertura \ |
| 52 | + -p:CoverletOutput=../../coverlet/linux_integration_test_net_8_coverage.xml \ |
| 53 | + test/Renci.SshNet.IntegrationTests/ |
| 54 | +
|
| 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 | +
|
| 77 | + - name: Archive Coverlet Results |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: Coverlet Results Linux |
| 81 | + path: coverlet |
| 82 | + |
| 83 | + Windows: |
| 84 | + runs-on: windows-2022 |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v4 |
| 88 | + with: |
| 89 | + fetch-depth: 0 # needed for Nerdbank.GitVersioning |
| 90 | + |
| 91 | + - name: Setup .NET |
| 92 | + uses: actions/setup-dotnet@v4 |
| 93 | + with: |
| 94 | + dotnet-version: 9.0.x |
| 95 | + |
| 96 | + - name: Build Solution |
| 97 | + run: dotnet build Renci.SshNet.sln |
| 98 | + |
| 99 | + - name: Publish AOT Compatibility Test App |
| 100 | + run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/ |
| 101 | + |
| 102 | + - name: Create NuGet Package |
| 103 | + run: dotnet pack |
| 104 | + |
| 105 | + - name: Archive NuGet Package |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: NuGet Package |
| 109 | + path: src/Renci.SshNet/bin/Release/*.*nupkg |
| 110 | + |
| 111 | + - name: Run Unit Tests .NET |
| 112 | + run: | |
| 113 | + dotnet test ` |
| 114 | + -f net8.0 ` |
| 115 | + --no-build ` |
| 116 | + --logger "console;verbosity=normal" ` |
| 117 | + --logger GitHubActions ` |
| 118 | + -p:CollectCoverage=true ` |
| 119 | + -p:CoverletOutputFormat=cobertura ` |
| 120 | + -p:CoverletOutput=../../coverlet/windows_unit_test_net_8_coverage.xml ` |
| 121 | + test/Renci.SshNet.Tests/ |
| 122 | +
|
| 123 | + - name: Run Unit Tests .NET Framework |
| 124 | + run: | |
| 125 | + dotnet test ` |
| 126 | + -f net462 ` |
| 127 | + --no-build ` |
| 128 | + --logger "console;verbosity=normal" ` |
| 129 | + --logger GitHubActions ` |
| 130 | + -p:CollectCoverage=true ` |
| 131 | + -p:CoverletOutputFormat=cobertura ` |
| 132 | + -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` |
| 133 | + test/Renci.SshNet.Tests/ |
| 134 | +
|
| 135 | + - name: Archive Coverlet Results |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + with: |
| 138 | + name: Coverlet Results Windows |
| 139 | + path: coverlet |
| 140 | + |
| 141 | + Publish: |
| 142 | + runs-on: ubuntu-24.04 |
| 143 | + if: github.ref == 'refs/heads/develop' |
| 144 | + permissions: |
| 145 | + packages: write |
| 146 | + needs: |
| 147 | + - Windows |
| 148 | + - Linux |
| 149 | + steps: |
| 150 | + - name: Download NuGet Package |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + name: NuGet Package |
| 154 | + |
| 155 | + - name: Publish to GitHub NuGet Registry |
| 156 | + run: | |
| 157 | + dotnet nuget add source \ |
| 158 | + --username $GITHUB_ACTOR \ |
| 159 | + --password ${{ secrets.GITHUB_TOKEN }} \ |
| 160 | + --store-password-in-clear-text \ |
| 161 | + --name github \ |
| 162 | + "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json" |
| 163 | + dotnet nuget push "*.nupkg" \ |
| 164 | + --source github \ |
| 165 | + --api-key ${{ secrets.GITHUB_TOKEN }} |
0 commit comments