From 28091e2b33bdaf1bb12614568cb43d582f9b2f0b Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 1 Oct 2024 22:47:37 +0400 Subject: [PATCH 1/2] Comment on alert only if the PR is made from main repo --- .github/workflows/benchmark.main.kts | 6 ++++-- .github/workflows/benchmark.yaml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.main.kts b/.github/workflows/benchmark.main.kts index 81a4a058e..71b3a02d3 100755 --- a/.github/workflows/benchmark.main.kts +++ b/.github/workflows/benchmark.main.kts @@ -144,13 +144,15 @@ workflow( action = GithubActionBenchmark( name = "SnakeKMP benchmarks", tool = GithubActionBenchmark.Tool.Jmh, - commentOnAlert = true, + // Comment on PR only the PR is made from the same repo + commentOnAlert_Untyped = expr { "${github.eventPullRequest.pull_request.head.repo.full_name} == 'krzema12/snakeyaml-engine-kmp'" }, summaryAlways = true, alertThreshold = "150%", failThreshold = "200%", ghRepository = "github.com/krzema12/snakeyaml-engine-kmp-benchmarks", outputFilePath = AGGREGATED_REPORT, - githubToken = expr { PUBLISH_BENCHMARK_RESULTS }, + // Use GitHub token in case the secret is not available + githubToken = expr { "$PUBLISH_BENCHMARK_RESULTS || ${github.token}" }, // Push and deploy GitHub pages branch automatically only if run in main repo and not in PR autoPush_Untyped = expr { "${github.repository} == 'krzema12/snakeyaml-engine-kmp' && ${github.event_name} != 'pull_request'" }, ), diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 874e8c2cd..6ca3cd8ca 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -95,9 +95,9 @@ jobs: tool: 'jmh' output-file-path: 'aggregated.json' gh-repository: 'github.com/krzema12/snakeyaml-engine-kmp-benchmarks' - github-token: '${{ secrets.PUBLISH_BENCHMARK_RESULTS }}' + github-token: '${{ secrets.PUBLISH_BENCHMARK_RESULTS || github.token }}' auto-push: '${{ github.repository == ''krzema12/snakeyaml-engine-kmp'' && github.event_name != ''pull_request'' }}' summary-always: 'true' - comment-on-alert: 'true' + comment-on-alert: '${{ github.event.pull_request.head.repo.full_name == ''krzema12/snakeyaml-engine-kmp'' }}' alert-threshold: '150%' fail-threshold: '200%' From 72845c7a9808988018d05c5f60d94373bef9c356 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 1 Oct 2024 21:33:31 +0200 Subject: [PATCH 2/2] Make a const with full repo name --- .github/workflows/benchmark.main.kts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.main.kts b/.github/workflows/benchmark.main.kts index 71b3a02d3..eebaf44ed 100755 --- a/.github/workflows/benchmark.main.kts +++ b/.github/workflows/benchmark.main.kts @@ -36,6 +36,7 @@ val BENCHMARK_RESULTS = "snake-kmp-benchmarks/build/reports/benchmarks" val RESULTS_DIR = "bench-results" val AGGREGATED_REPORT = "aggregated.json" val PUBLISH_BENCHMARK_RESULTS by Contexts.secrets +val FULL_REPOSITORY_NAME = "krzema12/snakeyaml-engine-kmp" workflow( name = "Run Benchmarks", @@ -145,7 +146,7 @@ workflow( name = "SnakeKMP benchmarks", tool = GithubActionBenchmark.Tool.Jmh, // Comment on PR only the PR is made from the same repo - commentOnAlert_Untyped = expr { "${github.eventPullRequest.pull_request.head.repo.full_name} == 'krzema12/snakeyaml-engine-kmp'" }, + commentOnAlert_Untyped = expr { "${github.eventPullRequest.pull_request.head.repo.full_name} == '$FULL_REPOSITORY_NAME'" }, summaryAlways = true, alertThreshold = "150%", failThreshold = "200%", @@ -154,7 +155,7 @@ workflow( // Use GitHub token in case the secret is not available githubToken = expr { "$PUBLISH_BENCHMARK_RESULTS || ${github.token}" }, // Push and deploy GitHub pages branch automatically only if run in main repo and not in PR - autoPush_Untyped = expr { "${github.repository} == 'krzema12/snakeyaml-engine-kmp' && ${github.event_name} != 'pull_request'" }, + autoPush_Untyped = expr { "${github.repository} == '$FULL_REPOSITORY_NAME' && ${github.event_name} != 'pull_request'" }, ), ) }