1#!/bin/bash 2 3# shellcheck source=./common.sh 4source "$(dirname "${BASH_SOURCE[0]}")/common.sh" 5 6# Workaround for dind-rootless userid mapping (https://github.com/pytorch/ci-infra/issues/96) 7WORKSPACE_ORIGINAL_OWNER_ID=$(stat -c '%u' "/var/lib/jenkins/workspace") 8cleanup_workspace() { 9 echo "sudo may print the following warning message that can be ignored. The chown command will still run." 10 echo " sudo: setrlimit(RLIMIT_STACK): Operation not permitted" 11 echo "For more details refer to https://github.com/sudo-project/sudo/issues/42" 12 sudo chown -R "$WORKSPACE_ORIGINAL_OWNER_ID" /var/lib/jenkins/workspace 13} 14# Disable shellcheck SC2064 as we want to parse the original owner immediately. 15# shellcheck disable=SC2064 16trap_add cleanup_workspace EXIT 17sudo chown -R jenkins /var/lib/jenkins/workspace 18git config --global --add safe.directory /var/lib/jenkins/workspace 19 20if [[ "$BUILD_ENVIRONMENT" == *onnx* ]]; then 21 # TODO: This can be removed later once vision is also part of the Docker image 22 pip install -q --user --no-use-pep517 "git+https://github.com/pytorch/vision.git@$(cat .github/ci_commit_pins/vision.txt)" 23 # JIT C++ extensions require ninja, so put it into PATH. 24 export PATH="/var/lib/jenkins/.local/bin:$PATH" 25 # NB: ONNX test is fast (~15m) so it's ok to retry it few more times to avoid any flaky issue, we 26 # need to bring this to the standard PyTorch run_test eventually. The issue will be tracked in 27 # https://github.com/pytorch/pytorch/issues/98626 28 "$ROOT_DIR/scripts/onnx/test.sh" 29fi 30