From 0ff48ed6dd5e1f141b083d55fd10e621b65ec2bc Mon Sep 17 00:00:00 2001 From: Amit Kumar Singh Date: Thu, 13 Jan 2022 16:08:59 +0530 Subject: [PATCH] Disable benchmarks comment on fork pull request (#820) * Disable benchmarks on fork PR * run benchmarks on fork PR but disbable PR comment --- .github/workflows/ci.yml | 6 +++--- project/BenchmarkWorkFlow.scala | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c1f7a6d18..d9d303fffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -259,15 +259,15 @@ jobs: run: | cp ./zio-http/example/src/main/scala/example/PlainTextBenchmarkServer.scala ./FrameworkBenchMarks/frameworks/Scala/zio-http/src/main/scala/Main.scala cd ./FrameworkBenchMarks - echo ${{github.event.pull_request.head.sha}} - sed -i "s/---COMMIT_SHA---/${{github.event.pull_request.head.sha}}/g" frameworks/Scala/zio-http/build.sbt + sed -i "s/---COMMIT_SHA---/${{github.event.pull_request.head.repo.owner.login}}\/zio-http.git#${{github.event.pull_request.head.sha}}/g" frameworks/Scala/zio-http/build.sbt ./tfb --test zio-http | tee result RESULT_REQUEST=$(echo $(grep -B 1 -A 17 "Concurrency: 256 for plaintext" result) | grep -oiE "requests/sec: [0-9]+.[0-9]+") RESULT_CONCURRENCY=$(echo $(grep -B 1 -A 17 "Concurrency: 256 for plaintext" result) | grep -oiE "concurrency: [0-9]+") echo ::set-output name=request_result::$(echo $RESULT_REQUEST) echo ::set-output name=concurrency_result::$(echo $RESULT_CONCURRENCY) - - uses: peter-evans/commit-comment@v1 + - if: ${{github.event.pull_request.head.repo.full_name == 'dream11/zio-http'}} + uses: peter-evans/commit-comment@v1 with: sha: ${{github.event.pull_request.head.sha}} body: | diff --git a/project/BenchmarkWorkFlow.scala b/project/BenchmarkWorkFlow.scala index b9f277548f..acfd278b00 100644 --- a/project/BenchmarkWorkFlow.scala +++ b/project/BenchmarkWorkFlow.scala @@ -7,7 +7,9 @@ object BenchmarkWorkFlow { id = "runBenchMarks", name = "Benchmarks", oses = List("centos"), - cond = Some("${{ github.event_name == 'pull_request'}}"), + cond = Some( + "${{ github.event_name == 'pull_request'}}", + ), steps = List( WorkflowStep.Run( env = Map("GITHUB_TOKEN" -> "${{secrets.ACTIONS_PAT}}"), @@ -34,8 +36,7 @@ object BenchmarkWorkFlow { commands = List( "cp ./zio-http/example/src/main/scala/example/PlainTextBenchmarkServer.scala ./FrameworkBenchMarks/frameworks/Scala/zio-http/src/main/scala/Main.scala", "cd ./FrameworkBenchMarks", - "echo ${{github.event.pull_request.head.sha}}", - """sed -i "s/---COMMIT_SHA---/${{github.event.pull_request.head.sha}}/g" frameworks/Scala/zio-http/build.sbt""", + """sed -i "s/---COMMIT_SHA---/${{github.event.pull_request.head.repo.owner.login}}\/zio-http.git#${{github.event.pull_request.head.sha}}/g" frameworks/Scala/zio-http/build.sbt""", "./tfb --test zio-http | tee result", """RESULT_REQUEST=$(echo $(grep -B 1 -A 17 "Concurrency: 256 for plaintext" result) | grep -oiE "requests/sec: [0-9]+.[0-9]+")""", """RESULT_CONCURRENCY=$(echo $(grep -B 1 -A 17 "Concurrency: 256 for plaintext" result) | grep -oiE "concurrency: [0-9]+")""", @@ -45,6 +46,9 @@ object BenchmarkWorkFlow { ), WorkflowStep.Use( ref = UseRef.Public("peter-evans", "commit-comment", "v1"), + cond = Some( + "${{github.event.pull_request.head.repo.full_name == 'dream11/zio-http'}}", + ), params = Map( "sha" -> "${{github.event.pull_request.head.sha}}", "body" ->