Skip to content

Commit

Permalink
use tullia git preset to fetch branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Pacman99 authored and zeme-wana committed Nov 29, 2022
1 parent 58795ad commit 63c241a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
26 changes: 7 additions & 19 deletions nix/cells/automation/library/plutus-benchmark-runner.sh
Expand Up @@ -32,16 +32,6 @@ if [ -z "$BENCHMARK_NAME" ] ; then
echo "[ci-plutus-benchmark]: 'BENCHMARK_NAME' is not set! Exiting"
exit 1
fi
if [ -z "$GITHUB_TOKEN" ] ; then
echo "[ci-plutus-benchmark]: 'GITHUB_TOKEN' is not set! Exiting"
exit 1
fi

echo "[ci-plutus-benchmark]: Cloning the plutus repository"
git init
git remote add origin git@github.com:input-output-hk/plutus.git
git fetch --depth 1 origin $PR_COMMIT_SHA
git checkout $PR_COMMIT_SHA

PR_BRANCH_REF=$(git rev-parse --short $PR_COMMIT_SHA)

Expand All @@ -53,9 +43,6 @@ nix develop --command cabal update
echo "[ci-plutus-benchmark]: Running benchmark for PR branch ..."
nix develop --command cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1

echo "[ci-plutus-benchmark]: fetching origin ..."
git fetch --depth 1 origin master

echo "[ci-plutus-benchmark]: Switching branches ..."
git checkout "$(git merge-base HEAD origin/master)"
BASE_BRANCH_REF=$(git rev-parse --short HEAD)
Expand All @@ -66,8 +53,6 @@ nix develop --command cabal clean
echo "[ci-plutus-benchmark]: Running benchmark for base branch ..."
nix develop --command 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

echo "[ci-plutus-benchmark]: Comparing results ..."
{
# The blank line is important, otherwise Github doesn't render markdown in the body of the details element.
Expand All @@ -84,7 +69,10 @@ echo -e "</details>"
} > bench-compare-result.log

jq -Rs '.' bench-compare-result.log >bench-compare.json

echo "[ci-plutus-benchmark]: Posting results to GitHub ..."
# TODO(std) we'll need to change this
curl -s -H "Authorization: token $(<$GITHUB_TOKEN)" -X POST -d "{\"body\": $(<bench-compare.json)}" "https://api.github.com/repos/input-output-hk/plutus/issues/${PR_NUMBER}/comments"
if [ -v GITHUB_TOKEN ] ; then
echo "[ci-plutus-benchmark]: Posting results to GitHub ..."
# TODO(std) we'll need to change this
curl -s -H "Authorization: token $(<$GITHUB_TOKEN)" -X POST -d "{\"body\": $(<bench-compare.json)}" "https://api.github.com/repos/input-output-hk/plutus/issues/${PR_NUMBER}/comments"
else
echo "[ci-plutus-benchmark]: GITHUB_TOKEN not set, not posting results to GitHub"
fi
9 changes: 8 additions & 1 deletion nix/cells/automation/pipelines.nix
Expand Up @@ -47,16 +47,23 @@ in
commentFact = facts.${cloud.library.actions.benchmark.commentInput}.value.github_body;
prFact = facts.${cloud.library.actions.benchmark.prInput}.value.github_body;

prRevision = prFact.pull_request.head.sha;

runner = cell.library.plutus-benchmark-runner {
PR_NUMBER = toString prFact.pull_request.number;
PR_COMMIT_SHA = prFact.pull_request.head.sha;
PR_COMMIT_SHA = prRevision;
BENCHMARK_NAME = lib.removePrefix "/benchmark " commentFact.comment.body;
GITHUB_TOKEN = "/secrets/cicero/github/token";
};
in
{
# Not importing common, github preset is not needed here
preset.nix.enable = true;
preset.git = {
enable = true;
remote = "https://github.com/input-output-hk/plutus";
ref = prRevision;
};
command.text = "${runner}/bin/plutus-benchmark-runner";
nomad.templates = [
{
Expand Down

0 comments on commit 63c241a

Please sign in to comment.