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