chore: Update dotnetcore.yml workflow to use dotnet version 8.0.x and… #245
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: [push] | |
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 | |
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 | |
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 | |
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 | |
echo "total=$total" >> $GITHUB_ENV | |
echo "passed=$passed" >> $GITHUB_ENV | |
echo "failed=$failures" >> $GITHUB_ENV | |
echo "skipped=$skipped" >> $GITHUB_ENV | |
- name: Create badge | |
run: | | |
curl -o tests-badge.svg "https://img.shields.io/badge/tests-${{ env.total }}%20%2F%20${{ env.passed }}-green" | |
- name: Upload badge | |
uses: actions/upload-artifact@v2 | |
with: | |
name: tests-badge | |
path: tests-badge.svg | |
- name: Publish | |
if: github.ref == 'refs/heads/master' | |
run: | | |
$scriptLocationDirectory=(Get-Location).ToString() | |
$scriptLocationFilePath=[System.IO.Path]::Combine($scriptLocationDirectory, "Publish.Nuget.ps1") | |
$nugetExecutable=[System.IO.Path]::Combine($scriptLocationDirectory, "nuget", "nuget.exe") | |
$projects = @('Musoq.Converter', 'Musoq.Evaluator', 'Musoq.Parser', 'Musoq.Plugins', 'Musoq.Schema') | |
foreach ($project in $projects) { | |
pushd | |
cd "./$project/bin/Release" | |
Invoke-Expression "$scriptLocationFilePath $nugetExecutable $project '${{ secrets.nuget_musoq_key }}'" | |
popd | |
} |