Changeset - bf85e6018daa
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 6 years ago 2020-03-07 20:48:02
thomas.de_schampheleire@nokia.com
scripts: properly check for errors in whitespacecleanup/run-all-cleanup

An error in whitespacecleanup, like a bug in isort that raises an exception,
should be treated as a problem instead of silently ignored.
2 files changed with 11 insertions and 7 deletions:
0 comments (0 inline, 0 general)
scripts/validate-commits
Show inline comments
 
#!/bin/bash
 
# Validate the specified commits against test suite and other checks.
 

	
 
if [ -n "$VIRTUAL_ENV" ]; then
 
    echo "Please run this script from outside a virtualenv."
 
    exit 1
 
fi
 

	
 
if ! hg update --check -q .; then
 
    echo "Working dir is not clean, please commit/revert changes first."
 
    exit 1
 
fi
 

	
 
venv=$(mktemp -d kallithea-validatecommits-env-XXXXXX)
 
resultfile=$(mktemp kallithea-validatecommits-result-XXXXXX)
 
echo > "$resultfile"
 

	
 
cleanup()
 
{
 
    rm -rf /tmp/kallithea-test*
 
    rm -rf "$venv"
 
}
 
finish()
 
{
 
    cleanup
 
    # print (possibly intermediate) results
 
    cat "$resultfile"
 
    rm "$resultfile"
 
}
 
trap finish EXIT
 

	
 
for rev in $(hg log -r "$1" -T '{node}\n'); do
 
    hg log -r "$rev"
 
    hg update "$rev"
 

	
 
    cleanup
 
    python3 -m venv "$venv"
 
    source "$venv/bin/activate"
 
    pip install --upgrade pip setuptools
 
    pip install -e . -r dev_requirements.txt python-ldap python-pam
 

	
 
    # run-all-cleanup
 
    scripts/run-all-cleanup
 
    if ! hg update --check -q .; then
 
        echo "run-all-cleanup did not give clean results!"
 
    if ! scripts/run-all-cleanup ; then
 
        echo "run-all-cleanup encountered errors!"
 
        result="NOK"
 
        hg diff
 
        hg revert -a
 
    else
 
        result=" OK"
 
        if ! hg update --check -q .; then
 
            echo "run-all-cleanup did not give clean results!"
 
            result="NOK"
 
            hg diff
 
            hg revert -a
 
        else
 
            result=" OK"
 
        fi
 
    fi
 
    echo "$result: $rev (run-all-cleanup)" >> "$resultfile"
 

	
 
    # pytest
 
    if py.test; then
 
        result=" OK"
 
    else
 
        result="NOK"
 
    fi
 
    echo "$result: $rev (pytest)" >> "$resultfile"
 

	
 
    deactivate
 
    echo
 
done
scripts/whitespacecleanup.sh
Show inline comments
 
#!/bin/bash -x
 
#!/bin/bash -xe
 

	
 
# Enforce some consistency in whitespace - just to avoid spurious whitespaces changes
 

	
 
files=`hg mani | egrep -v '/fontello/|/email_templates/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`
 

	
 
sed -i "s/`printf '\r'`//g" $files
 
sed -i -e "s,`printf '\t'`,    ,g" $files
 
sed -i -e "s,  *$,,g" $files
 
sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
 
# ensure one trailing newline - remove empty last line and make last line include trailing newline:
 
sed -i -e '$,${/^$/d}' -e '$a\' $files
 

	
 
sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
 
sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`
 

	
 
hg mani | xargs chmod -x
 
hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x
 

	
 
# isort is installed from dev_requirements.txt
 
hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs isort --line-width 160 --lines-after-imports 2
 

	
 
echo "diff after $0:"
 
hg diff
0 comments (0 inline, 0 general)