From 5a167f45c724fb6f70ab69b5a4015303c43b8c93 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 17 Nov 2021 20:08:25 +0200 Subject: [PATCH 1/8] Rename Dockerfile.travis and prepare to the testing with tox --- packages/docker/Dockerfile.bionic | 79 +++++++------------------------ run-tests-in-docker.sh | 5 +- 2 files changed, 19 insertions(+), 65 deletions(-) diff --git a/packages/docker/Dockerfile.bionic b/packages/docker/Dockerfile.bionic index 3a201435..0dd3b5ad 100644 --- a/packages/docker/Dockerfile.bionic +++ b/packages/docker/Dockerfile.bionic @@ -1,61 +1,31 @@ -FROM ubuntu:bionic AS base +FROM ubuntu:bionic ENV DEBIAN_FRONTEND noninteractive -ENV TRAVIS_SKIP_APT_UPDATE 1 - -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 RUN apt-get update RUN apt-get install -yq --no-install-suggests --no-install-recommends \ software-properties-common -RUN dpkg --add-architecture i386 - -RUN add-apt-repository ppa:deadsnakes/ppa - -RUN apt-get -y install sudo +# RUN dpkg --add-architecture i386 RUN apt-get install -yq --no-install-suggests --no-install-recommends \ - # travis xenial bionic - python-setuptools libssl-dev libpq-dev python-prctl python-dev \ - python-dev python-virtualenv python-pip virtualenv \ - # dpkg - python-minimal python-setuptools python-all python openssl libssl-dev \ - dh-apparmor debhelper dh-python python-msgpack python-qt4 python-stdeb \ - python-all-dev python-crypto python-psutil \ - fakeroot python-pytest \ - # Code quality - pylint python-pycodestyle python3-pycodestyle pycodestyle python-flake8 \ - python3-flake8 flake8 python-pyflakes python3-pyflakes pyflakes pyflakes3 \ - curl \ - # Wine - python python-pip wget wine-stable winetricks mingw-w64 wine32 wine64 xvfb \ + # xenial bionic + build-essential libcap-dev libssl-dev python-all-dev python-pip \ # Buildbot - python3-dev libffi-dev python3-setuptools \ - python3-pip \ - # python 3.7 - python3.7 python3.7-dev \ - # .travis.yml - build-essential libcap-dev tor \ - language-pack-en - + libffi-dev python3-all-dev python3-pip \ + # Testing environment + language-pack-en \ + qtbase5-dev qt5-default tor tox xvfb \ + # dpkg + debhelper dh-apparmor dh-python fakeroot python-stdeb + # Wine + # wget wine-stable winetricks mingw-w64 wine32 wine64 # cleanup RUN rm -rf /var/lib/apt/lists/* -##################################################################################################### - -FROM base AS travis - -# travis2bash -RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh -RUN chmod +x /usr/local/bin/travis2bash.sh - RUN useradd -m -U builder -RUN echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # copy sources COPY . /home/builder/src @@ -63,25 +33,10 @@ RUN chown -R builder.builder /home/builder/src USER builder +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + WORKDIR /home/builder/src -ENTRYPOINT /usr/local/bin/travis2bash.sh - -##################################################################################################### - -FROM base AS buildbot - -# travis2bash -RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh -RUN chmod +x /usr/local/bin/travis2bash.sh - -# copy entrypoint -COPY packages/docker/buildbot-entrypoint.sh entrypoint.sh -RUN chmod +x entrypoint.sh - -RUN useradd -m -U buildbot -RUN echo 'buildbot ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -USER buildbot - -ENTRYPOINT /entrypoint.sh "$BUILDMASTER" "$WORKERNAME" "$WORKERPASS" +CMD ["tox"] diff --git a/run-tests-in-docker.sh b/run-tests-in-docker.sh index 9fa9bfcc..c3cdead5 100755 --- a/run-tests-in-docker.sh +++ b/run-tests-in-docker.sh @@ -1,5 +1,4 @@ #!/bin/bash -docker build --target travis -t pybm -f packages/docker/Dockerfile.bionic . -docker run pybm - +docker build -t pybm-test -f packages/docker/Dockerfile.bionic . +docker run pybm-test -- 2.45.1 From b67f86146e6dc68a04f8f8bfe2e7607b10685fc7 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 17 Nov 2021 20:35:53 +0200 Subject: [PATCH 2/8] Add bandit and flake8 lint run into tox.ini --- setup.cfg | 1 + tox.ini | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index a4e0547c..09db975f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,7 @@ max-line-length = 119 [flake8] max-line-length = 119 +exclude = bitmessagecli.py,bitmessagecurses,bitmessageqt,tests,umsgpack ignore = E722,F841,W503 # E722: pylint is preferred for bare-except # F841: pylint is preferred for unused-variable diff --git a/tox.ini b/tox.ini index 632c7381..4f566c22 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,16 @@ skip_install = true commands = python pybitmessage/bitmessagemain.py -t [testenv:reset] -deps = coverage -commands = coverage erase +deps = + coverage + bandit + flake8 +commands = + coverage erase + bandit -r --exit-zero -s B105,B301,B411,B413,B608 \ + -x checkdeps.*,bitmessagecurses,bitmessageqt,tests pybitmessage + flake8 pybitmessage --count --select=E9,F63,F7,F82 \ + --show-source --statistics [testenv:stats] deps = coverage -- 2.45.1 From e43ed6f6d3affd188c2529a6d73e8501ad330bea Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 17 Nov 2021 21:18:47 +0200 Subject: [PATCH 3/8] Remove container after running the tests --- run-tests-in-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests-in-docker.sh b/run-tests-in-docker.sh index c3cdead5..16f598a7 100755 --- a/run-tests-in-docker.sh +++ b/run-tests-in-docker.sh @@ -1,4 +1,4 @@ #!/bin/bash docker build -t pybm-test -f packages/docker/Dockerfile.bionic . -docker run pybm-test +docker run --rm pybm-test -- 2.45.1 From 89d2660b52ee19e1c70ff88b2b6c5002e9c295f1 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 17 Nov 2021 22:20:30 +0200 Subject: [PATCH 4/8] stdeb is installed with pip, but it needs python-setuptools and python-six --- packages/docker/Dockerfile.bionic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docker/Dockerfile.bionic b/packages/docker/Dockerfile.bionic index 0dd3b5ad..620d50ee 100644 --- a/packages/docker/Dockerfile.bionic +++ b/packages/docker/Dockerfile.bionic @@ -17,8 +17,8 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \ # Testing environment language-pack-en \ qtbase5-dev qt5-default tor tox xvfb \ - # dpkg - debhelper dh-apparmor dh-python fakeroot python-stdeb + # stdeb + debhelper dh-apparmor dh-python fakeroot python-setuptools python-six wget # Wine # wget wine-stable winetricks mingw-w64 wine32 wine64 -- 2.45.1 From a94ffef2797a1edf19e095bea33e62f76d32077e Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 18 Nov 2021 18:37:34 +0200 Subject: [PATCH 5/8] Upgrade virtualenv for python3 to reduce warnings --- packages/docker/Dockerfile.bionic | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/docker/Dockerfile.bionic b/packages/docker/Dockerfile.bionic index 620d50ee..58e7dcbe 100644 --- a/packages/docker/Dockerfile.bionic +++ b/packages/docker/Dockerfile.bionic @@ -27,6 +27,9 @@ RUN rm -rf /var/lib/apt/lists/* RUN useradd -m -U builder +RUN python3 -m pip install wheel +RUN python3 -m pip install --upgrade virtualenv + # copy sources COPY . /home/builder/src RUN chown -R builder.builder /home/builder/src -- 2.45.1 From 643e47bf153ceeff53657461cf02e301df1b0580 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 18 Nov 2021 19:25:32 +0200 Subject: [PATCH 6/8] Use tty for colorful output --- run-tests-in-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests-in-docker.sh b/run-tests-in-docker.sh index 16f598a7..f5809d58 100755 --- a/run-tests-in-docker.sh +++ b/run-tests-in-docker.sh @@ -1,4 +1,4 @@ #!/bin/bash docker build -t pybm-test -f packages/docker/Dockerfile.bionic . -docker run --rm pybm-test +docker run --rm -t pybm-test -- 2.45.1 From 4bd63f82d94531549d9e416f608191b14ae92925 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 18 Nov 2021 20:49:59 +0200 Subject: [PATCH 7/8] Install python3.8 for qt5 test --- packages/docker/Dockerfile.bionic | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/docker/Dockerfile.bionic b/packages/docker/Dockerfile.bionic index 58e7dcbe..1bbbc47f 100644 --- a/packages/docker/Dockerfile.bionic +++ b/packages/docker/Dockerfile.bionic @@ -22,13 +22,16 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \ # Wine # wget wine-stable winetricks mingw-w64 wine32 wine64 +RUN apt-get install -yq python3.8 python3.8-dev python3.8-venv + # cleanup RUN rm -rf /var/lib/apt/lists/* RUN useradd -m -U builder -RUN python3 -m pip install wheel -RUN python3 -m pip install --upgrade virtualenv +RUN python3.8 -m pip install wheel +RUN python3.8 -m pip install --upgrade tox +RUN python3.8 -m pip install --upgrade virtualenv # copy sources COPY . /home/builder/src -- 2.45.1 From 5bd0f00a9f234dae35e46b20b074c32eaf0a718e Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Fri, 19 Nov 2021 19:46:44 +0200 Subject: [PATCH 8/8] Cleanup the Dockerfile --- packages/docker/Dockerfile.bionic | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/docker/Dockerfile.bionic b/packages/docker/Dockerfile.bionic index 1bbbc47f..8df49225 100644 --- a/packages/docker/Dockerfile.bionic +++ b/packages/docker/Dockerfile.bionic @@ -10,28 +10,26 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \ # RUN dpkg --add-architecture i386 RUN apt-get install -yq --no-install-suggests --no-install-recommends \ - # xenial bionic - build-essential libcap-dev libssl-dev python-all-dev python-pip \ + # General build depends for xenial and bionic + build-essential libcap-dev libssl-dev python-all-dev python-setuptools \ # Buildbot - libffi-dev python3-all-dev python3-pip \ + libffi-dev python3-dev python3-pip python3.8 python3.8-dev python3.8-venv \ # Testing environment language-pack-en \ - qtbase5-dev qt5-default tor tox xvfb \ + python-pip qtbase5-dev qt5-default tor xvfb \ # stdeb - debhelper dh-apparmor dh-python fakeroot python-setuptools python-six wget + debhelper dh-apparmor dh-python fakeroot wget \ + python-msgpack python-qt4 python-six # Wine - # wget wine-stable winetricks mingw-w64 wine32 wine64 - -RUN apt-get install -yq python3.8 python3.8-dev python3.8-venv + # wine-stable winetricks mingw-w64 wine32 wine64 # cleanup RUN rm -rf /var/lib/apt/lists/* RUN useradd -m -U builder -RUN python3.8 -m pip install wheel -RUN python3.8 -m pip install --upgrade tox -RUN python3.8 -m pip install --upgrade virtualenv +RUN python3.8 -m pip install setuptools wheel +RUN python3.8 -m pip install --upgrade pip tox virtualenv # copy sources COPY . /home/builder/src -- 2.45.1