Skip to content

Commit a7ffcf9

Browse files
comment on PR
1 parent dc9026e commit a7ffcf9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/benchmarking.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
path: bench/sources/here
7070
- name: Fetch existing benchmarks
7171
run: Rscript -e 'rlang::with_handlers(bench::cb_fetch(), error = function(e) paste("Could not fetch benchmarks, skipping. The error was", conditionMessage(e)))'
72+
- name: Prepare PR comment
73+
run: echo 'Here is how the current PR would change benchmark results:\n' > bench/pr-comment
7274
- name: Run benchmarks
7375
run: Rscript -e 'bench::cb_run()'
7476
- name: Show benchmarks
@@ -80,3 +82,9 @@ jobs:
8082
- name: Push benchmarks
8183
if: ${{ github.event_name == 'push' }}
8284
run: Rscript -e "bench::cb_push()"
85+
- name: comment PR
86+
uses: machine-learning-apps/pr-comment@master
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
path: bench/pr-comment

bench/01-declarations.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ plot_against_base <- function(new_bm,
2222
dplyr::filter(.data$name %in% !!name)
2323
reference$expression <- bench:::new_bench_expr(Sys.getenv("GITHUB_BASE_REF"))
2424
new_bm <- dplyr::bind_rows(reference, new_bm)
25+
stopifnot(nrow(new_bm) == 2)
26+
diff_in_percent <- round(100 * diff(new_bm$p50) / new_bm$p50[1])
27+
pr_comment <- glue::glue("* {name}: {new_bm$p50[1]} -> {new_bm$p50[2]} ({diff_in_percent}%)\n")
28+
cat(pr_comment, file = "pr-comment", append = TRUE)
2529
}
2630
}
2731
new_bm$branch <- factor(new_bm$expression)

0 commit comments

Comments
 (0)