Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Housekeeping] Add Benchmarks to GitHub Actions #2452

Merged
merged 19 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Benchmarks

on:
push:
branches:
- main
tags:
- '*'
paths-ignore:
- README.md
pull_request:
branches:
- '*'

env:
LATEST_NET_VERSION: '9.0.x'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'

jobs:
run_benchmarks:
name: Run Benchmarks
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-15]

steps:
- name: Checkout code
uses: actions/checkout@main

- uses: maxim-lobanov/setup-xcode@v1
if: runner.os == 'macOS'
with:
xcode-version: latest-stable

- name: Install Latest Version of .NET, v${{ env.LATEST_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.LATEST_NET_VERSION }}
dotnet-quality: 'ga'

- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
dotnet workload update

- name: Install Tizen Workload
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
shell: pwsh

- name: Display dotnet info
run: dotnet --info

- name: Run Benchmarks
run: dotnet run --project ${{ env.PathToCommunityToolkitAnalyzersBenchmarkCsproj }} -c Release -- -a ${{ runner.temp }}

- name: Publish Benchmarks
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: Benchmarks
path: |
${{ runner.temp }}/**/*.md
80 changes: 65 additions & 15 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: .NET
name: Build

on:
push:
Expand Down Expand Up @@ -42,7 +42,7 @@ env:
PathToCommunityToolkitCameraAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj'
DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/8.0.6.json'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
CommunityToolkitSampleApp_Xcode_Version: '16.2'
CommunityToolkitLibrary_Xcode_Version: '16.2'

Expand All @@ -60,15 +60,20 @@ jobs:
- name: Set Xcode version
if: runner.os == 'macOS'
run: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitSampleApp_Xcode_Version }}.app/Contents/Developer

- name: Install Latest .NET SDK
uses: actions/setup-dotnet@v3
- name: Install Latest .NET SDK, v${{ env.LATEST_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.LATEST_NET_VERSION }}
dotnet-quality: 'ga'

- name: Install .NET MAUI Workload
run: dotnet workload install maui
run: |
dotnet workload install maui
dotnet workload update

- name: Install Tizen Workload
run: |
Expand All @@ -85,6 +90,8 @@ jobs:
build_library:
name: Build Library
runs-on: ${{ matrix.os }}
env:
VSTEST_TESTHOST_SHUTDOWN_TIMEOUT: 1100 # Fixes "The active test run was aborted. Reason: Test host process crashed"
strategy:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have this issue on new pipeline?
I also curious if this variable is specific to Azure Pipelines or exists in Github.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha - I wish I knew the answer to that!

I don't have direct evidence that supports whether we still need it in GitHub Actions or not, but I'd kinda rather keep it just in case since it doesn't introduce any adverse effects to the pipeline and it may save us headaches in the future.

matrix:
os: [windows-latest, macos-15]
Expand Down Expand Up @@ -119,15 +126,20 @@ jobs:
- name: Set Xcode version
if: runner.os == 'macOS'
run: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitLibrary_Xcode_Version }}.app/Contents/Developer

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
- name: Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'

- name: Install .NET MAUI Workload
run: dotnet workload install maui --skip-sign-check --source https://api.nuget.org/v3/index.json
run: |
dotnet workload install maui
dotnet workload update

- name: Install Tizen Workload
run: |
Expand All @@ -138,10 +150,46 @@ jobs:
- name: Display dotnet info
run: dotnet --info

- name: Build CommunityToolkit.Maui
run: dotnet build -c Release ${{ env.PathToLibrarySolution }}
- name: 'Build CommunityToolkit.Maui.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitAnalyzersCsproj }} -c Release
TheCodeTraveler marked this conversation as resolved.
Show resolved Hide resolved

- name: 'Build CommunityToolkit.Maui.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitAnalyzersCodeFixCsproj }} -c Release

- name: 'Build CommunityToolkit.Maui.Camera.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitCameraAnalyzersCsproj }} -c Release

- name: 'Build CommunityToolkit.Maui.Camera.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitCameraAnalyzersCodeFixCsproj }} -c Release

- name: 'Build CommunityToolkit.Maui.MediaElement.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementAnalyzersCsproj }} -c Release

- name: 'Build CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj }} -c Release

- name: Run CommunityToolkit.Maui.UnitTests
- name: 'Build CommunityToolkit.Maui.SourceGenerators'
run: dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsCsproj }} -c Release

- name: 'Build CommunityToolkit.SourceGenerators.Internal'
run: dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsInternalCsproj }} -c Release

- name: 'Build CommunityToolkit.Maui.Camera'
run: dotnet build ${{ env.PathToCommunityToolkitCameraCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionCamera }} -p:Version=${{ env.NugetPackageVersion }}

- name: 'Build CommunityToolkit.Maui.MediaElement'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionMediaElement }} -p:Version=${{ env.NugetPackageVersion }}

- name: 'Build CommunityToolkit.Maui.Maps'
run: dotnet build ${{ env.PathToCommunityToolkitMapsCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionMaps }} -p:Version=${{ env.NugetPackageVersion }}

- name: 'Build CommunityToolkit.Maui.Core'
run: dotnet build ${{ env.PathToCommunityToolkitCoreCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}

- name: 'Build CommunityToolkit.Maui'
run: dotnet build ${{ env.PathToLibrarySolution }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a library, not solution

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the Library SLN on purpose to help ensure the pipeline always builds all of the projects.

In the future, a PR may add a new library but forget to update the pipeline. This ensures that the pipeline will still compile the new code until we remember to add it as a separate step.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, in that case I still don't see the benefit of building each project individually to build the whole solution later.
I have no strong objections merging the PR, but I still voting keeping it as simple as possible (less code). Once we get the issue with build investigation we can back to the changes.

- name: Run All Unit Tests
run: dotnet test -c Release ${{ env.PathToLibrarySolution }} --settings ".runsettings" --collect "XPlat code coverage" --logger trx --results-directory ${{ runner.temp }}

- name: Publish Test Results
Expand Down Expand Up @@ -198,10 +246,11 @@ jobs:
id-token: write # Required for requesting the JWT

steps:
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
- name: Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'

- name: Download NuGet List
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -251,9 +300,10 @@ jobs:

steps:
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'

- name: Download signed packages for ${{ matrix.platform }}
uses: actions/download-artifact@v4
Expand All @@ -267,4 +317,4 @@ jobs:
**/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
--skip-duplicate
--skip-duplicate
Loading