|
| 1 | +name: .NET Framework Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + dotnet-framework: |
| 11 | + name: Tests |
| 12 | + runs-on: windows-latest |
| 13 | + defaults: |
| 14 | + run: |
| 15 | + shell: pwsh |
| 16 | + env: |
| 17 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 18 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Install NUnit Console |
| 22 | + run: choco install nunit-console-runner --version=3.17.0 -y |
| 23 | + |
| 24 | + - name: Install LocalDB |
| 25 | + run: choco install sqllocaldb -y --no-progress |
| 26 | + |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 # need for GitVersion to work properly |
| 31 | + |
| 32 | + - name: Setup .NET |
| 33 | + uses: actions/setup-dotnet@v4 |
| 34 | + with: |
| 35 | + global-json-file: global.json |
| 36 | + |
| 37 | + - name: Add MSBuild to PATH |
| 38 | + uses: microsoft/setup-msbuild@v2 |
| 39 | + |
| 40 | + - name: Patch App.config for LocalDB |
| 41 | + run: | |
| 42 | + $cfg = 'src/DelegateDecompiler.EntityFramework.Tests/App.config' |
| 43 | + [xml]$xml = Get-Content $cfg |
| 44 | + $cs = $xml.configuration.connectionStrings.add | Where-Object name -eq 'DelegateDecompilerEfTestDb' |
| 45 | + $cs.connectionString = 'Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=DelegateDecompilerEfTestDb;MultipleActiveResultSets=True;Integrated Security=True;TrustServerCertificate=True' |
| 46 | + $xml.Save($cfg) |
| 47 | +
|
| 48 | + - name: Restore |
| 49 | + run: dotnet restore |
| 50 | + |
| 51 | + - name: Build |
| 52 | + run: dotnet build --no-restore -c Release DelegateDecompiler.sln |
| 53 | + |
| 54 | + - name: Locate NUnit Console |
| 55 | + run: | |
| 56 | + $exe = Get-ChildItem -Path "$Env:ChocolateyInstall\lib" -Recurse -Filter nunit3-console.exe | Select-Object -First 1 |
| 57 | + if (-not $exe) { Write-Error 'nunit3-console.exe not found after installation.'; exit 1 } |
| 58 | + Write-Host "Found NUnit console at $($exe.FullName)" |
| 59 | + "NUNIT_CONSOLE=$($exe.FullName)" | Out-File -FilePath $Env:GITHUB_ENV -Append |
| 60 | +
|
| 61 | + - name: Test |
| 62 | + run: | |
| 63 | + $ErrorActionPreference = 'Stop' |
| 64 | + $dlls = @( |
| 65 | + 'src/DelegateDecompiler.Tests/bin/Release/net40/DelegateDecompiler.Tests.dll', |
| 66 | + 'src/DelegateDecompiler.Tests.VB/bin/Release/net40/DelegateDecompiler.Tests.VB.dll', |
| 67 | + 'src/DelegateDecompiler.Tests/bin/Release/net45/DelegateDecompiler.Tests.dll', |
| 68 | + 'src/DelegateDecompiler.Tests.VB/bin/Release/net45/DelegateDecompiler.Tests.VB.dll', |
| 69 | + 'src/DelegateDecompiler.EntityFramework.Tests/bin/Release/net45/DelegateDecompiler.EntityFramework.Tests.dll' |
| 70 | + ) |
| 71 | + if (-not $Env:NUNIT_CONSOLE) { Write-Error 'NUNIT_CONSOLE env var not set.'; exit 1 } |
| 72 | + $resultArg = '--result=DelegateDecompiler.framework.tests.xml' |
| 73 | + & $Env:NUNIT_CONSOLE @dlls $resultArg |
| 74 | + shell: pwsh |
| 75 | + |
| 76 | + - name: Upload NUnit results |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: nunit-framework |
| 81 | + path: DelegateDecompiler.framework.tests.xml |
0 commit comments