Skip to content

bm.yml

bm.yml #9

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: 'Benchmarks'
# Controls when the workflow will run
on:
# Triggers the workflow on push or pr to master
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Manual Run'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "main-job"
benchmark:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Log run info
- name: Log run info
run: |
echo 🎉 The job was automatically triggered by a ${{ github.event_name }} event.
echo 🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!
echo Current directory is: ${{ github.workspace }}
# Print the reason for the manual run if applicable
- name: Print Manual Run Reason
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out code in repository
uses: actions/checkout@v4
# Install the .NET Core
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
# Restore/Build/Run
- name: Restore, Build, and Run Benchmarks
run: |
dotnet run --project Benchmarks/Benchmarks.csproj --configuration Release
# Add workflow summary
- name: Add benchmark results to workflow summary
if: success()
run: |
echo "## 🚀 Benchmark Results" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
for f in Benchmarks/BenchmarkDotNet.Artifacts/results/*-report-full.json; do
[ -e "$f" ] || continue # skip if no matching file
cat "$f" >> $GITHUB_STEP_SUMMARY
done
echo '```' >> $GITHUB_STEP_SUMMARY
# Upload benchmark results as artifact
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: Benchmarks/BenchmarkDotNet.Artifacts/results/*.json