Skip to content

Commit

Permalink
Update cibuildwheel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Sep 7, 2023
1 parent 4dffb9d commit ea40cc3
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 25 deletions.
4 changes: 0 additions & 4 deletions scripts/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ python3 -c "import vizdoom"
# Run tests
pytest tests

# CMake manual build
# rm CMakeCache.txt
# cmake -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=ON .
# make -j
28 changes: 28 additions & 0 deletions scripts/build_and_test_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e

# Set working dir to the root of the repo
cd $( dirname "${BASH_SOURCE[0]}" )/..

# Report directory
ls -lha .

# Report cmake version
cmake --version

# Report gcc version
gcc --version

# Report python version
python --version
python -c "import sys; print('Python', sys.version)"

# Install
export VIZDOOM_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=/root/miniconda/"
python -m pip install .[test]

# Test import
python -c "import vizdoom"

# Run tests
pytest tests
5 changes: 4 additions & 1 deletion tests/build_test_cibuildwheel_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DOCKERFILES_DIR=$( dirname ${BASH_SOURCE[0]} )/wheels_test_dockerfiles
GENERATED_DOCKERFILES_DIR=tests/test_dockerfiles
IMAGE_PREFIX="vizdoom_wheels"

# Generate and run dockerfiles

# Array in format "<base docker image> <base dockerfile to use> <additional commands to add to the dockerfile after FROM statement>"
DOCKERFILES_TO_BUILD_AND_RUN=(
"almalinux:9 dnf-based.Dockerfile" # Python 3.9
Expand All @@ -22,6 +22,9 @@ DOCKERFILES_TO_BUILD_AND_RUN=(
"continuumio/miniconda3:latest conda-based.Dockerfile" # Python 3.10
)

# Build wheels using cibuildwheel
cibuildwheel --platform linux --arch $(uname -m)

function create_dockerfile ( ) {
local all_args=("$@")
local base_image=$1
Expand Down
14 changes: 5 additions & 9 deletions tests/build_test_local_linux_builds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DOCKERFILES_DIR=$( dirname ${BASH_SOURCE[0]} )/local_builds_dockerfiles
GENERATED_DOCKERFILES_DIR=tests/test_dockerfiles
IMAGE_PREFIX="vizdoom_local"

# Generate and run dockerfiles
# Array in format "<base docker image> <base dockerfile to use> <additional commands to add to the dockerfile after FROM statement>"
DOCKERFILES_TO_BUILD_AND_RUN=(
"almalinux:9 dnf-based.Dockerfile RUN dnf install -y 'dnf-command(config-manager)' && dnf config-manager --set-enabled crb"
Expand All @@ -20,15 +21,10 @@ DOCKERFILES_TO_BUILD_AND_RUN=(
"ubuntu:18.04 apt-based.Dockerfile"
"ubuntu:20.04 apt-based.Dockerfile"
"ubuntu:22.04 apt-based.Dockerfile"
"ubuntu:latest apt-based.Dockerfile"
#"continuumio/miniconda3:latest conda-based.Dockerfile" # Does not work at the moment
"ubuntu:20.04 apt+conda-based.Dockerfile" # Ubuntu build with dependencies installed via conda
#"continuumio/miniconda3:latest conda-based.Dockerfile" # Does not work at the moment
)


# Build wheels using cibuildwheel
cibuildwheel --platform linux --arch $(uname -m)


# Test wheels inside docker containers
function create_dockerfile ( ) {
local all_args=("$@")
Expand Down Expand Up @@ -56,8 +52,8 @@ for dockerfile_setting in "${DOCKERFILES_TO_BUILD_AND_RUN[@]}"; do
tag="${without_ext}:latest"
log="${dockerfile_dir}/${without_ext}.log"

docker build -t $tag -f $dockerfile . &> $log || ( echo -e "${RED}FAILED${NC}"; exit 1 )
docker run -it $tag &>> $log || ( echo -e "${RED}FAILED${NC}"; exit 1 )
docker build -t $tag -f $dockerfile . #&> $log || ( echo -e "${RED}FAILED${NC}"; exit 1 )
docker run -it $tag #&>> $log || ( echo -e "${RED}FAILED${NC}"; exit 1 )

echo -e "${GREEN}OK${NC}"
done
20 changes: 20 additions & 0 deletions tests/local_builds_dockerfiles/apt+conda-based.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:latest

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Warsaw

WORKDIR vizdoom

# Instal wget
RUN apt-get update && apt-get install -y build-essential git make cmake wget

# Install miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
RUN bash ~/miniconda.sh -b -p $HOME/miniconda
ENV PATH="/root/miniconda/bin:${PATH}"

# Install conda dependencies
RUN conda install -y -c conda-forge boost sdl2 openal-soft

COPY . ./
CMD ["bash", "./scripts/build_and_test_conda.sh"]
4 changes: 1 addition & 3 deletions tests/local_builds_dockerfiles/apt-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ ENV TZ=Europe/Warsaw

WORKDIR vizdoom

# MINIMAL
# Install minimal dependencies
RUN apt update && apt install -y build-essential cmake git libboost-all-dev libsdl2-dev libopenal-dev python3-dev python3-pip

# FULL
#RUN apt update && apt install -y build-essential cmake libboost-all-dev libsdl2-dev libfreetype-dev libopenal-dev python3-dev python3-pip

COPY . ./
Expand Down
5 changes: 2 additions & 3 deletions tests/local_builds_dockerfiles/conda-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ FROM continuumio/miniconda3:latest

WORKDIR vizdoom

# MINIMAL
RUN conda install -c conda-forge c-compiler cxx-compiler make cmake boost sdl2 openal-soft
RUN conda install -y -c conda-forge gcc gxx rhash make cmake boost sdl2 openal-soft

COPY . ./
CMD ["bash", "./scripts/build_and_test.sh"]
CMD ["bash", "./scripts/build_and_test_conda.sh"]
4 changes: 1 addition & 3 deletions tests/local_builds_dockerfiles/dnf-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ FROM fedora:latest

WORKDIR vizdoom

# MINIMAL
# Install minimal dependencies
RUN dnf update -y && dnf clean all && dnf install -y gcc gcc-c++ make cmake git boost-devel SDL2-devel openal-soft-devel python3-devel python3-pip

# FULL
#RUN dnf update -y && dnf clean all && dnf install -y gcc gcc-c++ make cmake boost-devel SDL2-devel freetype-devel openal-soft-devel python3-devel python3-pip

COPY . ./
Expand Down
2 changes: 1 addition & 1 deletion tests/wheels_test_dockerfiles/apt-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV TZ=Europe/Warsaw

WORKDIR vizdoom

# MINIMAL
# Install Python and pip
RUN apt update && apt install -y python3-dev python3-pip

COPY . ./
Expand Down
2 changes: 1 addition & 1 deletion tests/wheels_test_dockerfiles/dnf-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM fedora:latest

WORKDIR vizdoom

# MINIMAL
# Install Python and pip
RUN dnf update -y && dnf clean all && dnf install -y python3-devel python3-pip

COPY . ./
Expand Down

0 comments on commit ea40cc3

Please sign in to comment.