From fc681f3b6c160cba3c05ea01c75dfa12e178e86c Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Fri, 14 Jul 2023 10:12:42 +0200 Subject: [PATCH] Test virtualenvs and build envs --- .drone.yml | 30 ++++---------------- examples/{test_input.py => example_input.py} | 0 pytest.ini | 2 +- scripts/build_archlinux.sh | 0 scripts/build_ubuntu.sh | 9 ++++++ scripts/test.sh | 18 ++++++++++++ 6 files changed, 33 insertions(+), 26 deletions(-) rename examples/{test_input.py => example_input.py} (100%) create mode 100644 scripts/build_archlinux.sh create mode 100644 scripts/build_ubuntu.sh create mode 100755 scripts/test.sh diff --git a/.drone.yml b/.drone.yml index d8ce678..b38e32b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,16 +25,7 @@ steps: image: archlinux_build:latest pull: if-not-exists commands: - # The following command is not required, we included this in the docker - # image of archlinux_build - # - pacman -S --noconfirm openblas python-pytest fftw pulseaudio python-pip python-scipy python-h5py - - pip install -r requirements.txt - - pip install . - - pytest - - # - name: release-arch - # commands: - # - + - scripts/test.sh volumes: - name: archlinux_ccache @@ -60,27 +51,16 @@ steps: volumes: - name: ubuntu_ccache path: /root/.ccache + environment: commands: # The following commands are not required, we included this in the docker - # image of ubuntu_build - #- apt update - #- apt install -y git cmake python3-pybind11 libopenblas-dev python3-pip python3-scipy libusb-1.0-0-dev libpulse-dev python3-h5py fftw-dev - - git submodule update --init --recursive - - cmake . - # More than two makes ascee2 irresponsive for now - - make -j2 - + # image of ubuntu_builud + - scripts/build_ubuntu.sh - name: ubuntu_test image: ubuntu_build:latest pull: if-not-exists commands: - # The following commands are not required, we included this in the docker - # image of ubuntu_build - #- apt update - #- apt install -y python3-pytest fftw pulseaudio python3-pip python3-scipy python3-h5py - - pip install -r requirements.txt - - pip install . - - pytest-3 + - scripts/test.sh volumes: - name: ubuntu_ccache diff --git a/examples/test_input.py b/examples/example_input.py similarity index 100% rename from examples/test_input.py rename to examples/example_input.py diff --git a/pytest.ini b/pytest.ini index 8a234a3..2979acd 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts = "--ignore=third_party" +addopts = "--ignore=third_party --ignore=examples" diff --git a/scripts/build_archlinux.sh b/scripts/build_archlinux.sh new file mode 100644 index 0000000..e69de29 diff --git a/scripts/build_ubuntu.sh b/scripts/build_ubuntu.sh new file mode 100644 index 0000000..df0363e --- /dev/null +++ b/scripts/build_ubuntu.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +apt update +apt install -y python3-venv +git submodule update --init --recursive + +cmake . +# More than two processes creates too much load +make -j2 diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..4d33f1b --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,18 @@ +#/bin/sh +# This script is run in the CI/CD system to test the code. +python3 -m venv testenv + +# Activate environment +. testenv/bin/activate + +pip install -r requirements.txt +pip install . + +arch_os_line='NAME="Arch Linux"' +if [[ $(sed -n "/^${arch_os_line}/p;q" /etc/os-release) == ${arch_os_line} ]]; then + # Arch Linux + pytest +else + # Not Arch Linux, assuming Ubuntu + pytest-3 +fi