Skip to content

Commit 14f4d65

Browse files
committed
build: fix coverage change calculation in CI script and formatting
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: passed - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent ee4d86a commit 14f4d65

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

.github/workflows/scripts/run_tests_coverage

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,16 @@ compare_cov() {
108108
new_cov_value="$2"
109109

110110
if [ "$old_cov_value" == 0 ]; then
111-
new_cov_percentage=$(awk "BEGIN {printf \"%.2f\", $new_cov_value*100}")
112-
printf "\$\\\\\\\\color{green}+%s\\\\\\\\\\\\\\\\%%\$\n" "$new_cov_percentage"
111+
awk "BEGIN {printf \"\$\\\\\\\\color{green}+%.2f\\\\\\\\%%\$\n\", $new_cov_value*100}"
113112
else
114113
percentage_change=$(awk "BEGIN {printf \"%.2f\", (($new_cov_value - $old_cov_value) / $old_cov_value) * 100}")
115114
color="green"
116-
sign=""
117-
if [ "$(awk "BEGIN {if ($percentage_change >= 0) print 1; else print 0}")" -eq 1 ]; then
118-
sign="+"
119-
elif [ "$(awk "BEGIN {if ($percentage_change < 0) print 1; else print 0}")" -eq 1 ]; then
120-
sign="-"
115+
sign="+"
116+
if [ "$(awk "BEGIN {if ($percentage_change < 0) print 1; else print 0}")" -eq 1 ]; then
121117
color="red"
118+
sign=""
122119
fi
123-
printf "\$\\\\\\\\color{%s}%s%s\\\\\\\\\\\\\\\\%%\$\n" "$color" "$sign" "$percentage_change"
120+
awk "BEGIN {print \"\$\\\\\\\\color{$color}${sign}${percentage_change}\\\\\\\\%\$\"}"
124121
fi
125122
}
126123

@@ -162,13 +159,13 @@ main() {
162159
pkg_functions_cov=${pkg_cov_values[2]}
163160
pkg_lines_cov=${pkg_cov_values[3]}
164161

165-
pkg_cov_fractions=($(cat $coverage_path | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{if ($1<$2) print "$\\\\\\\\color{red}" $0 "$"; else print "$\\\\\\\\color{green}" $0 "$"}'))
162+
pkg_cov_fractions=($(cat $coverage_path | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{if ($1<$2) print "$\\color{red}" $0 "$"; else print "$\\color{green}" $0 "$"}'))
166163
pkg_statements_cov_fraction=${pkg_cov_fractions[0]}
167164
pkg_branches_cov_fraction=${pkg_cov_fractions[1]}
168165
pkg_functions_cov_fraction=${pkg_cov_fractions[2]}
169166
pkg_lines_cov_fraction=${pkg_cov_fractions[3]}
170167

171-
old_cov_report=$(curl -s --fail "${coverage_base_url}/${pkg}/lib/index.html" 2>/dev/null || true)
168+
old_cov_report=$(curl -s --fail "${coverage_base_url}/${pkg}/index.html" 2>/dev/null || true)
172169
if [ -z "$old_cov_report" ]; then
173170
old_statements_cov=0
174171
old_branches_cov=0

0 commit comments

Comments
 (0)