-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for wheels built using cibuildwheel
- Loading branch information
Showing
11 changed files
with
147 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/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 python version | ||
python3 --version | ||
python3 -c "import sys; print('Python', sys.version)" | ||
|
||
# Find matching wheel file in wheelhouse | ||
PYTHON_VERSION=$(python3 -c "import sys; print('{}{}'.format(sys.version_info.major, sys.version_info.minor))") | ||
PYTHON_WHEEL=$(ls wheelhouse/vizdoom-*-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}*.whl) | ||
|
||
# Updgrade pip and install test deps | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install pytest psutil | ||
|
||
# Install wheel | ||
python3 -m pip install ${PYTHON_WHEEL} | ||
|
||
# Test import | ||
python3 -c "import vizdoom" | ||
|
||
# Run tests | ||
pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Tests | ||
|
||
This directory contains the tests for the project that can be run with pytest or by running the `test_*.py` or `manual_test_*.py` files directly. | ||
Manual tests require significant amount of time, so they are not run by default by CI/CD. | ||
The `build_test_*.sh` scripts test the build process of the project under different distrubutions and enviroments. To run them docker and cibuildwheels is required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
NC='\033[0m' | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
|
||
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 | ||
"fedora:36 dnf-based.Dockerfile" # Python 3.10 | ||
"fedora:37 dnf-based.Dockerfile" # Python 3.11 | ||
"rockylinux:9 dnf-based.Dockerfile" # Python 3.9 | ||
"debian:11.6 apt-based.Dockerfile ENV LANG C.UTF-8" # Python 3.9 | ||
"ubuntu:20.04 apt-based.Dockerfile" # Python 3.8 | ||
"ubuntu:22.04 apt-based.Dockerfile" # Python 3.10 | ||
"continuumio/miniconda3:latest conda-based.Dockerfile" # Python 3.10 | ||
) | ||
|
||
function create_dockerfile ( ) { | ||
local all_args=("$@") | ||
local base_image=$1 | ||
local base_name=$( basename "$( echo ${base_image} | tr ':' '_' )" ) | ||
local base_dockerfile=$2 | ||
local add_commands=("${all_args[@]:2}") | ||
|
||
mkdir -p $GENERATED_DOCKERFILES_DIR | ||
dockerfile=${GENERATED_DOCKERFILES_DIR}/${IMAGE_PREFIX}_${base_name}.Dockerfile | ||
|
||
echo "FROM $base_image" > $dockerfile | ||
echo "" >> $dockerfile | ||
echo -e "${add_commands[@]}" >> $dockerfile | ||
cat ${DOCKERFILES_DIR}/$base_dockerfile | tail -n +2 >> $dockerfile | ||
} | ||
|
||
for dockerfile_setting in "${DOCKERFILES_TO_BUILD_AND_RUN[@]}"; do | ||
create_dockerfile $dockerfile_setting | ||
|
||
echo -n "Building and running $dockerfile, saving output to $dockerfile.log ... " | ||
filename=$( basename "$dockerfile" ) | ||
dockerfile_dir=$( dirname "$dockerfile" ) | ||
without_ext="${filename%.*}" | ||
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 ) | ||
|
||
echo -e "${GREEN}OK${NC}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM ubuntu:latest | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Europe/Warsaw | ||
|
||
WORKDIR vizdoom | ||
|
||
# MINIMAL | ||
RUN apt update && apt install -y python3-dev python3-pip | ||
|
||
COPY . ./ | ||
CMD ["bash", "./scripts/install_and_test_wheel.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM continuumio/miniconda3:latest | ||
|
||
WORKDIR vizdoom | ||
|
||
COPY . ./ | ||
CMD ["bash", "./scripts/install_and_test_wheel.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM fedora:latest | ||
|
||
WORKDIR vizdoom | ||
|
||
# MINIMAL | ||
RUN dnf update -y && dnf clean all && dnf install -y python3-devel python3-pip | ||
|
||
COPY . ./ | ||
CMD ["bash", "./scripts/install_and_test_wheel.sh"] |