Skip to content

Improve test execution error handling in workflows #151

Improve test execution error handling in workflows

Improve test execution error handling in workflows #151

Workflow file for this run

name: Linux / .NET Tests
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:
jobs:
dotnet-linux:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: Your_strong_password123
ports:
- 1433:1433
options: >-
--health-cmd "bash -c '(/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P Your_strong_password123 -Q \"SELECT 1\" || exit 1)'"
--health-interval 10s --health-timeout 5s --health-retries 10
steps:
- name: Checkout (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0 # need for GitVersion to work properly
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Restore
run: dotnet restore
- name: Patch App.config
run: |
$configPath = 'src/DelegateDecompiler.EntityFramework.Tests/App.config'
[xml]$xml = Get-Content $configPath
$node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'DelegateDecompilerEfTestDb' }
$node.connectionString = 'Data Source=localhost,1433;Initial Catalog=DelegateDecompilerEfTestDb;User ID=sa;Password=Your_strong_password123;Encrypt=False;TrustServerCertificate=True;MultipleActiveResultSets=True'
$xml.Save($configPath)
- name: Build
run: dotnet build --no-restore -c Release DelegateDecompiler.sln
- name: Run tests
run: |
$failed = $false
function Fail { $script:failed = $true }
dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.Tests || Fail
dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.Tests.VB || Fail
dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.EntityFramework.Tests || Fail
dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.EntityFrameworkCore8.Tests || Fail
dotnet test --no-build -c Release -f net9.0 src/DelegateDecompiler.EntityFrameworkCore9.Tests || Fail
dotnet test --no-build -c Release -f net10.0 src/DelegateDecompiler.EntityFrameworkCore10.Tests || Fail
if ($failed) { exit 1 }