Skip to content

Commit c022218

Browse files
authored
Make all $HELIX_ env vars available in Apple workloads (#7869)
1 parent 0b38c9e commit c022218

2 files changed

Lines changed: 9 additions & 24 deletions

File tree

src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.apple.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ set -x
2828
# It is important we call the script via `launchctl asuser` in order to be able to spawn
2929
# the simulator which needs to run in a user session with GUI rendering capabilities.
3030
# The problem with launchctl is that the spawned process won't share environment variables
31-
# so we have to pass all of them as parameters are set them again.
31+
# so we have to set them again.
32+
export -p > envvars
3233
chmod +x xharness-runner.apple.sh
3334
helix_runner_uid=$(id -u)
3435
sudo launchctl asuser "$helix_runner_uid" sh ./xharness-runner.apple.sh \
3536
$forwarded_args \
3637
--app "$HELIX_WORKITEM_ROOT/$app" \
37-
--xharness-cli-path "$XHARNESS_CLI_PATH" \
3838
--output-directory "$HELIX_WORKITEM_UPLOAD_ROOT" \
3939
--diagnostics-path "$XHARNESS_DIAGNOSTICS_PATH" \
4040

src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-runner.apple.sh

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
###
88

99
app=''
10-
output_directory=''
1110
target=''
1211
timeout=''
1312
launch_timeout=''
14-
xharness_cli_path=''
1513
xcode_version=''
1614
app_arguments=''
1715
expected_exit_code=0
@@ -25,10 +23,6 @@ while [[ $# -gt 0 ]]; do
2523
app="$2"
2624
shift
2725
;;
28-
--output-directory)
29-
output_directory="$2"
30-
shift
31-
;;
3226
--diagnostics-path)
3327
export XHARNESS_DIAGNOSTICS_PATH="$2"
3428
shift
@@ -45,10 +39,6 @@ while [[ $# -gt 0 ]]; do
4539
launch_timeout="$2"
4640
shift
4741
;;
48-
--xharness-cli-path)
49-
xharness_cli_path="$2"
50-
shift
51-
;;
5242
--xcode-version)
5343
xcode_version="$2"
5444
shift
@@ -85,20 +75,18 @@ if [ -z "$target" ]; then
8575
die "No target was provided";
8676
fi
8777

88-
if [ -z "$output_directory" ]; then
89-
die "No output directory provided";
90-
fi
91-
92-
if [ -z "$xharness_cli_path" ]; then
93-
die "XHarness path wasn't provided";
94-
fi
95-
9678
if [ -z "$xcode_version" ]; then
9779
xcode_path="$(dirname "$(dirname "$(xcode-select -p)")")"
9880
else
9981
xcode_path="/Applications/Xcode${xcode_version/./}.app"
10082
fi
10183

84+
# First we need to revive env variables since they were erased by launchctl
85+
# This file already has the expressions in the `export name=value` format
86+
. ./envvars
87+
88+
output_directory=$HELIX_WORKITEM_UPLOAD_ROOT
89+
10290
# Signing
10391
if [ "$target" == 'ios-device' ] || [ "$target" == 'tvos-device' ]; then
10492
echo "Real device target detected, application will be signed"
@@ -141,12 +129,9 @@ elif [[ "$target" =~ "simulator" ]]; then
141129
open -a "$simulator_app"
142130
fi
143131

144-
export XHARNESS_DISABLE_COLORED_OUTPUT=true
145-
export XHARNESS_LOG_WITH_TIMESTAMPS=true
146-
147132
# The xharness alias
148133
function xharness() {
149-
dotnet exec $xharness_cli_path "$@"
134+
dotnet exec $XHARNESS_CLI_PATH "$@"
150135
}
151136

152137
# Act out the actual commands

0 commit comments

Comments
 (0)