Attempting to make the simulator deletion occur when the process is killed

pull/959/head
Morgan Pretty 1 year ago
parent 1371111c89
commit c56e6b03c6

@ -81,8 +81,7 @@ local update_cocoapods_cache(depends_on) = {
'touch /Users/drone/.cocoapods_cache.lock', 'touch /Users/drone/.cocoapods_cache.lock',
||| |||
if [[ -d ./Pods ]]; then if [[ -d ./Pods ]]; then
rm -rf /Users/drone/.cocoapods_cache rsync -a --delete ./Pods/ /Users/drone/.cocoapods_cache
cp -r ./Pods /Users/drone/.cocoapods_cache
fi fi
|||, |||,
'rm -f /Users/drone/.cocoapods_cache.lock' 'rm -f /Users/drone/.cocoapods_cache.lock'
@ -98,17 +97,43 @@ local pre_boot_test_sim = {
commands: [ commands: [
'mkdir -p build/artifacts', 'mkdir -p build/artifacts',
'echo "Test-iPhone14-${DRONE_COMMIT:0:9}-${DRONE_BUILD_EVENT}" > ./build/artifacts/device_name', 'echo "Test-iPhone14-${DRONE_COMMIT:0:9}-${DRONE_BUILD_EVENT}" > ./build/artifacts/device_name',
'xcrun simctl create "$(cat ./build/artifacts/device_name)" com.apple.CoreSimulator.SimDeviceType.iPhone-14', 'xcrun simctl create "$(<./build/artifacts/device_name)" com.apple.CoreSimulator.SimDeviceType.iPhone-14',
'echo $(xcrun simctl list devices | grep -m 1 $(cat ./build/artifacts/device_name) | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") > ./build/artifacts/sim_uuid', 'echo $(xcrun simctl list devices | grep -m 1 $(<./build/artifacts/device_name) | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") > ./build/artifacts/sim_uuid',
'xcrun simctl boot $(cat ./build/artifacts/sim_uuid)', 'xcrun simctl boot $(<./build/artifacts/sim_uuid)',
'echo "Pre-booting simulator complete: $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*$(cat ./build/artifacts/sim_uuid).*")"', 'echo "Pre-booting simulator complete: $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*$(<./build/artifacts/sim_uuid).*")"',
'echo "Number of Simulators: $(ls -1 /Users/drone/Library/Developer/CoreSimulator/Devices | wc -l)"',
]
};
local clean_up_test_simulator = {
name: 'Clean Up Test Simulator',
commands: [
|||
function handle_exit() {
xcrun simctl delete unavailable
if [ -e build/artifacts/sim_uuid ]; then
xcrun simctl delete $(<./build/artifacts/sim_uuid)
fi
exit 0
}
trap handle_exit EXIT
while true; do
sleep 10
done
|||
],
depends_on: [
'Pre-Boot Test Simulator',
] ]
}; };
local build_and_run_tests = { local build_and_run_tests = {
name: 'Build and Run Tests', name: 'Build and Run Tests',
commands: [ commands: [
'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(cat ./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci', 'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(<./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci',
], ],
depends_on: [ depends_on: [
'Pre-Boot Test Simulator', 'Pre-Boot Test Simulator',
@ -133,31 +158,6 @@ local unit_test_summary = {
} }
}; };
local delete_test_simulator = {
name: 'Delete Test Simulator',
commands: [
'xcrun simctl delete unavailable',
|||
if [[ -f ./build/artifacts/sim_uuid ]]; then
xcrun simctl delete $(cat ./build/artifacts/sim_uuid)
fi
|||,
|||
if [[ -z $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*2879BA18-1253-4EDC-B4AF-A21DAC3025DD.*") ]]; then
echo "Successfully deleted simulator."
else
echo "Failed to delete simulator!"
fi
|||
],
depends_on: [
'Build and Run Tests',
],
when: {
status: ['failure', 'skipped', 'killed', 'success']
}
};
[ [
// Unit tests (PRs only) // Unit tests (PRs only)
{ {
@ -172,9 +172,9 @@ local delete_test_simulator = {
load_cocoapods_cache, load_cocoapods_cache,
install_cocoapods, install_cocoapods,
pre_boot_test_sim, pre_boot_test_sim,
clean_up_test_simulator,
build_and_run_tests, build_and_run_tests,
unit_test_summary, unit_test_summary,
delete_test_simulator,
update_cocoapods_cache(['Build and Run Tests']) update_cocoapods_cache(['Build and Run Tests'])
], ],
}, },
@ -242,9 +242,9 @@ local delete_test_simulator = {
load_cocoapods_cache, load_cocoapods_cache,
install_cocoapods, install_cocoapods,
pre_boot_test_sim, pre_boot_test_sim,
clean_up_test_simulator,
build_and_run_tests, build_and_run_tests,
unit_test_summary, unit_test_summary,
delete_test_simulator,
update_cocoapods_cache(['Build and Run Tests']), update_cocoapods_cache(['Build and Run Tests']),
{ {
name: 'Install Codecov CLI', name: 'Install Codecov CLI',
@ -255,7 +255,7 @@ local delete_test_simulator = {
which codecovcli > ./build/artifacts/codecov_install_path which codecovcli > ./build/artifacts/codecov_install_path
fi fi
|||, |||,
'$(cat ./build/artifacts/codecov_install_path)/codecovcli --version' '$(<./build/artifacts/codecov_install_path)/codecovcli --version'
], ],
}, },
{ {
@ -269,7 +269,7 @@ local delete_test_simulator = {
name: 'Upload coverage to Codecov', name: 'Upload coverage to Codecov',
environment: { CODECOV_TOKEN: { from_secret: 'CODECOV_TOKEN' } }, environment: { CODECOV_TOKEN: { from_secret: 'CODECOV_TOKEN' } },
commands: [ commands: [
'$(cat ./build/artifacts/codecov_install_path)/codecovcli upload-process --fail-on-error -f ./build/artifacts/coverage.xml', '$(<./build/artifacts/codecov_install_path)/codecovcli upload-process --fail-on-error -f ./build/artifacts/coverage.xml',
], ],
depends_on: [ depends_on: [
'Convert xcresult to xml', 'Convert xcresult to xml',

Loading…
Cancel
Save