Skip to content

Commit

Permalink
feat: add comment when bench finished
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <igxnon@gmail.com>
  • Loading branch information
iGxnon committed Mar 3, 2024
1 parent ac479c4 commit a91ff88
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 3 deletions.
40 changes: 40 additions & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.9'

services:
xline1:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- ..:/xline
networks:
- xline_network

xline2:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- ..:/xline
networks:
- xline_network

xline3:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- ..:/xline
networks:
- xline_network

xline4:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- ..:/xline
networks:
- xline_network

xline5:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- ..:/xline
networks:
- xline_network

networks:
xline_network:
49 changes: 49 additions & 0 deletions ci/plugins/pr-comment/hooks/post-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

set -euo pipefail

REPO=$BUILDKITE_PULL_REQUEST_REPO
PR=$BUILDKITE_PULL_REQUEST

re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+).git$"

if [[ $REPO =~ $re ]]; then
GITHUB_USER=${BASH_REMATCH[4]}
GITHUB_REPO=${BASH_REMATCH[5]}
fi

if [[ -z "${PR:-}" ]]; then
echo "Warn: PR to comment is missing. Skipping" 1>&2
exit 0
fi

if [[ -z "${GITHUB_USER:-}" ]]; then
echo "Warn: Cannot identify github user/org. Skipping" 1>&2
exit 0
fi

if [[ -z "${GITHUB_REPO:-}" ]]; then
echo "Warn: Cannot identify github repo. Skipping" 1>&2
exit 0
fi

if [[ -z "${GITHUB_TOKEN:-}" ]]; then
echo "Error: GITHUB_TOKEN environment variable not set" 1>&2
echo "A Github personal access token with repo permissions is needed to comment on pull requests" 1>&2
exit 1
fi

if [[ -z "${BUILDKITE_PLUGIN_PR_COMMENT_COMMENT_FILE:-}" ]]; then
echo "Error: comment property in the plugin es mandatory" 1>&2
exit 1
fi

echo "Posting comment to PR $PR in ${GITHUB_USER}/${GITHUB_REPO}" 1>&2

jq -n --arg msg "$(cat ${BUILDKITE_PLUGIN_PR_COMMENT_COMMENT_FILE})" '{body: $msg}' | curl -sSg \
-u apikey:${GITHUB_TOKEN} \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: application/json' \
-X POST \
-d@- \
"https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/issues/${PR}/comments"
Empty file modified ci/scripts/run-benchmark.sh
100644 → 100755
Empty file.
11 changes: 8 additions & 3 deletions ci/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
steps:
- label: "build"
command: "docker run -q --rm -v $(pwd):/xline \
if: build.pull_request.labels includes "run-benchmark"
command: "docker run --rm -v $(pwd):/xline \
ghcr.io/xline-kv/build-env:latest \
cargo build --release --bin xline --bin benchmark"

- wait

- label: "benchmark"
depends_on:
- "build"
command: "ci/scripts/run-benchmark.sh"
if: build.pull_request.labels includes "run-benchmark"
env:
BUILDKITE_PLUGIN_PR_COMMENT_COMMENT_FILE: "out/xline.txt"
plugins:
- ./ci/plugins/pr-comment

0 comments on commit a91ff88

Please sign in to comment.