2024-07-30 19:49:12 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit immediately if a command exits with a non-zero status
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Constants
|
|
|
|
IMAGE_NAME="quivr-core-test"
|
|
|
|
IMAGE_TAG="latest"
|
|
|
|
DOCKERFILE="Dockerfile.test"
|
|
|
|
VOLUME_MAPPING="$PWD:/code"
|
2024-08-01 16:54:43 +03:00
|
|
|
TOX_DIR="/code/.tox-docker"
|
|
|
|
CMD="poetry run tox -p auto"
|
2024-07-30 19:49:12 +03:00
|
|
|
|
|
|
|
# Functions
|
|
|
|
build_image() {
|
|
|
|
echo "Building Docker image..."
|
|
|
|
docker build -f $DOCKERFILE -t $IMAGE_NAME:$IMAGE_TAG .
|
|
|
|
}
|
|
|
|
|
|
|
|
run_container() {
|
|
|
|
echo "Running tests in Docker container..."
|
2024-08-01 16:54:43 +03:00
|
|
|
docker run -it --rm \
|
|
|
|
-e TOX_WORK_DIR=$TOX_DIR \
|
|
|
|
-v $VOLUME_MAPPING \
|
|
|
|
$IMAGE_NAME:$IMAGE_TAG $CMD
|
2024-07-30 19:49:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Main script execution
|
|
|
|
build_image
|
|
|
|
run_container
|
|
|
|
|
|
|
|
echo "Tests completed successfully."
|