Skip to content

Fix duplicate copy

Fix duplicate copy #2

name: Generate Windows Benchmark Baseline
on:
push:
branches:
- python-upgrade
workflow_dispatch:
inputs:
python_version:
description: Python version to benchmark
required: false
default: "3.14"
open_pr:
description: Open a pull request with the generated benchmark baseline
required: false
type: boolean
default: false
permissions:
contents: write
pull-requests: write
jobs:
windows_benchmark_baseline:
runs-on: windows-latest
env:
PYTHON_VERSION: ${{ github.event.inputs.python_version || '3.14' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
python -m pip install -r requirements_dev.txt
- name: Generate benchmark baseline
shell: pwsh
run: |
pytest -c "." --benchmark-storage=.benchmarks/ --benchmark-save=benchmark tests/benchmarks.py
$benchDir = ".benchmarks/Windows-CPython-${{ env.PYTHON_VERSION }}-64bit"
if (-not (Test-Path $benchDir)) {
throw "Benchmark directory not found: $benchDir"
}
$latest = Get-ChildItem -Path $benchDir -Filter "*_benchmark.json" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($null -eq $latest) {
throw "No benchmark JSON files found in $benchDir"
}
$target = Join-Path $benchDir "0001_benchmark.json"
$latestPath = [System.IO.Path]::GetFullPath($latest.FullName)
$targetPath = [System.IO.Path]::GetFullPath($target)
if ($latestPath -ne $targetPath) {
Copy-Item -Path $latest.FullName -Destination $target -Force
}
- name: Upload benchmark baseline artifact
uses: actions/upload-artifact@v4
with:
name: windows-cpython-${{ env.PYTHON_VERSION }}-benchmark-baseline
path: .benchmarks/Windows-CPython-${{ env.PYTHON_VERSION }}-64bit/0001_benchmark.json
- name: Create pull request with baseline
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.open_pr == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
commit-message: Add Windows benchmark baseline for Python ${{ env.PYTHON_VERSION }}
title: Add Windows benchmark baseline for Python ${{ env.PYTHON_VERSION }}
body: Generated by workflow_dispatch in windows-benchmark-baseline.yml.
branch: chore/windows-benchmark-baseline-py${{ env.PYTHON_VERSION }}
add-paths: |
.benchmarks/Windows-CPython-${{ env.PYTHON_VERSION }}-64bit/0001_benchmark.json