Refactor variables to use TulipaVariable #1486
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run benchmarks | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write # For writing the comment | |
concurrency: | |
# Skip intermediate builds: always. | |
# Cancel intermediate builds: only if it is a pull request build. | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | |
jobs: | |
benchmark: | |
# Only runs if the PR originates from the repo itself and if the label 'benchmark' is assigned | |
if: contains(github.event.pull_request.labels.*.name, 'benchmark') && github.event.pull_request.head.repo.full_name == github.repository | |
runs-on: ubuntu-latest | |
env: | |
BASE: ${{ github.event.pull_request.base.sha }} | |
HEAD: ${{ github.event.pull_request.head.sha }} | |
steps: | |
- name: Find Comment (before benchmarks) | |
uses: peter-evans/find-comment@v3 | |
id: fcbenchmark-early | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Benchmark Results | |
- name: Early Comment on PR | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.fcbenchmark-early.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
### Benchmark Results | |
Benchmark in progress... | |
edit-mode: replace | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@latest | |
with: | |
version: 1 | |
- uses: julia-actions/cache@v2 | |
- name: Extract Package Name from Project.toml | |
id: extract-package-name | |
run: | | |
PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/') | |
echo "::set-output name=package_name::$PACKAGE_NAME" | |
- name: Build AirspeedVelocity | |
env: | |
JULIA_NUM_THREADS: 2 | |
run: | | |
# Lightweight build step, as sometimes the runner runs out of memory: | |
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add(;url="https://github.com/MilesCranmer/AirspeedVelocity.jl.git")' | |
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")' | |
- name: Add ~/.julia/bin to PATH | |
run: | | |
echo "$HOME/.julia/bin" >> $GITHUB_PATH | |
- name: Run benchmarks | |
run: | | |
echo $PATH | |
ls -l ~/.julia/bin | |
mkdir results | |
benchpkg ${{ steps.extract-package-name.outputs.package_name }} \ | |
--rev="$BASE,$HEAD" \ | |
--url=${{ github.event.repository.clone_url }} \ | |
--bench-on="$HEAD" \ | |
--output-dir=results/ | |
- name: Create plots from benchmarks | |
run: | | |
mkdir -p plots | |
benchpkgplot ${{ steps.extract-package-name.outputs.package_name }} \ | |
--rev="$BASE,$HEAD" \ | |
--npart=10 --format=png --input-dir=results/ --output-dir=plots/ | |
- name: Upload plot as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: plots | |
path: plots | |
- name: Create markdown table from benchmarks | |
run: | | |
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} \ | |
--rev="$BASE,$HEAD" \ | |
--mode=time,memory \ | |
--input-dir=results/ --ratio > table.md | |
echo '### Benchmark Results' > body.md | |
echo '' >> body.md | |
echo '' >> body.md | |
cat table.md >> body.md | |
echo '' >> body.md | |
echo '' >> body.md | |
echo '### Benchmark Plots' >> body.md | |
echo 'A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.' >> body.md | |
echo 'Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).' >> body.md | |
- name: Find Comment | |
uses: peter-evans/find-comment@v3 | |
id: fcbenchmark | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Benchmark Results | |
- name: Comment on PR | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.fcbenchmark.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: body.md | |
edit-mode: replace |