Skip to content

Commit

Permalink
Migrated tox tests to Bionic on Docker (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Feb 23, 2019
1 parent 65a407f commit 284fe25
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 37 deletions.
76 changes: 48 additions & 28 deletions .travis.yml
Expand Up @@ -30,68 +30,88 @@ matrix:
python: 3.5 python: 3.5
virtualenv: virtualenv:
system_site_packages: true system_site_packages: true
- name: "Ubuntu Xenial (16.04) with Python 2.7 and tox" - name: "Fedora Core 29 (Docker) with Python 2.7"
env: [TARGET="linux-python27-tox", TOXENV="py27"] env: FEDORA_VERSION="29"
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 2.7 python: 2.7
virtualenv: services:
system_site_packages: false - docker
- name: "Ubuntu Xenial (16.04) with Python 3.4 and tox" - name: "Fedora Core 29 (Docker) with Python 3.7"
env: [TARGET="linux-python34-tox", TOXENV="py34"] env: FEDORA_VERSION="29"
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 3.4 python: 3.7
virtualenv: services:
system_site_packages: false - docker
- name: "Ubuntu Xenial (16.04) with Python 3.5 and tox" - name: "Ubuntu Bionic (18.04) (Docker) with Python 2.7"
env: [TARGET="linux-python35-tox", TOXENV="py35"] env: UBUNTU_VERSION="18.04"
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 3.5 python: 2.7
virtualenv: services:
system_site_packages: false - docker
- name: "Ubuntu Xenial (16.04) with Python 3.6 and tox" - name: "Ubuntu Bionic (18.04) (Docker) with Python 3.6"
env: [TARGET="linux-python36-tox", TOXENV="py36"] env: UBUNTU_VERSION="18.04"
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 3.6 python: 3.6
virtualenv: services:
system_site_packages: false - docker
- name: "Ubuntu Xenial (16.04) with Python 3.7 and tox" - name: "Ubuntu Bionic (18.04) (Docker) with Python 2.7 and tox"
env: [TARGET="linux-python37-tox", TOXENV="py37"] env: [TOXENV="py27", UBUNTU_VERSION="18.04"]
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 3.7 python: 2.7
virtualenv: services:
system_site_packages: false - docker
- name: "Fedora Core 29 (Docker) with Python 2.7" - name: "Ubuntu Bionic (18.04) (Docker) with Python 3.4 and tox"
env: FEDORA_VERSION="29" env: [TOXENV="py34", UBUNTU_VERSION="18.04"]
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
group: edge group: edge
language: python language: python
python: 2.7 python: 3.4
services: services:
- docker - docker
- name: "Fedora Core 29 (Docker) with Python 3.7" - name: "Ubuntu Bionic (18.04) (Docker) with Python 3.5 and tox"
env: FEDORA_VERSION="29" env: [TOXENV="py35", UBUNTU_VERSION="18.04"]
os: linux
dist: xenial
sudo: required
group: edge
language: python
python: 3.5
services:
- docker
- name: "Ubuntu Bionic (18.04) (Docker) with Python 3.6 and tox"
env: [TOXENV="py36", UBUNTU_VERSION="18.04"]
os: linux
dist: xenial
sudo: required
group: edge
language: python
python: 3.6
services:
- docker
- name: "Ubuntu Bionic (18.04) (Docker) with Python 3.7 and tox"
env: [TOXENV="py37", UBUNTU_VERSION="18.04"]
os: linux os: linux
dist: xenial dist: xenial
sudo: required sudo: required
Expand Down
3 changes: 2 additions & 1 deletion artifacts/reader.py
Expand Up @@ -5,6 +5,7 @@


import abc import abc
import glob import glob
import io
import os import os
import json import json
import yaml import yaml
Expand Down Expand Up @@ -281,7 +282,7 @@ def ReadFile(self, filename):
Yields: Yields:
ArtifactDefinition: an artifact definition. ArtifactDefinition: an artifact definition.
""" """
with open(filename, 'r') as file_object: with io.open(filename, 'r', encoding='utf-8') as file_object:
for artifact_definition in self.ReadFileObject(file_object): for artifact_definition in self.ReadFileObject(file_object):
yield artifact_definition yield artifact_definition


Expand Down
43 changes: 40 additions & 3 deletions config/travis/install.sh
Expand Up @@ -11,11 +11,11 @@ L2TBINARIES_TEST_DEPENDENCIES="funcsigs mock pbr six";


DPKG_PYTHON2_DEPENDENCIES="python-yaml"; DPKG_PYTHON2_DEPENDENCIES="python-yaml";


DPKG_PYTHON2_TEST_DEPENDENCIES="python-coverage python-funcsigs python-mock python-pbr python-six python-tox"; DPKG_PYTHON2_TEST_DEPENDENCIES="python-coverage python-funcsigs python-mock python-pbr python-six";


DPKG_PYTHON3_DEPENDENCIES="python3-yaml"; DPKG_PYTHON3_DEPENDENCIES="python3-yaml";


DPKG_PYTHON3_TEST_DEPENDENCIES="python3-mock python3-pbr python3-setuptools python3-six python3-tox"; DPKG_PYTHON3_TEST_DEPENDENCIES="python3-mock python3-pbr python3-setuptools python3-six";


RPM_PYTHON2_DEPENDENCIES="python2-pyyaml"; RPM_PYTHON2_DEPENDENCIES="python2-pyyaml";


Expand Down Expand Up @@ -62,13 +62,50 @@ then


docker exec ${CONTAINER_NAME} dnf copr -y enable @gift/dev; docker exec ${CONTAINER_NAME} dnf copr -y enable @gift/dev;


if test ${TRAVIS_PYTHON_VERSION} = "2.7"; if test -n "${TOXENV}";
then
docker exec ${CONTAINER_NAME} dnf install -y python3-tox;

elif test ${TRAVIS_PYTHON_VERSION} = "2.7";
then then
docker exec ${CONTAINER_NAME} dnf install -y git python2 ${RPM_PYTHON2_DEPENDENCIES} ${RPM_PYTHON2_TEST_DEPENDENCIES}; docker exec ${CONTAINER_NAME} dnf install -y git python2 ${RPM_PYTHON2_DEPENDENCIES} ${RPM_PYTHON2_TEST_DEPENDENCIES};
else else
docker exec ${CONTAINER_NAME} dnf install -y git python3 ${RPM_PYTHON3_DEPENDENCIES} ${RPM_PYTHON3_TEST_DEPENDENCIES}; docker exec ${CONTAINER_NAME} dnf install -y git python3 ${RPM_PYTHON3_DEPENDENCIES} ${RPM_PYTHON3_TEST_DEPENDENCIES};
fi fi


docker cp ../artifacts ${CONTAINER_NAME}:/

elif test -n "${UBUNTU_VERSION}";
then
CONTAINER_NAME="ubuntu${UBUNTU_VERSION}";

docker pull ubuntu:${UBUNTU_VERSION};

docker run --name=${CONTAINER_NAME} --detach -i ubuntu:${UBUNTU_VERSION};

docker exec ${CONTAINER_NAME} apt-get update -q;
docker exec ${CONTAINER_NAME} sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common";

docker exec ${CONTAINER_NAME} add-apt-repository ppa:gift/dev -y;

if test -n "${TOXENV}";
then
docker exec ${CONTAINER_NAME} add-apt-repository universe;
docker exec ${CONTAINER_NAME} add-apt-repository ppa:deadsnakes/ppa -y;

DPKG_PYTHON="python${TRAVIS_PYTHON_VERSION}";

docker exec ${CONTAINER_NAME} sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y ${DPKG_PYTHON} tox";

elif test ${TRAVIS_PYTHON_VERSION} = "2.7";
then
docker exec ${CONTAINER_NAME} sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y git python ${DPKG_PYTHON2_DEPENDENCIES} ${DPKG_PYTHON2_TEST_DEPENDENCIES}";
else
docker exec ${CONTAINER_NAME} sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 ${DPKG_PYTHON3_DEPENDENCIES} ${DPKG_PYTHON3_TEST_DEPENDENCIES}";
fi

docker cp ../artifacts ${CONTAINER_NAME}:/

elif test ${TRAVIS_OS_NAME} = "linux" && test ${TARGET} != "jenkins"; elif test ${TRAVIS_OS_NAME} = "linux" && test ${TARGET} != "jenkins";
then then
sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list; sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list;
Expand Down
25 changes: 21 additions & 4 deletions config/travis/runtests.sh
Expand Up @@ -42,13 +42,30 @@ elif test -n "${FEDORA_VERSION}";
then then
CONTAINER_NAME="fedora${FEDORA_VERSION}"; CONTAINER_NAME="fedora${FEDORA_VERSION}";


docker exec "${CONTAINER_NAME}" sh -c "git clone https://github.com/ForensicArtifacts/artifacts.git"; if test -n "${TOXENV}";
then
docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && tox -e ${TOXENV}";

elif test ${TRAVIS_PYTHON_VERSION} = "2.7";
then
docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && python2 run_tests.py";
else
docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && python3 run_tests.py";
fi

elif test -n "${UBUNTU_VERSION}";
then
CONTAINER_NAME="ubuntu${UBUNTU_VERSION}";

if test -n "${TOXENV}";
then
docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && tox -e ${TOXENV}";


if test ${TRAVIS_PYTHON_VERSION} = "2.7"; elif test ${TRAVIS_PYTHON_VERSION} = "2.7";
then then
docker exec "${CONTAINER_NAME}" sh -c "cd artifacts && python2 run_tests.py"; docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && python2 run_tests.py";
else else
docker exec "${CONTAINER_NAME}" sh -c "cd artifacts && python3 run_tests.py"; docker exec ${CONTAINER_NAME} sh -c "export LANG=en_US.UTF-8; cd artifacts && python3 run_tests.py";
fi fi


elif test "${TRAVIS_OS_NAME}" = "linux"; elif test "${TRAVIS_OS_NAME}" = "linux";
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -124,7 +124,7 @@ def _make_spec_file(self):
elif line.startswith('%files'): elif line.startswith('%files'):
python_spec_file.extend([ python_spec_file.extend([
'%package -n %{name}-tools', '%package -n %{name}-tools',
'Requires: python-artifacts', 'Requires: {0:s}-artifacts'.format(python_package),
'Summary: Tools for {0:s}'.format(summary), 'Summary: Tools for {0:s}'.format(summary),
'', '',
'%description -n %{name}-tools']) '%description -n %{name}-tools'])
Expand Down

0 comments on commit 284fe25

Please sign in to comment.