-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·55 lines (43 loc) · 1.46 KB
/
test.sh
File metadata and controls
executable file
·55 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e -o xtrace
# Allows us to run from a relative path
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd ${DIR}
# permit overriding the container name (for avoiding name clashes)
if [[ -z "$CONTAINER_NAME" ]]; then
CONTAINER_NAME=`basename $PWD-test`
fi
# Make sure we clean up
function finish() {
echo "Cleaning up...."
# Remove the container when we're done
docker rm -f ${CONTAINER_NAME} || true
# Go back to original dir
popd
}
trap finish EXIT
IMAGE_TAG=goodbc_python_test_build-${CONTAINER_NAME}
if [ -z "${SKIP_BUILD}" ]; then
DOCKER_BUILDKIT=1 docker build --tag ${IMAGE_TAG} -f Dockerfile_test_build .
fi
DOCKER_CMD="py.test -v -s"
if [ "$#" -gt 0 ]; then
echo "Using command from args"
DOCKER_CMD=$@
fi
# Define MOUNT_WORKSPACE to mount this workspace inside the docker container
WORKSPACE_VOLUME=""
if [ ! -z "${MOUNT_WORKSPACE}" ]; then
WORKSPACE_VOLUME="-v `pwd`:/workspace"
fi
# run the tests / shell
docker run --name ${CONTAINER_NAME} --rm -d ${WORKSPACE_VOLUME} ${IMAGE_TAG} tail -F /dev/null
docker exec -it -e MSSQL_PASSWORD ${CONTAINER_NAME} ${DOCKER_CMD}
# extract the package for deployment
NAME=$(cat setup.py | grep 'name=' | xargs | cut -d '=' -f 2 | tr -d ',')
VERSION=$(cat setup.py | grep 'version=' | xargs | cut -d '=' -f 2 | tr -d ',')
PACKAGE="${NAME}-${VERSION}"
docker cp ${CONTAINER_NAME}:/workspace/dist/${PACKAGE}.tar.gz .
echo "Deployable package follows:"
ls -al ${PACKAGE}.tar.gz
echo ""