Skip to content

Commit

Permalink
Teach /benchmark to take a benchmark name (IntersectMBO#4351)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpj authored Jan 27, 2022
1 parent 39cde0a commit fdc1eeb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Check for '/benchmark' comments on a PR
#
- uses: khan/pull-request-comment-trigger@master
id: check
id: find-comment
with:
trigger: '/benchmark'
reaction: rocket
Expand All @@ -30,14 +30,24 @@ jobs:
# Extract the branch of that the PR the comment was added to belongs to
#
- uses: xt0rted/pull-request-comment-branch@v1
if: steps.check.outputs.triggered == 'true'
id: comment-branch
if: steps.find-comment.outputs.triggered == 'true'
id: extract-branch
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}

#
# Extract the benchmark name from the comment text
#
- uses: actions-ecosystem/action-regex-match@v2
if: steps.check.outputs.triggered == 'true'
id: extract-benchmark
with:
text: ${{ github.find-comment.outputs.comment_body }}
regex: '^/benchmark\s*(.*?)\s*$'

#
# Trigger the buildkite pipeline IF the 'benchmark' command was found
#
- run: |
./scripts/trigger-buildkite-pipeline.sh ${{ steps.comment-branch.outputs.head_ref }} ${{ github.event.issue.number }}
if: steps.check.outputs.triggered == 'true'
./scripts/trigger-buildkite-pipeline.sh ${{ steps.extract-branch.outputs.head_ref }} ${{ github.event.issue.number }} ${{ steps.extract-benchmark.outputs.group1 }}
if: steps.find-comment.outputs.triggered == 'true' && steps.extract-benchmark.outputs.match != ""
11 changes: 8 additions & 3 deletions scripts/ci-plutus-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ if [ -z "$PR_NUMBER" ] ; then
echo "[ci-plutus-benchmark]: 'PR_NUMBER' is not set! Exiting"
exit 1
fi
echo "[ci-plutus-benchmark]: Processing benchmark comparison for PR $PR_NUMBER"
if [ -z "$BENCHMARK_NAME" ] ; then
echo "[ci-plutus-benchmark]: 'BENCHMARK_NAME' is not set! Exiting"
exit 1
fi

echo "[ci-plutus-benchmark]: Processing benchmark comparison for benchmark $BENCHMARK_NAME on PR $PR_NUMBER"
PR_BRANCH_REF=$(git rev-parse --short HEAD)

echo "[ci-plutus-benchmark]: Updating cabal database ..."
cabal update

echo "[ci-plutus-benchmark]: Running benchmark for PR branch ..."
nix-shell --run "cabal bench plutus-benchmark:validation >bench-PR.log 2>&1"
nix-shell --run "cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1"

echo "[ci-plutus-benchmark]: fetching origin ..."
git fetch origin
Expand All @@ -46,7 +51,7 @@ git checkout "$(git merge-base HEAD origin/master)"
BASE_BRANCH_REF=$(git rev-parse --short HEAD)

echo "[ci-plutus-benchmark]: Running benchmark for base branch ..."
nix-shell --run "cabal bench plutus-benchmark:validation >bench-base.log 2>&1"
nix-shell --run "cabal bench $BENCHMARK_NAME >bench-base.log 2>&1"

git checkout "$PR_BRANCH_REF" # .. so we use the most recent version of the comparison script

Expand Down
12 changes: 7 additions & 5 deletions scripts/trigger-buildkite-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -e

if [ $# -ne 2 ]; then
if [ $# -ne 3 ]; then
echo "[trigger-buildkite-pipeline]: Missing argument(s)"
echo "[trigger-buildkite-pipeline]: expecting 2 arguments: <branch name> <PR number>"
echo "[trigger-buildkite-pipeline]: expecting 3 arguments: <branch name> <PR number> <benchmark name>"
echo "[trigger-buildkite-pipeline]: Arguments received: '$*'"
exit 1
fi
Expand All @@ -15,9 +15,10 @@ if [ -z "$BUILDKITE_API_ACCESS_TOKEN" ] ; then
fi

BRANCH="$1"
PR="$2"
PR_NUMBER="$2"
BENCHMARK_NAME="$2"

echo "[trigger-buildkite-pipeline]: Triggering build for $BRANCH"
echo "[trigger-buildkite-pipeline]: Triggering build of benchmark $BENCHMARK_NAME for branch $BRANCH on PR $PR_NUMBER"

curl --silent -H "Authorization: Bearer $BUILDKITE_API_ACCESS_TOKEN" \
-X POST "https://api.buildkite.com/v2/organizations/input-output-hk/pipelines/plutus-benchmark/builds"\
Expand All @@ -26,6 +27,7 @@ curl --silent -H "Authorization: Bearer $BUILDKITE_API_ACCESS_TOKEN" \
\"branch\": \"$BRANCH\",
\"message\": \"Running benchmarks\",
\"env\": {
\"PR_NUMBER\": \"$PR\"
\"PR_NUMBER\": \"$PR_NUMBER\"
\"BENCHMARK_NAME\": \"$BENCHMARK_NAME\"
}
}"

0 comments on commit fdc1eeb

Please sign in to comment.