diff --git a/nix/cells/automation/library/plutus-benchmark-runner.nix b/nix/cells/automation/library/plutus-benchmark-runner.nix index 96418ffa5ab..641fd74a541 100644 --- a/nix/cells/automation/library/plutus-benchmark-runner.nix +++ b/nix/cells/automation/library/plutus-benchmark-runner.nix @@ -1,6 +1,6 @@ { cell, inputs }: -{ PR_NUMBER, PR_COMMIT_SHA, BENCHMARK_NAME, GITHUB_TOKEN }: +{ PR_NUMBER, BENCHMARK_NAME, GITHUB_TOKEN }: let inherit (inputs.cells.plutus.library) pkgs; @@ -19,7 +19,6 @@ pkgs.writeShellApplication { ]; text = '' PR_NUMBER=${PR_NUMBER} \ - PR_COMMIT_SHA=${PR_COMMIT_SHA} \ BENCHMARK_NAME=${BENCHMARK_NAME} \ GITHUB_TOKEN=${GITHUB_TOKEN} \ ${./plutus-benchmark-runner.sh} diff --git a/nix/cells/automation/library/plutus-benchmark-runner.sh b/nix/cells/automation/library/plutus-benchmark-runner.sh index 8b519fe110e..be07331a7f8 100755 --- a/nix/cells/automation/library/plutus-benchmark-runner.sh +++ b/nix/cells/automation/library/plutus-benchmark-runner.sh @@ -24,16 +24,12 @@ if [ -z "$PR_NUMBER" ] ; then echo "[ci-plutus-benchmark]: 'PR_NUMBER' is not set! Exiting" exit 1 fi -if [ -z "$PR_COMMIT_SHA" ] ; then - echo "[ci-plutus-benchmark]: 'PR_COMMIT_SHA' is not set! Exiting" - exit 1 -fi if [ -z "$BENCHMARK_NAME" ] ; then echo "[ci-plutus-benchmark]: 'BENCHMARK_NAME' is not set! Exiting" exit 1 fi -PR_BRANCH_REF=$(git rev-parse --short $PR_COMMIT_SHA) +PR_BRANCH_REF=$(git rev-parse --short HEAD) echo "[ci-plutus-benchmark]: Processing benchmark comparison for benchmark '$BENCHMARK_NAME' on PR $PR_NUMBER" diff --git a/nix/cells/automation/pipelines.nix b/nix/cells/automation/pipelines.nix index b43faf6cc30..c0c6a911b53 100644 --- a/nix/cells/automation/pipelines.nix +++ b/nix/cells/automation/pipelines.nix @@ -8,6 +8,8 @@ let inherit (inputs.nixpkgs) lib system; inherit (inputs.cells) cloud; + inherit (inputs.cells.plutus) library; + inherit (library) pkgs; common = { config @@ -52,27 +54,30 @@ in benchmark = { config, ... }: let - # Facts here correspond to inputs created by the benchmark action in the cloud cell - facts = config.actionRun.facts; - commentFact = facts.${cloud.library.actions.benchmark.commentInput}.value.github_body; - prFact = facts.${cloud.library.actions.benchmark.prInput}.value.github_body; + fact = config.actionRun.facts.${cloud.library.actions.benchmark.input}.value.github_body; + prNumber = toString fact.issue.number; - prRevision = prFact.pull_request.head.sha; + prRevision = lib.getExe (pkgs.writeScript "get-pr-rev" '' + curl \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/input-output-hk/plutus/pulls/${prNumber} \ + | jq -r .base.sha + ''); runner = cell.library.plutus-benchmark-runner { - PR_NUMBER = toString prFact.pull_request.number; - PR_COMMIT_SHA = prRevision; - BENCHMARK_NAME = lib.removePrefix "/benchmark " commentFact.comment.body; + PR_NUMBER = prNumber; + BENCHMARK_NAME = lib.removePrefix "/benchmark " fact.comment.body; GITHUB_TOKEN = "/secrets/cicero/github/token"; }; in { - # Not importing common, github preset is not needed here + # Not importing commn module defined above, because we don't need the github preset preset.nix.enable = true; preset.git.clone = { enable = true; remote = "https://github.com/input-output-hk/plutus"; - ref = prRevision; + # Tullia has some magic to get the revision when given a script like this + ref.outPath = prRevision; }; command.text = "${runner}/bin/plutus-benchmark-runner"; nomad.templates = [ diff --git a/nix/cells/cloud/actions.nix b/nix/cells/cloud/actions.nix index b1f34204cc2..a08d788073f 100644 --- a/nix/cells/cloud/actions.nix +++ b/nix/cells/cloud/actions.nix @@ -1,7 +1,7 @@ { cell , inputs }: { - /* "plutus/ci" = { + "plutus/ci" = { task = "ci"; io = '' // This is a CUE expression that defines what events trigger a new run of this action. @@ -18,66 +18,20 @@ { #lib.io.github_pr, github, #target_default: false }, ] ''; - };*/ + }; "plutus/benchmark" = { task = "benchmark"; io = '' - // Two inputs need to match: PR sync event & issue comment creation event - - // WIP: Currently inlining lib.io.github_pr_comment - // #lib.io.github_pr_comment & - // - { - #input: string | *"GitHub PR comment to \(#repo)" - #prInput: string | *"GitHub PR to \(#repo)" - - #repo: =~"^[^/]+/[^/]+$" - #comment: string - - - _prRepo: #repo - - let pr = { - #lib.io.github_pr - #input: #prInput - #repo: _prRepo - inputs: _final_inputs - } - - _final_inputs: inputs - inputs: { - pr.inputs - - "\(#input)": match: { - github_event: "issue_comment" - github_body: { - action: "created" - - repository: full_name: #repo - - issue: pull_request: {} - - comment: body: =~#comment - } - } - } - - let _body = inputs["\(#input)"].value.github_body - _repo: _body.repository.full_name - _comment: _body.comment.body - _number: _body.issue.number - - #target: "zeme-iohk/benchmarking" - #input: "${cell.library.actions.benchmark.commentInput}" - #prInput: "${cell.library.actions.benchmark.prInput}" + #lib.io.github_pr_comment & { + #input: "${cell.library.actions.benchmark.input}" #repo: "input-output-hk/plutus" #comment: "^/benchmark .+" } ''; }; - /*"plutus/publish-documents" = { + "plutus/publish-documents" = { task = "publish-documents"; io = '' let push = { @@ -97,6 +51,6 @@ } } ''; - };*/ + }; } diff --git a/nix/cells/cloud/library.nix b/nix/cells/cloud/library.nix index 6f026310726..c54766b6d0d 100644 --- a/nix/cells/cloud/library.nix +++ b/nix/cells/cloud/library.nix @@ -3,8 +3,7 @@ }: { actions = { ci.input = "GitHub event"; - benchmark.commentInput = "GitHub comment"; - benchmark.prInput = "GitHub pr"; + benchmark.input = "GitHub comment"; documents.input = "GitHub push"; }; }