From 05ad8d875ec6633f8b8f01aac9ecf82f4560df00 Mon Sep 17 00:00:00 2001 From: Liam Sturge Date: Fri, 3 Feb 2023 16:49:26 +0000 Subject: [PATCH] Fix build platform environment variable Certain tests that make use of `pytest_wrapper.py`, such as those triggered by `task_python_integration.sh` will fail when a "PLATFORM" environment variable is not set within the Docker container. When using `build.sh` to both create a container, and run a command to execute one of the tests that requires a "PLATFORM", an error will occur due to the missing environment variable. This patch is necessary to add support for this environment variable to `build.sh` and prevent such errors. --- docker/build.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docker/build.sh b/docker/build.sh index 75f0e35c6c7b..123365c8f0a0 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -25,11 +25,15 @@ # [--net=host] [--cache-from ] [--cache] # [--name CONTAINER_NAME] [--context-path ] # [--spec DOCKER_IMAGE_SPEC] +# [--platform ] # [] # # CONTAINER_TYPE: Type of the docker container used the run the build, # e.g. "ci_cpu", "ci_gpu" # +# BUILD_PLATFORM: (Optional) Type of build platform used for the build, +# e.g. "arm", "cpu", "gpu". Defaults to "cpu". +# # DOCKER_IMAGE_TAG: (Optional) Docker image tag to be built and used. # Defaults to 'latest', as it is the default Docker tag. # @@ -119,6 +123,14 @@ if [[ "$1" == "--name" ]]; then shift 2 fi +PLATFORM="cpu" + +if [[ "$1" == "--platform" ]]; then + PLATFORM="$2" + echo "Using build platform: ${PLATFORM}" + shift 2 +fi + if [[ ! -f "${DOCKERFILE_PATH}" ]]; then echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\"" exit 1 @@ -227,6 +239,7 @@ if [[ -n ${COMMAND} ]]; then -e "CI_BUILD_GID=$(id -g)" \ -e "CI_PYTEST_ADD_OPTIONS=$CI_PYTEST_ADD_OPTIONS" \ -e "CI_IMAGE_NAME=${DOCKER_IMAGE_NAME}" \ + -e "PLATFORM=${PLATFORM}" \ ${CUDA_ENV}\ ${CI_DOCKER_EXTRA_PARAMS[@]} \ ${DOCKER_IMG_SPEC} \