I have a script which properly spins up a database for testing on my local machine.
I’m trying to make Xcode test pre-actions execute that, with no success.
When it reaches a line like “open -a Docker”, it successfully opens up Docker, but if you try to execute any Docker commands, e.g. “docker run”, either nothing will happen, or it will hang (not sure which one, probably both of those are related to the command just not working at all, and how the script is set up.)
Is there any hope?
The solution was to 1- Repair the PATH that is passed to the script by:
# Update PATH incase it's run from Xcode scripts.
PATH="$PATH:/usr/local/bin/:/opt/homebrew/bin/"
And also take the BASE_DIR from the script itself:
# Take an argument for BASE_DIR, incase this is run from Xcode scripts.
if [ "$1" != "" ]; then
note "Got BASE_DIR argument: $1"
BASE_DIR=$1
fi
The Xcode-pre-script would calculate the BASE_DIR someway like this, and pass it to the script:
BASE_DIR=${WORKSPACE_PATH%%/.swiftpm*}
cd $BASE_DIR
echo "note: Xcode script calculated BASE_DIR to be $BASE_DIR"
. ./scripts/<name>.command $BASE_DIR || true