Changeset - 28d44a25c785
[Not reviewed]
0 4 0
Branko Majic (branko) - 7 years ago 2017-05-01 18:02:35
branko@majic.rs
MAR-102: Fixed pip_check_requirements_upgrades.sh to sort both new and current requirements to avoid reporting false positives due to difference in ordering from pip-compile and sort -u. Used --upgrade option when running pip-compile to make sure upgrades are actually checked. Updated wsgihello2 to be more useful in testing the script.
4 files changed with 18 insertions and 9 deletions:
0 comments (0 inline, 0 general)
roles/common/files/pip_check_requirements_upgrades.sh
Show inline comments
 
@@ -122,24 +122,24 @@ fi
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    if [[ $debug != 0 ]]; then
 
        echo "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
        echo -e "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
    fi
 
}
 

	
 
function info() {
 
    echo "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
 
    echo -e "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
 
}
 

	
 
function success() {
 
    echo "${_text_bold}${_text_green}[OK]   ${_text_reset}" "$@"
 
    echo -e "${_text_bold}${_text_green}[OK]   ${_text_reset}" "$@"
 
}
 

	
 
function warning() {
 
    echo "${_text_bold}${_text_yellow}[WARN] ${_text_reset}" "$@"
 
    echo -e "${_text_bold}${_text_yellow}[WARN] ${_text_reset}" "$@"
 
}
 

	
 
function error() {
 
    echo "${_text_bold}${_text_red}[ERROR]${_text_reset}" "$@" >&2
 
    echo -e "${_text_bold}${_text_red}[ERROR]${_text_reset}" "$@" >&2
 
}
 

	
 
# Clean-up command for temporary files.
 
@@ -147,7 +147,7 @@ function on_exit() {
 
    debug "Cleaning-up temporary file: $tmp_current"
 
    [[ -f $tmp_current ]] && rm "$tmp_current"
 

	
 
    debug "Cleaning-up temporayr file: $tmp_new"
 
    debug "Cleaning-up temporary file: $tmp_new"
 
    [[ -f $tmp_new ]] && rm "$tmp_new"
 
}
 
trap on_exit EXIT
 
@@ -247,11 +247,16 @@ 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 --no-header --no-annotate --no-index --output-file "$tmp_new" "$req_in" > /dev/null; then
 
	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
 
	    error "Failed while running pip-compile command against (see error stack trace above): $req_in"
 
	    continue
 
	fi
 

	
 
        debug "Current requirements:\n$(cat "$tmp_current")"
 
        debug "New requirements:\n$(cat "$tmp_new")"
 

	
 
	# Run diff, storing the output and result.
 
	diff=$(diff -u "$tmp_current" "$tmp_new")
 
	result="$?"
testsite/playbooks/roles/wsgihello2/files/requirements.in
Show inline comments
 
ipcalc
 
\ No newline at end of file
 
django-apptemplates
 
ipcalc
 
django~=1.8.0
testsite/playbooks/roles/wsgihello2/files/requirements.txt
Show inline comments
 
django-apptemplates==1.2
 
ipcalc==1.1.3
 
django==1.8.16
testsite/playbooks/roles/wsgihello2/meta/main.yml
Show inline comments
 
@@ -13,7 +13,7 @@ dependencies:
 
    environment_variables:
 
      WEBSITE_NAME: "Majic Ansible Roles Test Site"
 
    wsgi_requirements:
 
      - futures==3.0.1
 
      - futures==3.1.1
 
      - gunicorn==19.6.0
 
  - role: database
 
    db_name: wsgi_{{ testsite_domain_underscores }}
0 comments (0 inline, 0 general)