Skip to content

Commit

Permalink
Merge pull request #1201 from flatcar/krnowak/fix-image-changes
Browse files Browse the repository at this point in the history
Fix garbled output in image changes reports
  • Loading branch information
krnowak authored Sep 29, 2023
2 parents f44c3d3 + 876436f commit 1f5658e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ jobs:
)
show_changes_env=(
# Nothing to add.
"SCRIPTS_REPO=scripts"
"COREOS_OVERLAY_REPO=coreos-overlay"
"PORTAGE_STABLE_REPO=portage-stable"
)
show_changes_params_overrides=(
# We may not have a tag handy, so we tell show-changes
Expand Down
50 changes: 30 additions & 20 deletions ci-automation/image_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function image_changes() (
show_changes_env=(
# Provide a python3 command for the CVE DB parsing
"PATH=${PATH}:${PWD}/ci-automation/python-bin"
"SCRIPTS_REPO=scripts"
"COREOS_OVERLAY_REPO=coreos-overlay"
"PORTAGE_STABLE_REPO=portage-stable"
)
show_changes_params_overrides=(
# Nothing to override.
Expand All @@ -83,7 +86,7 @@ function image_changes() (
echo "Image URL: http://${BUILDCACHE_SERVER}/images/${arch}/${vernum}/flatcar_production_image.bin.bz2"
echo
generate_image_changes_report \
"${arch}" "${channel}" "${vernum}" /dev/stdout "${fbs_repo}" "${work_directory}" \
"${arch}" "${channel}" "${vernum}" '-' "${fbs_repo}" "${work_directory}" \
"${package_diff_env[@]}" --- "${package_diff_params_b[@]}" -- \
"${size_changes_env[@]}" --- "${size_changes_params_b[@]}" -- \
"${show_changes_env[@]}" --- "${show_changes_params_overrides[@]}"
Expand Down Expand Up @@ -177,14 +180,21 @@ function generate_image_changes_report() (
"${show_changes_params[@]}"
)

{
# Using "|| :" to avoid failing the job.
print_image_reports \
"${flatcar_build_scripts_repo}" "${channel_a}" "${version_a}" "${work_directory}" \
"${package_diff_env[@]}" --- "${package_diff_params[@]}" -- \
"${size_changes_env[@]}" --- "${size_changes_params[@]}" -- \
"${show_changes_env[@]}" --- "${show_changes_params[@]}" || :
} >"${report_output}"
local print_image_reports_invocation=(
print_image_reports
"${flatcar_build_scripts_repo}" "${channel_a}" "${version_a}" "${work_directory}"
"${package_diff_env[@]}" --- "${package_diff_params[@]}" --
"${size_changes_env[@]}" --- "${size_changes_params[@]}" --
"${show_changes_env[@]}" --- "${show_changes_params[@]}"
)
# Using "|| :" to avoid failing the job.
if [[ ${report_output} = '-' ]]; then
"${print_image_reports_invocation[@]}" || :
else
{
"${print_image_reports_invocation[@]}" || :
} >"${report_output}"
fi
)
# --

Expand Down Expand Up @@ -301,25 +311,25 @@ function print_image_reports() {
env \
--chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_packages.txt \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}"
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo
echo "Image file changes, compared to ${channel_a} ${version_a}:"
env \
--chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt FILESONLY=1 CUTKERNEL=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}"
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo
echo "Image kernel config changes, compared to ${channel_a} ${version_a}:"
env \
--chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_kernel_config.txt \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}"
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo
echo "Image init ramdisk file changes, compared to ${channel_a} ${version_a}:"
env \
--chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_initrd_contents.txt FILESONLY=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}"
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo

local size_changes_invocation=(
Expand All @@ -329,13 +339,13 @@ function print_image_reports() {
"${flatcar_build_scripts_repo}/size-change-report.sh"
)
echo "Image file size changes, compared to ${channel_a} ${version_a}:"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:wtd}"; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:old}"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:wtd}" 2>&1; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:old}" 2>&1
fi
echo
echo "Image init ramdisk file size changes, compared to ${channel_a} ${version_a}:"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-wtd}"; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-old}"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-wtd}" 2>&1; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-old}" 2>&1
fi
echo "Take the total size difference with a grain of salt as normally initrd is compressed, so the actual difference will be smaller."
echo "To see the actual difference in size, see if there was a report for /boot/flatcar/vmlinuz-a."
Expand All @@ -346,7 +356,7 @@ function print_image_reports() {
env \
--chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt CALCSIZE=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}"
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo

local param
Expand All @@ -359,15 +369,15 @@ function print_image_reports() {
"${show_changes_env[@]}" \
"${flatcar_build_scripts_repo}/show-changes" \
"${SHOW_CHANGES_NEW_CHANNEL}-${SHOW_CHANGES_NEW_CHANNEL_PREV_VERSION}" \
"${SHOW_CHANGES_NEW_VERSION}"
"${SHOW_CHANGES_NEW_VERSION}" 2>&1
# See if a channel transition happened and print the changelog against ${channel_a} ${version_a} which is the previous release
if [ "${channel_a}" != "${SHOW_CHANGES_NEW_CHANNEL}" ]; then
env \
--chdir "${work_directory}" \
"${show_changes_env[@]}" \
"${flatcar_build_scripts_repo}/show-changes" \
"${channel_a}-${version_a}" \
"${SHOW_CHANGES_NEW_VERSION}"
"${SHOW_CHANGES_NEW_VERSION}" 2>&1
fi
}
# --
Expand Down

0 comments on commit 1f5658e

Please sign in to comment.