-
Notifications
You must be signed in to change notification settings - Fork 79
121 lines (118 loc) · 8.16 KB
/
Copy pathNightly.yml
File metadata and controls
121 lines (118 loc) · 8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
pull-requests: read
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Update draft on GitHub Releases
id: release_drafter
uses: release-drafter/release-drafter@v7
with:
config-name: file:release-drafter.yml
- uses: actions/setup-dotnet@v6
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 }}
# Coverlet.MTP emits one timestamped OpenCover report per test project below the results directory.
# Note: --coverlet-include-test-assembly is intentionally omitted because it cannot work in MTP mode
# (the test assembly DLL is the controller process and is locked). GitHubActionsTestLogger.dll will
# also be locked. When coverlet hits a locked file, it throws an AggregateException and the entire
# coverage collection is aborted — producing no coverage files at all.
- name: Test and collect coverage
run: dotnet test --no-build -c Release --solution CSharpMath.slnx --results-directory .testcoverage --coverlet --coverlet-output-format opencover --coverlet-exclude '[GitHubActionsTestLogger*]*'
shell: pwsh
- name: Run ReportGenerator on Test Coverage results
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: '.testcoverage/**/*coverage.opencover.*.xml'
targetdir: '.testcoverage/report'
reporttypes: 'Html'
title: 'CSharpMath test coverage results'
tag: ${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }}
- name: Upload CSharpMath test coverage results as CI artifacts
uses: actions/upload-artifact@v7
with:
name: CSharpMath test coverage results
path: .testcoverage/
- name: Upload CSharpMath test coverage results to codecov.io
uses: codecov/codecov-action@v7
with:
files: .testcoverage/**/*coverage.opencover.*.xml
name: CSharpMath test coverage
fail_ci_if_error: false
- name: Upload CSharpMath.Rendering.Tests results as CI artifacts
uses: actions/upload-artifact@v7
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@v7
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