Skip to content

Merge remote-tracking branch 'origin/feature/cross_apply_operator' in… #38

Merge remote-tracking branch 'origin/feature/cross_apply_operator' in…

Merge remote-tracking branch 'origin/feature/cross_apply_operator' in… #38

Workflow file for this run

name: CI
on:
push:
branches:
- '**'
paths-ignore:
- 'badges/**'
jobs:
build:
strategy:
matrix:
runs-on: [windows-latest]
runs-on: ${{ matrix.runs-on }}
name: Running tests on ${{ matrix.runs-on }}.
steps:
- uses: actions/checkout@v4
with:
dotnet-version: '8.0.x'
ref: ${{ github.ref }}
- name: Install trx2junit
run: dotnet tool install -g trx2junit
- name: Build & Run tests
run: dotnet test --configuration Release --logger "trx;LogFileName=test-results.trx"
- name: Convert TRX to JUnit
if: "github.ref != 'refs/heads/master'"
run: |
$trxFiles = Get-ChildItem -Recurse -Filter test-results.trx
$trx2junitPath = (Get-Command trx2junit).Source
foreach ($trxFile in $trxFiles) {
& $trx2junitPath $trxFile.FullName --output ($trxFile.DirectoryName + "\test-results.xml")
}
- name: Merge JUnit results
if: "github.ref != 'refs/heads/master'"
run: |
$xmlFiles = Get-ChildItem -Recurse -File -Filter test-results.xml
$mergedXml = [xml]"<testsuites></testsuites>"
foreach ($xmlFile in $xmlFiles) {
$content = [xml](Get-Content $xmlFile.FullName)
foreach ($testsuite in $content.testsuites.testsuite) {
$importedNode = $mergedXml.ImportNode($testsuite, $true)
$mergedXml.DocumentElement.AppendChild($importedNode) > $null
}
}
$mergedXml.Save("merged-test-results.xml")
- name: Parse test results
if: "github.ref != 'refs/heads/master'"
shell: pwsh
id: parse
run: |
[xml]$testResults = Get-Content merged-test-results.xml
$total = ($testResults.testsuites.testsuite | Measure-Object -Property tests -Sum).Sum
$failures = ($testResults.testsuites.testsuite | Measure-Object -Property failures -Sum).Sum
$skipped = ($testResults.testsuites.testsuite | Measure-Object -Property skipped -Sum).Sum
$passed = $total - $failures - $skipped
"TOTAL=$total" >> $env:GITHUB_ENV
"PASSED=$passed" >> $env:GITHUB_ENV
"FAILURES=$failures" >> $env:GITHUB_ENV
"SKIPPED=$skipped" >> $env:GITHUB_ENV
- name: Create badge
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref != 'refs/heads/master'"
shell: bash
run: |
PASSED=${PASSED:-0}
FAILED=${FAILED:-0}
SKIPPED=${SKIPPED:-0}
TOTAL=$((PASSED + FAILED + SKIPPED))
if [ "$FAILED" -gt 0 ]; then
COLOR="red"
elif [ "$SKIPPED" -gt 0 ]; then
COLOR="yellow"
else
COLOR="green"
fi
# Generate the badge URL
BADGE_URL="https://img.shields.io/badge/tests-${PASSED}%2F${TOTAL}%20%28${FAILED}%20failed%2C%20${SKIPPED}%20skipped%29-${COLOR}.svg"
# Fetch the badge
curl -o tests-badge.svg "${BADGE_URL}"
- name: Commit badge
shell: bash
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref != 'refs/heads/master'"
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
mkdir -p badges
rm -f badges/tests-badge.svg
mv tests-badge.svg badges/tests-badge.svg
git add badges/tests-badge.svg
if ! git diff --cached --quiet; then
git commit -m "Update test results badge [skip ci]"
git push --force
else
echo "No changes to commit"
fi