Skip to content

chore: update ci workflow #47

chore: update ci workflow

chore: update ci workflow #47

name: Benchmark PR vs main
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
benchmark-delta:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Homebrew Mac
if: ${{ runner.os == 'Macos' }}
run: |
echo "/opt/homebrew/bin:/usr/local/bin" >> $GITHUB_PATH
brew install jemalloc
- name: Ubuntu deps
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install -y libjemalloc-dev
- name: Git URL token override and misc
run: |
[ -d Benchmarks ] && echo "hasBenchmark=1" >> $GITHUB_ENV
[ -f Benchmarks/Package.swift ] && echo "BENCHMARK_PACKAGE_PATH=--package-path Benchmarks" >> $GITHUB_ENV
echo "/opt/homebrew/bin:/usr/local/bin" >> $GITHUB_PATH
- name: Run benchmarks for PR branch
if: ${{ env.hasBenchmark == '1' }}
run: |
echo "exitStatus=1" >> $GITHUB_ENV
swift package ${BENCHMARK_PACKAGE_PATH} --disable-sandbox benchmark baseline update pull_request --no-progress
- name: Switch to branch 'main'
if: ${{ env.hasBenchmark == '1' }}
run: |
git stash
git checkout main
- name: Run benchmarks for branch 'main'
if: ${{ env.hasBenchmark == '1' }}
run: |
swift package ${BENCHMARK_PACKAGE_PATH} --disable-sandbox benchmark baseline update main --no-progress
- name: Compare PR and main
if: ${{ env.hasBenchmark == '1' }}
id: benchmark
continue-on-error: true
run: |
echo $(date) >> $GITHUB_STEP_SUMMARY
swift package ${BENCHMARK_PACKAGE_PATH} benchmark baseline check main pull_request --format markdown >> $GITHUB_STEP_SUMMARY
echo "exitStatus=$?" >> $GITHUB_ENV
- if: ${{ env.exitStatus == '0' }}
name: Pull request comment text same
run: |
{
echo "_Pull request is the same as baseline_"
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)"
} > benchmark_comment
- if: ${{ env.exitStatus == '1' }}
name: Pull request comment text failure
run: |
{
echo "_Pull request had an unknown failure_"
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)"
} > benchmark_comment
- if: ${{ env.exitStatus == '2' }}
name: Pull request comment text regression
run: |
{
echo "_Pull request had a regression_"
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)"
} > benchmark_comment
- if: ${{ env.exitStatus == '4' }}
name: Pull request comment text improvement
run: |
{
echo "_Pull request had a performance improvement_"
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)"
} > benchmark_comment
- name: Comment PR
if: ${{ env.hasBenchmark == '1' }}
uses: thollander/actions-comment-pull-request@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file-path: benchmark_comment
comment-tag: 'Pull request benchmark comparison [${{ matrix.os }}] with'
- name: Exit with correct status
if: ${{ success() || failure() }}
run: |
#/usr/bin/ordo-performance powersave
exit ${{ env.exitStatus }}