Skip to content

Commit

Permalink
ci(benchmark): optimise benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 committed Dec 9, 2021
1 parent 501a9c8 commit 72fda01
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ name: Continuous Integration
on:
pull_request:
branches: ['**']
types: [opened, synchronize, reopened, edited]
push:
branches: ['**']
tags: [v*]
Expand Down Expand Up @@ -207,7 +208,7 @@ jobs:

runBenchMarks:
name: Benchmarks
if: ${{ github.event_name == 'push'}}
if: ${{ github.event_name == 'pull_request'}}
strategy:
matrix:
os: [centos]
Expand All @@ -233,7 +234,8 @@ jobs:
- id: result
run: |
cd ./FrameworkBenchMarks
sed -i "s/---COMMIT_SHA---/${GITHUB_SHA}/g" frameworks/Scala/zio-http/build.sbt
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
./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]+")
Expand Down
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ lazy val root = (project in file("."))
.aggregate(zhttp, zhttpBenchmarks, zhttpTest, example)

// CI Configuration
ThisBuild / githubWorkflowPREventTypes := Seq(
PREventType.Opened,
PREventType.Synchronize,
PREventType.Reopened,
PREventType.Edited,
)
ThisBuild / githubWorkflowAddedJobs :=
Seq(
WorkflowJob(
Expand Down
9 changes: 5 additions & 4 deletions project/BenchmarkWorkFlow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object BenchmarkWorkFlow {
id = "runBenchMarks",
name = "Benchmarks",
oses = List("centos"),
cond = Some("${{ github.event_name == 'push'}}"),
cond = Some("${{ github.event_name == 'pull_request'}}"),
env = Map("GITHUB_TOKEN" -> "${{secrets.ACTIONS_PAT}}"),
steps = List(
WorkflowStep.Run(
Expand All @@ -32,7 +32,8 @@ object BenchmarkWorkFlow {
id = Some("result"),
commands = List(
"cd ./FrameworkBenchMarks",
"""sed -i "s/---COMMIT_SHA---/${GITHUB_SHA}/g" frameworks/Scala/zio-http/build.sbt""",
"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""",
"./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]+")""",
Expand All @@ -41,8 +42,8 @@ object BenchmarkWorkFlow {
),
),
WorkflowStep.Use(
UseRef.Public("unsplash", "comment-on-pr", "v1.3.0"),
Map(
ref = UseRef.Public("unsplash", "comment-on-pr", "v1.3.0"),
params = Map(
"msg" -> "## \uD83D\uDE80\uD83D\uDE80\uD83D\uDE80 Benchmark Results \n **${{steps.result.outputs.concurrency_result}}** \n **${{steps.result.outputs.request_result}}**",
"check_for_duplicate_msg" -> "false",
),
Expand Down

0 comments on commit 72fda01

Please sign in to comment.