2020-05-20 14:08:00 -04:00
|
|
|
# frozen_string_literal: true
|
2022-03-23 20:07:27 -04:00
|
|
|
# This file isn't named "Dangerfile" so that it's not imported by default since it's only meant to be run in the `bundle-size-review` job.
|
2020-05-20 14:08:00 -04:00
|
|
|
|
|
|
|
analysis_result = "./bundle-size-review/analysis.json"
|
|
|
|
markdown_result = "./bundle-size-review/comparison.md"
|
|
|
|
|
|
|
|
# Executing the webpack-entry-point-analyser
|
|
|
|
# We would like to do that in the CI file directly,
|
|
|
|
# but unfortunately the head_commit SHA is not available
|
|
|
|
# as a CI variable due to our merge into master simulation
|
|
|
|
analyze_cmd = [
|
|
|
|
"webpack-entry-point-analyser",
|
|
|
|
"--from-file ./webpack-report/stats.json",
|
|
|
|
"--json #{analysis_result}",
|
|
|
|
" --sha #{gitlab&.head_commit}"
|
|
|
|
].join(" ")
|
|
|
|
|
|
|
|
# execute analysis
|
|
|
|
`#{analyze_cmd}`
|
|
|
|
|
|
|
|
# We are executing the comparison by comparing the start_sha
|
|
|
|
# to the current pipeline result. The start_sha is the commit
|
|
|
|
# from master that was merged into for the merged pipeline.
|
|
|
|
comparison_cmd = [
|
|
|
|
"webpack-compare-reports",
|
2020-05-21 17:08:31 -04:00
|
|
|
"--job #{ENV["CI_JOB_ID"]}",
|
2020-05-20 14:08:00 -04:00
|
|
|
"--to-file #{analysis_result}",
|
|
|
|
"--html ./bundle-size-review/comparison.html",
|
|
|
|
"--markdown #{markdown_result}"
|
|
|
|
].join(" ")
|
|
|
|
|
|
|
|
# execute comparison
|
|
|
|
`#{comparison_cmd}`
|
|
|
|
|
|
|
|
comment = `cat #{markdown_result}`
|
|
|
|
|
2020-11-23 04:09:13 -05:00
|
|
|
unless comment.strip.empty?
|
|
|
|
markdown(<<~MARKDOWN)
|
2020-05-20 14:08:00 -04:00
|
|
|
#{comment}
|
2020-11-23 04:09:13 -05:00
|
|
|
MARKDOWN
|
|
|
|
end
|