Skip to content

Update BuildAndTest.yml #11

Update BuildAndTest.yml

Update BuildAndTest.yml #11

Workflow file for this run

name: Build and Test
# PREREQUISITES FOR PUSH-BACK OF TEST RESULTS
# Please note: test project usually required nuget package JUnitTestLogger
# to be able to provide JUnit compatible test results XML file (required
# for pushing back details on succeeded/failed tests)
#
# NuGet install command:
# - Install-Package JUnitTestLogger
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
# Path to the solution file relative to the root of the project
SOLUTION_FILE_PATH: .
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
#arch: [x86, x86_64, arm]
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: macos-latest
runNetExe: mono
# Configuration type to build
env:
BUILD_CONFIGURATION: CI_CD
# arch: x86_64
- os: ubuntu-latest
# Configuration type to build
env:
BUILD_CONFIGURATION: CI_CD
# arch: x86
#- os: ubuntu-latest
# arch: x86_64
#- os: ubuntu-latest
# arch: arm
- os: windows-latest
# Configuration type to build
env:
BUILD_CONFIGURATION: Debug
# build_configuration_suffix: "_WIN"
# arch: x86
#- os: windows-latest
# arch: x86_64
env:
RESULTS_PATH: TestResults.xml
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore /p:Configuration=${{env.BUILD_CONFIGURATION}}
- name: Build
run: dotnet build --configuration=${{env.BUILD_CONFIGURATION}} --no-restore
#- name: Dir Listing (Win)
# if: startsWith(matrix.os, 'windows')
# run: dir
#- name: Dir Listing (Linux/Mac)
# if: (!startsWith(matrix.os, 'windows'))
# run: ls -la
- name: Run Unit Tests (.NET Framework 4.8/Windows)
if: startsWith(matrix.os, 'windows')
run: dotnet test --no-restore --framework net48 --results-directory test-results-net48 --logger junit --configuration=${{env.BUILD_CONFIGURATION}}
- name: Run Unit Tests (.NET/all platforms)
#if: (!startsWith(matrix.os, 'windows'))
run: dotnet test --no-restore --framework net8.0 --results-directory test-results --logger junit --configuration=${{env.BUILD_CONFIGURATION}}
- name: Dir Listing (Win)
if: startsWith(matrix.os, 'windows')
run: dir
- name: Dir Listing (Linux/Mac) test-results
if: (!startsWith(matrix.os, 'windows'))
run: ls -la
- name: Dir Listing (Win) test-results
if: startsWith(matrix.os, 'windows')
run: dir test-results
- name: Dir Listing (Linux/Mac) test-results
if: (!startsWith(matrix.os, 'windows'))
run: ls -la test-results
- name: Unit Test Results (Win) (.NET Framework 4.8/Windows)
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always() && startsWith(matrix.os, 'windows')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "test-results-net48/TestResults.xml"
check_run_annotations: all tests
comment_title: Unit Test Statistics (${{matrix.os}}) (.NET Framework 4.8/Windows)
check_name: Unit Test Results .NET Framework 4.8/${{matrix.os}}
report_individual_runs: true
- name: Unit Test Results (Linux) (.NET/all platforms)
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() && startsWith(matrix.os, 'ubuntu')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "test-results/TestResults.xml"
check_run_annotations: all tests
comment_title: Unit Test Statistics (${{matrix.os}}) (.NET/all platforms)
check_name: Unit Test Results .NET/${{matrix.os}}
report_individual_runs: true
- name: Unit Test Results (Win/Mac) (.NET/all platforms)
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always() && (!(startsWith(matrix.os, 'ubuntu')))
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "test-results/TestResults.xml"
check_run_annotations: all tests
comment_title: Unit Test Statistics (${{matrix.os}}) (.NET/all platforms)
check_name: Unit Test Results .NET/${{matrix.os}}
report_individual_runs: true
#- name: Publish Unit Test Results
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: NUnit Test Results ${{ matrix.os }}
# path: test-results/TestResults.xml
- name: Publish Unit Test Results (.NET Framework 4.8/Windows)
uses: actions/upload-artifact@v4
if: always() && startsWith(matrix.os, 'windows')
with:
name: NUnit Test Results ${{ matrix.os }} - .NET Framework 4.8/Windows
path: "test-results-net48/TestResults.xml"
- name: Publish Unit Test Results (.NET/all platforms)
uses: actions/upload-artifact@v4
if: always()
with:
name: NUnit Test Results ${{ matrix.os }} - .NET/all platforms
path: "test-results/TestResults.xml"