view scripts/validate-commits @ 8687:5e46f73f0d1c

model: always import the whole db module - drop "from" imports
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 12 Oct 2020 11:12:37 +0200
parents 68861940ee1e
children 0a9ddb8cd8c1
line wrap: on
line source

#!/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

revset=$1
if [ -z "$revset" ]; then
    echo "Warning: no revisions specified, checking draft changes up to the current one."
    revset='draft() and ancestors(.)'
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 "$revset" -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
    if ! scripts/run-all-cleanup ; then
        echo "run-all-cleanup encountered errors!"
        result="NOK"
    else
        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