From d9514fba012b9c543f002bca9fb328aeebcdd752 2017-05-01 18:19:43 From: Branko Majic Date: 2017-05-01 18:19:43 Subject: [PATCH] MAR-102: Refactored the check to ensure pip-compile exit code is properly verified. --- diff --git a/roles/common/files/pip_check_requirements_upgrades.sh b/roles/common/files/pip_check_requirements_upgrades.sh index 965b4034b5777e9ee32a39f15746fdde0c63bf37..066850624ea2ecfb4e11b0c0c3db42b9877ee5e0 100755 --- a/roles/common/files/pip_check_requirements_upgrades.sh +++ b/roles/common/files/pip_check_requirements_upgrades.sh @@ -149,6 +149,9 @@ function on_exit() { debug "Cleaning-up temporary file: $tmp_new" [[ -f $tmp_new ]] && rm "$tmp_new" + + debug "Cleaning-up temporary file: $tmp_new_sorted" + [[ -f $tmp_new_sorted ]] && rm "$tmp_new_sorted" } trap on_exit EXIT @@ -221,6 +224,7 @@ fi # stored. tmp_current=$(mktemp) tmp_new=$(mktemp) +tmp_new_sorted=$(mktemp) # Process each environment. for environment in "$config_dir"/*; do @@ -247,18 +251,19 @@ for environment in "$config_dir"/*; do # Deploy the existing requirements file and the new one. sed -e 's/[[:blank:]]*#.*//' "$req_txt" | grep -v "^$" | sort -u > "$tmp_current" - if ! pip-compile --upgrade --dry-run --no-header --no-annotate --no-index "$req_in" 2>&1 | \ - grep -v 'Dry-run' | sed -e 's/[[:blank:]]*#.*//' | grep -v "^$" | \ - sort -u > "$tmp_new" ; then + if ! pip-compile --no-header --no-annotate --no-index --output-file "$tmp_new" --upgrade "$req_in" > /dev/null; then error "Failed while running pip-compile command against (see error stack trace above): $req_in" continue fi + # Sort the new requirements file. + sed -e 's/[[:blank:]]*#.*//' "$tmp_new" | grep -v "^$" | sort -u > "$tmp_new_sorted" + debug "Current requirements:\n$(cat "$tmp_current")" - debug "New requirements:\n$(cat "$tmp_new")" + debug "New requirements:\n$(cat "$tmp_new_sorted")" # Run diff, storing the output and result. - diff=$(diff -u "$tmp_current" "$tmp_new") + diff=$(diff -u "$tmp_current" "$tmp_new_sorted") result="$?" # Show warning about available updates.