Skip to content

Commit a8bb4ff

Browse files
Copilotpetesramek
andauthored
refactor: move benchmark run from pull-request to release workflow, consume artifacts in publish-docs
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/a0437570-56e0-443f-8b45-75faef614455 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent deafa00 commit a8bb4ff

3 files changed

Lines changed: 46 additions & 58 deletions

File tree

.github/workflows/publish-documentation.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,17 @@ jobs:
9696
run: |
9797
cp -r api-reference/guide api-reference/${{ env.friendly-version }}/guide
9898
99-
- name: 'Run benchmarks for v${{ env.friendly-version }}'
100-
shell: bash
101-
env:
102-
BENCHMARKS_ARTIFACTS: /tmp/benchmarks
103-
run: |
104-
dotnet run \
105-
--project benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj \
106-
--configuration Release \
107-
/p:Platform="Any CPU" \
108-
--framework ${{ vars.DEFAULT_BUILD_FRAMEWORK || 'net10.0' }} \
109-
-- --filter ${{ vars.BENCHMARKDOTNET_FILTER || '*' }} \
110-
--exporters GitHub \
111-
--memory \
112-
--iterationTime 100 \
113-
--join \
114-
--artifacts $BENCHMARKS_ARTIFACTS/
99+
- name: 'Download benchmark results'
100+
uses: actions/download-artifact@v8
101+
with:
102+
pattern: benchmark-*
103+
path: /tmp/benchmarks
104+
merge-multiple: true
115105

116106
- name: 'Inject benchmark results into guide for v${{ env.friendly-version }}'
117107
shell: bash
118-
env:
119-
BENCHMARKS_ARTIFACTS: /tmp/benchmarks
120108
run: |
121-
find "$BENCHMARKS_ARTIFACTS" -name "*-report-github.md" | sort | xargs -r cat > /tmp/benchmark_results.md
109+
find /tmp/benchmarks -name "*-report-github.md" | sort | xargs -r cat > /tmp/benchmark_results.md
122110
awk '/{benchmarks_section}/{while((getline line < "/tmp/benchmark_results.md") > 0) print line; close("/tmp/benchmark_results.md"); next} {print}' \
123111
"api-reference/${{ env.friendly-version }}/guide/benchmarks.md" > /tmp/benchmarks.md
124112
mv /tmp/benchmarks.md "api-reference/${{ env.friendly-version }}/guide/benchmarks.md"

.github/workflows/pull-request.yml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ permissions:
1818
id-token: write
1919
contents: write
2020

21-
concurrency:
22-
group: pull-request-${{ github.head_ref || github.ref }}
21+
concurrency:
22+
group: pull-request-${{ github.head_ref || github.ref }}
2323
cancel-in-progress: true
2424

2525
env:
@@ -189,7 +189,7 @@ jobs:
189189
- name: Pack with .NET
190190
run: |
191191
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.release-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
192-
192+
193193
- name: Upload Package
194194
uses: actions/upload-artifact@v7
195195
with:
@@ -239,38 +239,3 @@ jobs:
239239

240240
- name: 'Check for vulnerable packages'
241241
run: dotnet list src/PolylineAlgorithm/PolylineAlgorithm.csproj package --vulnerable --include-transitive
242-
243-
benchmark:
244-
if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }}
245-
name: Benchmark with .NET CLI on ${{ matrix.os }}
246-
needs: [workflow-variables, build]
247-
strategy:
248-
matrix:
249-
os: [ubuntu-latest, windows-latest, macos-latest]
250-
runs-on: ${{ matrix.os }}
251-
steps:
252-
- name: 'Checkout ${{ github.head_ref || github.ref }}'
253-
uses: actions/checkout@v6
254-
- name: Install .NET SDK
255-
uses: actions/setup-dotnet@v5
256-
with:
257-
dotnet-version: |
258-
8.x
259-
10.x
260-
- name: Download Build
261-
uses: actions/download-artifact@v8
262-
with:
263-
name: build
264-
- name: Benchmark
265-
working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
266-
run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --join
267-
- name: Upload Benchmark Results
268-
uses: actions/upload-artifact@v7
269-
with:
270-
name: benchmark-${{ matrix.os }}
271-
path: |
272-
${{ runner.temp }}/benchmarks/**/*-report-github.md
273-
- name: Write Benchmark Summary
274-
shell: bash
275-
run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY
276-
working-directory: ${{ runner.temp }}/benchmarks/

.github/workflows/release.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,44 @@ jobs:
290290
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.nupkg
291291
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.snupkg
292292
293+
benchmark:
294+
name: Benchmark with .NET CLI on ${{ matrix.os }}
295+
needs: [workflow-variables, build, validate-release]
296+
if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }}
297+
strategy:
298+
matrix:
299+
os: [ubuntu-latest, windows-latest, macos-latest]
300+
runs-on: ${{ matrix.os }}
301+
steps:
302+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
303+
uses: actions/checkout@v6
304+
- name: Install .NET SDK
305+
uses: actions/setup-dotnet@v5
306+
with:
307+
dotnet-version: |
308+
8.x
309+
10.x
310+
- name: Download Build
311+
uses: actions/download-artifact@v8
312+
with:
313+
name: build
314+
- name: Benchmark
315+
working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
316+
run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --join
317+
- name: Upload Benchmark Results
318+
uses: actions/upload-artifact@v7
319+
with:
320+
name: benchmark-${{ matrix.os }}
321+
path: |
322+
${{ runner.temp }}/benchmarks/**/*-report-github.md
323+
- name: Write Benchmark Summary
324+
shell: bash
325+
run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY
326+
working-directory: ${{ runner.temp }}/benchmarks/
327+
293328
publish-documentation:
294329
name: 'Publish documentation'
295-
needs: [pack, validate-release, workflow-variables]
330+
needs: [pack, benchmark, validate-release, workflow-variables]
296331
if: ${{ needs.workflow-variables.outputs.is-release == 'true' }}
297332
uses: ./.github/workflows/publish-documentation.yml
298333
permissions:

0 commit comments

Comments
 (0)