Commit dc52d490 authored by Petr Špaček's avatar Petr Špaček

CI: Test Python 2 & Python 3

parent ed29502e
......@@ -4,25 +4,25 @@ variables:
stages:
- test
test:pep8:
test:python2:pep8:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-pep8.sh /tmp
- /tmp/compare-pep8.sh
- PYTHON=python2 /tmp/compare-pep8.sh
tags:
- docker
- linux
- amd64
test:pylint:
test:python2:pylint:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-pylint.sh /tmp
- /tmp/compare-pylint.sh
- PYTHON=python2 /tmp/compare-pylint.sh
artifacts:
when: on_failure
expire_in: '1 hour'
......@@ -34,13 +34,64 @@ test:pylint:
- linux
- amd64
test:comparative:kresd:
test:python2:comparative:kresd:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-tests.sh /tmp
- /tmp/compare-tests.sh $(pwd)/kresd_run.sh
- PYTHON=python2 /tmp/compare-tests.sh $(pwd)/kresd_run.sh
artifacts:
when: always
expire_in: '1 hour'
paths:
- modified_tests
- base.log
- base.tests
- head.log
- head.tests
tags:
- docker
- linux
- amd64
test:python3:pep8:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-pep8.sh /tmp
- PYTHON=python3 /tmp/compare-pep8.sh
tags:
- docker
- linux
- amd64
test:python3:pylint:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-pylint.sh /tmp
- PYTHON=python3 /tmp/compare-pylint.sh
artifacts:
when: on_failure
expire_in: '1 hour'
paths:
- base.log
- head.log
tags:
- docker
- linux
- amd64
test:python3:comparative:kresd:
image: cznic/deckard-ci
stage: test
script:
- cp ci/common.sh /tmp
- cp ci/compare-tests.sh /tmp
- PYTHON=python3 /tmp/compare-tests.sh $(pwd)/kresd_run.sh
artifacts:
when: always
expire_in: '1 hour'
......
......@@ -8,4 +8,6 @@ CMD ["/bin/bash"]
# we do not care that much about particular version
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y knot-resolver pep8 pylint
RUN apt-get install -y knot-resolver
RUN apt-get install -y python-pep8 pylint python-dnspython python-jinja2
RUN apt-get install -y python3-pep8 pylint3 python3-dnspython python3-jinja2
......@@ -3,6 +3,7 @@ set -o errexit -o nounset
HEAD="$(git log -1 --format="%H" HEAD)"
MERGEBASE="$(git merge-base origin/master "${HEAD}")"
LOGDIR="$(pwd)"
PYTHON=${PYTHON:-"python"}
# workaround for Gitlab's missing support for absolute paths in artifacts:
# https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1011
......
......@@ -2,4 +2,4 @@
set -o nounset -o xtrace -o errexit
source "$(dirname "$(readlink -f "$0")")/common.sh"
git diff "${MERGEBASE}..${HEAD}" | pep8 --ignore=W503 --diff --show-source --max-line-length=100 && echo "OK, no PEP8 errors detected"
git diff "${MERGEBASE}..${HEAD}" | ${PYTHON} -m pep8 --ignore=W503 --diff --show-source --max-line-length=100 && echo "OK, no PEP8 errors detected"
......@@ -8,7 +8,7 @@ PYFILES=$(find . \
-type f -exec grep -qsm1 '^#!.*\bpython' '{}' \; -print)
: check if version under test does not produce critical errors
pylint -E ${PYFILES}
${PYTHON} -m pylint -E ${PYFILES}
: no critical errors, compare score between versions
rm -rf ~/.pylint.d
......@@ -20,7 +20,7 @@ PYFILES=$(find . \
-type d -exec test -e '{}/__init__.py' \; -print -prune -o \
-name '*.py' -print -o \
-type f -exec grep -qsm1 '^#!.*\bpython' '{}' \; -print)
pylint ${PYFILES} &> /tmp/base.log || : old version is not clear
${PYTHON} -m pylint ${PYFILES} &> /tmp/base.log || : old version is not clear
LOGS[0]="/tmp/base.log"
echo ==================== merge base ====================
cat /tmp/base.log
......@@ -29,7 +29,7 @@ echo ==================== merge base end ====================
: get test results from version under test
git checkout --force --detach "${HEAD}"
git clean -xdf
pylint ${PYFILES} &> /tmp/head.log || : version under test is not clear
${PYTHON} -m pylint ${PYFILES} &> /tmp/head.log || : version under test is not clear
LOGS[1]="/tmp/base.log"
echo ==================== candidate version ====================
cat /tmp/head.log
......
......@@ -36,7 +36,7 @@ LOGS[0]="${MODIFIED_TESTS_FILE}"
export MAKEFLAGS="--output-sync=target --keep-going -j$(nproc)"
: get test results from version under test
"${TESTRUNNER}" &> /tmp/head.log || :
PYTHON=${PYTHON} "${TESTRUNNER}" &> /tmp/head.log || :
LOGS[1]="/tmp/head.log"
extract_test_results /tmp/head.log | filter_test_results &> /tmp/head.tests || (: "no tests left, huh?" && cat /tmp/head.log)
LOGS[2]="/tmp/head.tests"
......@@ -44,7 +44,7 @@ LOGS[2]="/tmp/head.tests"
: get test results from common ancestor with master branch
git checkout --force --detach "${MERGEBASE}"
git clean -xdf
"${TESTRUNNER}" &> /tmp/base.log || :
PYTHON=${PYTHON} "${TESTRUNNER}" &> /tmp/base.log || :
LOGS[3]="/tmp/base.log"
extract_test_results /tmp/base.log | filter_test_results &> /tmp/base.tests || (: "no tests left, huh?" && cat /tmp/base.log)
LOGS[4]="/tmp/base.tests"
......
......@@ -19,15 +19,22 @@ test -n "${STATUS}" && echo "Working tree is dirty, commit your changes now." &&
trap checkout_back EXIT
trap "{ FAILURE_DETECTED=1; }" ERR
"${CIDIR}"/compare-pylint.sh
checkout_back
git clean -xdf
"${CIDIR}"/compare-pep8.sh
checkout_back
git clean -xdf
"${CIDIR}"/compare-tests.sh "${CIDIR}/../kresd_run.sh"
for PYTHON in python2 python3
do
export PYTHON
"${CIDIR}"/compare-pylint.sh
checkout_back
git clean -xdf
"${CIDIR}"/compare-pep8.sh
checkout_back
git clean -xdf
"${CIDIR}"/compare-tests.sh "${CIDIR}/../kresd_run.sh"
checkout_back
git clean -xdf
done
# at this point all the tests passed so we can clean up
git clean -xdf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment