Skip to content
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
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ indent_size = 2

# PowerShell scripts inherit LF + UTF-8 (no BOM) + 4-space indent from
# the global [*] section above — no per-language override is needed.
# LF + no-BOM is required for the `#!/usr/bin/env pwsh` shebang at the
# top of every script in scripts/ to work on Linux/macOS — CR breaks
# the kernel's exec lookup, and a leading BOM prevents shebang
# LF + no-BOM is required for the `#!/usr/bin/env pwsh` shebang (where
# present) on scripts under scripts/ to work on Linux/macOS — CR
# breaks the kernel's exec lookup, and a leading BOM prevents shebang
# recognition entirely.

# C# files
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Benchmarks

# Runs BenchmarkDotNet after a merge to main, then publishes the results to
# the gh-pages branch under /dev/bench/ where benchmark-action/github-action-benchmark
# renders an interactive line chart.
#
# This workflow is decoupled from PR validation and release: it does NOT gate
# merging or publishing — it just adds one data point per qualifying push.

on:
push:
branches: [main]
paths:
- 'src/**'
- 'benchmarks/**'
- '.github/workflows/benchmarks.yaml'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
benchmark:
name: Run BenchmarkDotNet & publish chart
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x

- name: Restore
run: dotnet restore benchmarks/Wolfgang.TryPattern.Benchmarks/Wolfgang.TryPattern.Benchmarks.csproj

- name: Build (Release)
run: dotnet build -c Release --no-restore benchmarks/Wolfgang.TryPattern.Benchmarks/Wolfgang.TryPattern.Benchmarks.csproj

- name: Run benchmarks
working-directory: benchmarks/Wolfgang.TryPattern.Benchmarks
run: dotnet run -c Release --no-build -- --filter "*" --job short --memory --exporters json

- name: Merge per-class BDN reports
id: locate
working-directory: benchmarks/Wolfgang.TryPattern.Benchmarks
run: |
shopt -s nullglob
reports=(BenchmarkDotNet.Artifacts/results/*-report-full-compressed.json)
if [ ${#reports[@]} -eq 0 ]; then
echo "::error::No BenchmarkDotNet JSON report found"
exit 1
fi
echo "Merging ${#reports[@]} report(s):"
printf ' %s\n' "${reports[@]}"
jq -s '{
Title: "BenchmarkDotNet combined report",
HostEnvironmentInfo: .[0].HostEnvironmentInfo,
Benchmarks: [.[].Benchmarks[]]
}' "${reports[@]}" > benchmarks-result.json
echo "report=benchmarks/Wolfgang.TryPattern.Benchmarks/benchmarks-result.json" >> "$GITHUB_OUTPUT"

- name: Publish chart to gh-pages
uses: benchmark-action/github-action-benchmark@52576c92bccf6ac60c8223ec7eb2565637cae9ba # v1.22.1
with:
name: BenchmarkDotNet
tool: 'benchmarkdotnet'
output-file-path: ${{ steps.locate.outputs.report }}
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
alert-threshold: '200%'
fail-on-alert: false
35 changes: 33 additions & 2 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,47 @@ jobs:

- name: Initialize CodeQL
if: steps.check-csharp.outputs.has-csharp == 'true'
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# security-extended adds the broader security query pack on top of the
# default queries (more rules, slightly longer scans).
queries: security-extended

- name: Setup .NET
if: steps.check-csharp.outputs.has-csharp == 'true'
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'

- name: Restore .NET workloads
if: steps.check-csharp.outputs.has-csharp == 'true'
shell: pwsh
run: |
# Skip entirely if no csproj declares a workload-bearing TFM (android/ios/
# maccatalyst/maui/tvos/tizen/browser) — netX.Y-windows TFMs use
# SDK-bundled projection assemblies, not the workload installer, so
# they're intentionally excluded. Saves ~5-15s on pure-library
# repos and removes a network-dependent failure mode.
$hasWorkloadTfm = @(Get-ChildItem -Recurse -Filter *.csproj |
Select-String -Pattern 'net\d+\.\d+-(android|ios|maccatalyst|maui|tvos|tizen|browser)' -List).Count -gt 0
if (-not $hasWorkloadTfm) {
Write-Host "No workload-bearing TFMs — skipping dotnet workload restore"
exit 0
}
$solution = Get-ChildItem -Path . -Recurse -Depth 2 -Include "*.sln", "*.slnx" | Select-Object -First 1
if ($solution) {
Write-Host "Restoring workloads for $($solution.FullName)"
dotnet workload restore "$($solution.FullName)"
} else {
Write-Host "No solution found; restoring workloads for all projects"
dotnet workload restore
}
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet workload restore failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}

- name: Build for CodeQL Analysis
id: build
if: steps.check-csharp.outputs.has-csharp == 'true'
Expand Down Expand Up @@ -128,7 +159,7 @@ jobs:
- name: Perform CodeQL Analysis
id: perform-codeql-analysis
if: steps.check-csharp.outputs.has-csharp == 'true'
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"

Expand Down
Loading
Loading