-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathaction.yml
More file actions
128 lines (117 loc) · 4.29 KB
/
Copy pathaction.yml
File metadata and controls
128 lines (117 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: 'Run xcodebuild'
description: 'Action runs `xcodebuild build` for the scheme specified'
inputs:
scheme:
required: true
type: string
project_path:
required: false
type: string
xcode_path:
required: false
type: string
destination:
required: false
type: string
default: 'platform=iOS Simulator,name=iPhone 17 Pro Max,OS=latest'
sdk:
required: false
type: string
default: 'iphonesimulator'
cloned_source_packages_path:
required: false
type: string
default: ''
derived_data_path:
required: false
type: string
default: ''
disable_package_resolution:
required: false
type: boolean
default: false
other_flags:
required: false
type: string
default: ''
runs:
using: "composite"
steps:
# See run_xcodebuild_test/action.yml for the full rationale. In short:
# resolution runs as its own bounded, retried, logged step so a slow git clone
# cannot masquerade as a hang and burn the job's entire timeout with no output.
- name: Resolve package dependencies for ${{ inputs.scheme }}
shell: bash
env:
PROJECT_PATH: ${{ inputs.project_path }}
XCODE_PATH: ${{ inputs.xcode_path }}
CLONED_SOURCE_PACKAGES_PATH: ${{ inputs.cloned_source_packages_path }}
RESOLVE_TIMEOUT_SECONDS: '1500'
run: |
set -o pipefail
if [ -n "$PROJECT_PATH" ]; then cd "$PROJECT_PATH"; fi
if [ -n "$XCODE_PATH" ]; then sudo xcode-select -s "$XCODE_PATH"; fi
clonedPath=()
if [ -n "$CLONED_SOURCE_PACKAGES_PATH" ]; then
clonedPath=(-clonedSourcePackagesDirPath "$CLONED_SOURCE_PACKAGES_PATH")
fi
resolve_bounded() {
xcodebuild -resolvePackageDependencies \
-scheme '${{ inputs.scheme }}' \
"${clonedPath[@]}" &
local pid=$!
( sleep "$RESOLVE_TIMEOUT_SECONDS"; kill -9 "$pid" 2>/dev/null ) &
local watchdog=$!
wait "$pid"
local status=$?
kill "$watchdog" 2>/dev/null || true
wait "$watchdog" 2>/dev/null || true
return $status
}
for attempt in 1 2 3; do
echo "::group::Resolving package dependencies (attempt $attempt of 3)"
start=$(date +%s)
if resolve_bounded; then
echo "::endgroup::"
echo "Dependencies resolved in $(( $(date +%s) - start ))s on attempt $attempt."
exit 0
fi
echo "::endgroup::"
echo "Attempt $attempt failed or exceeded ${RESOLVE_TIMEOUT_SECONDS}s after $(( $(date +%s) - start ))s."
if [ -n "$CLONED_SOURCE_PACKAGES_PATH" ]; then
rm -rf "${CLONED_SOURCE_PACKAGES_PATH%/}/repositories" || true
fi
done
echo "::error::Could not resolve package dependencies after 3 attempts. \
This is a dependency fetch problem, not a build failure."
exit 1
- name: Test ${{ inputs.scheme }}
env:
SCHEME: ${{ inputs.scheme }}
PROJECT_PATH: ${{ inputs.project_path }}
XCODE_PATH: ${{ inputs.xcode_path }}
CLONED_SOURCE_PACKAGES_PATH: ${{ inputs.cloned_source_packages_path }}
DERIVED_DATA_PATH: ${{ inputs.derived_data_path }}
run: |
if [ ! -z "$PROJECT_PATH" ]; then
cd $PROJECT_PATH
fi
if [ ! -z "$XCODE_PATH" ]; then
sudo xcode-select -s $XCODE_PATH
fi
otherFlags="${{ inputs.other_flags }}"
# Unconditionally disabled — the resolve step above already produced the
# checkouts, so xcodebuild must never resolve mid-build.
echo "Disabling Automatic Package Resolution"
otherFlags+=" -disableAutomaticPackageResolution"
if [ ! -z "$DERIVED_DATA_PATH" ]; then
echo "Using custom DerivedData path"
otherFlags+=" -derivedDataPath $DERIVED_DATA_PATH"
fi
if [ ! -z "$CLONED_SOURCE_PACKAGES_PATH" ]; then
echo "Using custom cloned source packages path"
otherFlags+=" -clonedSourcePackagesDirPath $CLONED_SOURCE_PACKAGES_PATH"
fi
xcodebuild -version
xcodebuild build -scheme $SCHEME -destination '${{ inputs.destination }}' -skipPackagePluginValidation $otherFlags | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
shell: bash