Changeset - d9514fba012b
[Not reviewed]
0 1 0
Branko Majic (branko) - 7 years ago 2017-05-01 18:19:43
branko@majic.rs
MAR-102: Refactored the check to ensure pip-compile exit code is properly verified.
1 file changed with 10 insertions and 5 deletions:
0 comments (0 inline, 0 general)
roles/common/files/pip_check_requirements_upgrades.sh
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)