Skip to content

Publish CI test results into PR discussions, harden artifact download, and add PR preview publishing #283

Publish CI test results into PR discussions, harden artifact download, and add PR preview publishing

Publish CI test results into PR discussions, harden artifact download, and add PR preview publishing #283

Workflow file for this run

name: Build and Test
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
permissions: {}
jobs:
event_file:
if: github.event_name == 'pull_request'
name: Publish event file
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Upload event file
uses: actions/upload-artifact@v4
with:
name: EventFile
path: ${{ github.event_path }}
build:
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest, macOS-latest]
dotnet: [10.0.301]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Add version to global.json
run: |
$version = "${{ matrix.dotnet }}"
$globalJsonPath = "global.json"
$globalJson = Get-Content -Raw -Path $globalJsonPath | ConvertFrom-Json
if ($null -eq $globalJson.sdk.version) {
$globalJson.sdk | Add-Member -Type NoteProperty -Name version -Value $version
} else {
$globalJson.sdk.version = $version
}
$globalJson | ConvertTo-Json -Depth 10 | Set-Content -Path $globalJsonPath
shell: pwsh
- name: Install local tools
run: dotnet tool restore
- name: Build and run integration tests
run: dotnet run --project build/Build.fsproj --launch-profile BuildAndTest
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: test-results
publish_test_results_preview:
if: ${{ always() && github.event_name == 'pull_request' && github.event.pull_request.number == 570 }}
name: Publish test results preview
runs-on: ubuntu-latest
needs:
- build
permissions:
actions: read
checks: write
pull-requests: write
steps:
- name: Download test results
uses: actions/download-artifact@v5
with:
pattern: test-results-*
path: test-results
merge-multiple: true
- name: Publish test results
if: ${{ hashFiles('test-results/**/*.trx') != '' }}
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: "Test Results (Preview)"
comment_mode: always
commit: ${{ github.event.pull_request.head.sha }}
files: "test-results/**/*.trx"