Skip to content

Instantly share code, notes, and snippets.

@MahdiBM
Last active September 16, 2024 22:29
Show Gist options
  • Save MahdiBM/53adae524092b7a8fcddb61aa7f42a7d to your computer and use it in GitHub Desktop.
Save MahdiBM/53adae524092b7a8fcddb61aa7f42a7d to your computer and use it in GitHub Desktop.
Update Benchmark Thresholds
name: update-benchmark-thresholds
on:
workflow_dispatch:
inputs:
# This will have to be an exhastive list of all benchmarks.
# If there is a benchmark name missing, just update this list and push.
benchmark:
type: choice
required: true
description: "What benchmark to update"
options:
- 'MySampleBenchmark'
- 'all'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update-thresholds:
# Using GitHub Actions runners is not recommended for non-allocation benchmarks. They're not consistent enough.
runs-on: ubuntu-latest
timeout-minutes: 60
container: swift:5.10-noble
env:
THRESHOLDS_DIR: "Benchmarks/Thresholds/"
PR_COMMENT: null # will be populated later
steps:
- name: Configure git
shell: bash
run: |
set -eu
# EDIT THESE 4 LINES. Provide correct info and secret.
# Set up git and ability to commit changes
git config --global user.name "my-bot"
git config --global user.email "[email protected]"
git config --global --add url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"
git config --global --add url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf "[email protected]:"
git config --global --add safe.directory '*'
- name: Check out ${{ github.event.repository.name }}
uses: actions/checkout@v4
# jemalloc is a dependency of the Benchmarking package
- name: Install jemalloc
run: |
set -eu
apt-get update -y
apt-get install -y libjemalloc-dev
- name: Restore .build
id: "restore-cache"
uses: runs-on/cache/restore@v4
with:
path: .build
# e.g. 'my-repo-benchmark-build-Linux-c7008df8062ac4d5887ead9e59aa05829e'
key: "${{ github.event.repository.name }}-benchmark-build-${{ runner.os }}-${{ github.sha }}}"
restore-keys: "${{ github.event.repository.name }}-benchmark-build-${{ runner.os }}-"
- name: Update Thresholds Based On Current Branch '${{ github.ref_name }}'
run: |
set -eu
if [ "${{ inputs.benchmark }}" = "all" ]; then
BENCHMARK_FILTER=""
else
BENCHMARK_FILTER="--filter ${{ inputs.benchmark }}"
fi
echo "Benchmark filter is $BENCHMARK_FILTER"
swift package --allow-writing-to-directory "$THRESHOLDS_DIR" benchmark $BENCHMARK_FILTER --format metricP90AbsoluteThresholds --path "$THRESHOLDS_DIR"
- name: Commit The Changes
shell: bash
run: |
set -eu
git add .
git commit -m "Update benchmark thresholds"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment