From 0e550218065be9c3f8468d826725db122d7f8dd4 Mon Sep 17 00:00:00 2001 From: Marton Balassa <7115274+BalassaMarton@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:38:50 +0100 Subject: [PATCH] Improved .NET build scripts so that they don't exit on the first error Added environment variable to enable ANSI colors in build output --- .github/workflows/continuous-integration.yml | 52 +++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b03e18846..6eed801ea 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -18,6 +18,7 @@ jobs: build: env: COMPOSEUI_SKIP_DOWNLOAD: 'true' + DOTNET_CONSOLE_ANSI_COLOR: 'true' runs-on: windows-latest strategy: matrix: @@ -25,11 +26,13 @@ jobs: node-version: [ '18.x' ] steps: - uses: actions/checkout@v3 + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} COMPOSEUI_SKIP_DOWNLOAD: ${{env.COMPOSEUI_SKIP_DOWNLOAD}} + - name: Install NPM dependencies run: npm ci @@ -43,14 +46,51 @@ jobs: uses: actions/setup-dotnet@v2 with: dotnet-version: ${{ matrix.dotnet-version }} - - name: Install Nuget dependencies - run: Get-ChildItem -Recurse -Include *.sln | ForEach-Object {dotnet restore $_} - - name: Build .Net - run: Get-ChildItem -Recurse -Include *.sln | ForEach-Object {dotnet build $_ --configuration Release --no-restore; if ($LASTEXITCODE -ne 0 ) {throw "Build for $_ FAILED"; }} + - name: Install NuGet dependencies + run: | + $failedSolutions = @() + + Get-ChildItem -Recurse -Include *.sln ` + | ForEach-Object { + dotnet restore $_; + if ($LASTEXITCODE -ne 0) {$failedSolutions += Split-Path $_ -leaf; } + } + + if ($failedSolutions.count -gt 0) { + throw "Restore FAILED for solutions $failedSolutions" + } + + + - name: Build .NET + run: | + $failedSolutions = @() + + Get-ChildItem -Recurse -Include *.sln ` + | ForEach-Object { + dotnet build $_ --configuration Release --no-restore; + if ($LASTEXITCODE -ne 0) {$failedSolutions += Split-Path $_ -leaf; } + } + + if ($failedSolutions.count -gt 0) { + throw "Build FAILED for solutions $failedSolutions" + } + + + - name: Test .NET + run: | + $failedSolutions = @() + + Get-ChildItem -Recurse -Include *.sln ` + | ForEach-Object { + dotnet test $_ --configuration Release --no-build; + if ($LASTEXITCODE -ne 0) { $failedSolutions += Split-Path $_ -leaf; } + } + + if ($failedSolutions.count -gt 0) { + throw "Test FAILED for solutions $failedSolutions" + } - - name: Test .Net - run: Get-ChildItem -Recurse -Include *.sln | ForEach-Object {dotnet test $_ --configuration Release --no-restore --verbosity normal --collect:"XPlat Code Coverage"; if ($LASTEXITCODE -ne 0 ) {throw "Test for $_ FAILED"; }} - name: Codecov uses: codecov/codecov-action@v3.0.0