Skip to content

Format again

Format again #219

Workflow file for this run

name: Build and Test (upload results and nightly builds)
on: [push, pull_request]
jobs:
Windows:
if: (github.event_name == 'pull_request') == github.event.pull_request.head.repo.fork
runs-on: windows-latest
permissions:
contents: write
packages: write
steps:
- name: Update draft on GitHub Releases
id: release_drafter
uses: release-drafter/release-drafter@v6.0.0 # Pinned to v6.0.0 to avoid v6.1.0 bug: https://github.com/release-drafter/release-drafter/issues/1425
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-dotnet@main
with:
dotnet-version: '10.x'
workloads: maui, wasm-tools
# Automatic building by dotnet test is not to be relied on as untested projects like CSharpMath.VectSharp will be omitted.
# For building on Windows specifically, we also need to have this special configuration because Microsoft.Maui.Resizetizer and Uno.Resizetizer
# use different native SkiaSharp DLL versions on build time, causing a conflict if both build in parallel for a solution-wide build.
# An instance of an exception caused by this can be seen at: https://github.com/verybadcat/CSharpMath/actions/runs/21598419979/job/62237307140
### C:\Users\runneradmin\.nuget\packages\uno.resizetizer\1.12.1\build\Uno.Resizetizer.android.targets(11,3): error MSB4018:
### System.TypeInitializationException: The type initializer for 'SkiaSharp.SKObject' threw an exception.
### ---> System.InvalidOperationException: The version of the native libSkiaSharp library (116.0) is incompatible with this version of SkiaSharp. Supported versions of the native libSkiaSharp library are in the range [88.1, 89.0).
# This has been reported before: https://github.com/unoplatform/uno/issues/21344 and the resolution was to build MAUI and Uno apps separately.
# Also note that CSharpMath.Uno.Example must be built on a separate step from CSharpMath.Maui.Example, even two commands on the same step won't work.
- name: Build CSharpMath.Uno.Example
run: dotnet build CSharpMath.Uno.Example # Note: Built in Debug, which won't produce NuGet packages.
- name: Build non-CSharpMath.Uno.Example projects
env:
RELEASE_NOTES: |
${{ format('# {0}', steps.release_drafter.outputs.name) }}
${{ steps.release_drafter.outputs.body }}
run: |
# .NET Core MSBuild cannot parse , and ; correctly so we replace them with MSBuild XML escapes: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743
$env:RELEASE_NOTES = $env:RELEASE_NOTES -replace ',','%2C' -replace ';','%3B'
dotnet build -c Not.Uno.Example -p:PackageReleaseNotes="$env:RELEASE_NOTES" -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }}
- name: Test
run: dotnet test --no-build -c Release --solution CSharpMath.slnx
#### Awaiting coverlet.MTP at https://github.com/coverlet-coverage/coverlet/pull/1788
# # --collect:"XPlat Code Coverage" means collect test coverage with https://github.com/coverlet-coverage/coverlet
# # Coverlet settings come after --: https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md#advanced-options-supported-via-runsettings
# dotnet test --solution CSharpMath.slnx -c Release --collect:"XPlat Code Coverage" --results-directory .testcoverage -p:PackageReleaseNotes="$env:RELEASE_NOTES" -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }} -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.IncludeTestAssembly=true
# shell: pwsh
#- name: Run ReportGenerator on Test Coverage results
# uses: danielpalme/ReportGenerator-GitHub-Action@5
# with:
# reports: '.testcoverage/**/*.*' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
# targetdir: '.testcoverage/report' # REQUIRED # The directory where the generated report should be saved.
# reporttypes: 'Html' # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
# title: 'CSharpMath test coverage results' # Optional title.
# tag: ${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }} # Optional tag or build version.
#- name: Upload CSharpMath test coverage results as CI artifacts
# uses: actions/upload-artifact@v4
# with:
# name: CSharpMath test coverage results
# path: .testcoverage/
#- name: Upload CSharpMath test coverage results to codecov.io
# uses: codecov/codecov-action@v4
# with:
# file: .testcoverage/**/*.xml # optional
# name: CSharpMath test coverage # optional
# fail_ci_if_error: false # optional (default = false)
- name: Upload CSharpMath.Rendering.Tests results as CI artifacts
uses: actions/upload-artifact@v4
if: always() # Run even when a previous step failed: https://stackoverflow.com/a/58859404/5429648
with:
name: CSharpMath.Rendering.Tests results
path: CSharpMath.Rendering.Tests/*/*.png
- name: Upload NuGet packages as CI artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: NuGet packages
path: .nupkgs/*
include-hidden-files: true # This GitHub Action interprets any file or folder starting with . as hidden and omitted by default.
- name: Push NuGet packages to GitHub Packages registry
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
# On Windows, / will not be interpreted as the folder separator in this command and \ must be used here, unlike in Unix environments.
# "dotnet nuget push" with "dotnet nuget add source" to GitHub Packages is unstable for project names with a dot: https://github.com/NuGet/Home/issues/9775#issuecomment-714509211
# so we must specify -k (key) directly in "dotnet nuget push" instead of following the GitHub Packages documentation.
# By using *.* as the file path, this command will fail when .nupkgs folder contains any file that isn't a .nupkg or .snupkg file.
# --skip-duplicate enables re-running this workflow even if some packages from the same commit are already uploaded.
# --no-symbols omits uploading .snupkg files which is not supported by GitHub Packages: https://github.com/orgs/community/discussions/38678
dotnet nuget push '.nupkgs\*.*' -s 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' -k ${{ github.token }} --skip-duplicate --no-symbols
shell: pwsh
- name: Publish CSharpMath.Uno.Example
run: |
git fetch origin gh-pages
if (-not $?) { Exit } # For forks that didn't include the gh-pages branch, don't fail the workflow
git worktree add website/wwwroot gh-pages
Get-ChildItem -Path website/wwwroot/* -Exclude dev,.nojekyll | Remove-Item -Recurse -Force # dev is the output folder of Benchmark.yml and .nojekyll ensures _framework folder is served, keep them
# TODO: why can't this publish use --no-build? For example, see https://github.com/verybadcat/CSharpMath/actions/runs/21600019106/job/62243168945
# Error: C:\Program Files\dotnet\sdk\10.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(262,5): error NETSDK1085:
# The 'NoBuild' property was set to true but the 'Build' target was invoked. [D:\a\CSharpMath\CSharpMath\CSharpMath.Uno\CSharpMath.Uno.csproj::TargetFramework=net10.0-browserwasm]
dotnet publish CSharpMath.Uno.Example -f net10.0-browserwasm -o website # the files we want are in website/wwwroot after this
cd website/wwwroot
# By default, Uno outputs absolute paths for e.g. href and src attributes in HTML starting with / which breaks GitHub Pages hosting. We replace them with ./
Get-ChildItem -Path . -Include *.html,*.js -Recurse | ForEach-Object { [System.IO.File]::WriteAllText($_.FullName, [System.IO.File]::ReadAllText($_.FullName).Replace('="/','="./').Replace(' "/',' "./').Replace('["/','["./')) }
git config user.name ${{ github.actor }}
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add -A # We need to include untracked files too, unlike git commit -a
git commit -m "Update website to commit ${{ github.sha }}"
shell: pwsh
- name: Push CSharpMath.Uno.Example to GitHub Pages
uses: ad-m/github-push-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
branch: gh-pages
directory: website/wwwroot