Skip to content

Commit

Permalink
chore: scripts should propagate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Aug 1, 2023
1 parent 3cba0e8 commit fe78f05
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 138 deletions.
108 changes: 54 additions & 54 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ on:

pull_request:
paths:
- 'Sources/**'
- 'Tests/**'
- 'test-server/**'
- 'Samples/**'
- '.github/workflows/test.yml'
- 'fastlane/**'
- 'scripts/tests-with-thread-sanitizer.sh'
- 'scripts/ci-select-xcode.sh'
- 'scripts/xcode-test.sh'
- '.codecov.yml'
- "Sources/**"
- "Tests/**"
- "test-server/**"
- "Samples/**"
- ".github/workflows/test.yml"
- "fastlane/**"
- "scripts/tests-with-thread-sanitizer.sh"
- "scripts/ci-select-xcode.sh"
- "scripts/xcode-test.sh"
- ".codecov.yml"
- Sentry.xcodeproj

# run the workflow any time an Xcode scheme changes for a sample app
- 'Samples/tvOS-Swift/tvOS-Swift.xcodeproj/xcshareddata/xcschemes/tvOS-Swift.xcscheme'
- 'Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS13-Swift.xcscheme'
- 'Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-SwiftUITests.xcscheme'
- 'Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme'
- 'Samples/macOS-Swift/macOS-Swift.xcodeproj/xcshareddata/xcschemes/macOS-Swift.xcscheme'
- 'Samples/iOS-ObjectiveC/iOS-ObjectiveC.xcodeproj/xcshareddata/xcschemes/iOS-ObjectiveC.xcscheme'
- "Samples/tvOS-Swift/tvOS-Swift.xcodeproj/xcshareddata/xcschemes/tvOS-Swift.xcscheme"
- "Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS13-Swift.xcscheme"
- "Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-SwiftUITests.xcscheme"
- "Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme"
- "Samples/macOS-Swift/macOS-Swift.xcodeproj/xcshareddata/xcschemes/macOS-Swift.xcscheme"
- "Samples/iOS-ObjectiveC/iOS-ObjectiveC.xcodeproj/xcshareddata/xcschemes/iOS-ObjectiveC.xcscheme"

jobs:
build-test-server:
Expand Down Expand Up @@ -79,68 +79,67 @@ jobs:
matrix:
# Can't run tests on watchOS because XCTest is not available
include:

# iOS 13.7
- runs-on: macos-11
platform: 'iOS'
xcode: '13.2.1'
test-destination-os: '13.7'
platform: "iOS"
xcode: "13.2.1"
test-destination-os: "13.7"

# iOS 14
- runs-on: macos-11
platform: 'iOS'
xcode: '13.2.1'
test-destination-os: '14.5'
platform: "iOS"
xcode: "13.2.1"
test-destination-os: "14.5"

# iOS 15
- runs-on: macos-12
platform: 'iOS'
xcode: '13.4.1'
test-destination-os: 'latest'
platform: "iOS"
xcode: "13.4.1"
test-destination-os: "latest"

# iOS 16
- runs-on: macos-13
platform: 'iOS'
xcode: '14.3'
test-destination-os: 'latest'
platform: "iOS"
xcode: "14.3"
test-destination-os: "latest"

# macOS 11
- runs-on: macos-11
platform: 'macOS'
xcode: '13.2.1'
test-destination-os: 'latest'
platform: "macOS"
xcode: "13.2.1"
test-destination-os: "latest"

# macOS 12
- runs-on: macos-12
platform: 'macOS'
xcode: '13.4.1'
test-destination-os: 'latest'
platform: "macOS"
xcode: "13.4.1"
test-destination-os: "latest"

# macOS 13
- runs-on: macos-13
platform: 'macOS'
xcode: '14.3'
test-destination-os: 'latest'
platform: "macOS"
xcode: "14.3"
test-destination-os: "latest"

# Catalyst. We only test the latest version, as
# the risk something breaking on Catalyst and not
# on an older iOS or macOS version is low.
- runs-on: macos-13
platform: 'Catalyst'
xcode: '14.3'
test-destination-os: 'latest'
platform: "Catalyst"
xcode: "14.3"
test-destination-os: "latest"

# tvOS 15
- runs-on: macos-12
platform: 'tvOS'
xcode: '13.4.1'
test-destination-os: 'latest'
platform: "tvOS"
xcode: "13.4.1"
test-destination-os: "latest"

# tvOS 16
- runs-on: macos-13
platform: 'tvOS'
xcode: '14.3'
test-destination-os: 'latest'
platform: "tvOS"
xcode: "14.3"
test-destination-os: "latest"

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -180,7 +179,7 @@ jobs:
- name: Build tests
id: build_tests
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci build-for-testing

- name: Run tests
# We call a script with the platform so the destination
# passed to xcodebuild doesn't end up in the job name,
Expand Down Expand Up @@ -275,6 +274,7 @@ jobs:

- name: Archiving Test Logs
uses: actions/upload-artifact@v3
if: ${{ failure() || cancelled() }}
with:
path: thread-sanitizer.log

Expand All @@ -283,7 +283,7 @@ jobs:
runs-on: macos-13
strategy:
matrix:
target: ['ios_swift', 'ios_objc', 'tvos_swift']
target: ["ios_swift", "ios_objc", "tvos_swift"]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -312,12 +312,12 @@ jobs:
matrix:
include:
- runs-on: macos-12
xcode: '13.4.1'
device: 'iPhone 8 (15.2)'
xcode: "13.4.1"
device: "iPhone 8 (15.2)"

- runs-on: macos-13
xcode: '14.3'
device: 'iPhone 8 (16.1)'
xcode: "14.3"
device: "iPhone 8 (16.1)"

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion scripts/no-changes-in-high-risk-files.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euox pipefail
set -euxo pipefail

# To update the sha run the command in ACTUAL and copy the result in EXPECTED.

Expand Down
34 changes: 17 additions & 17 deletions scripts/pod-lib-lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -uox pipefail
set -euxo pipefail

PLATFORM="${1:-ios}"
POD_SPEC=${2:-Sentry}
Expand All @@ -9,28 +9,28 @@ EXTRA_ARGS=""

case $POD_SPEC in

"Sentry")
INCLUDE_POD_SPECS="--include-podspecs=SentryPrivate.podspec"
;;
"Sentry")
INCLUDE_POD_SPECS="--include-podspecs=SentryPrivate.podspec"
;;

"SentrySwiftUI")
INCLUDE_POD_SPECS="--include-podspecs={Sentry.podspec,SentryPrivate.podspec}"
;;
"SentrySwiftUI")
INCLUDE_POD_SPECS="--include-podspecs={Sentry.podspec,SentryPrivate.podspec}"
;;

*)
echo "pod lib lint: Can't find --include-podspecs for '$POD_SPEC'";
exit 1;
;;
*)
echo "pod lib lint: Can't find --include-podspecs for '$POD_SPEC'"
exit 1
;;
esac

case $LIBRARY_TYPE in
"static")
EXTRA_ARGS="--use-libraries"
;;
"static")
EXTRA_ARGS="--use-libraries"
;;

*)
EXTRA_ARGS=""
;;
*)
EXTRA_ARGS=""
;;
esac

pod lib lint --verbose --platforms="$PLATFORM" "$POD_SPEC".podspec "$INCLUDE_POD_SPECS" $EXTRA_ARGS
1 change: 1 addition & 0 deletions scripts/test-alamofire.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

# Ensure the swizzling of network classes doesn't break the normal functionality of web requests.
# We borrow the tests of Alamofire under the MIT license: https://github.com/Alamofire/Alamofire.
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-homekit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

# We borrow the tests of Home Assistant under the Apache license: https://github.com/home-assistant/iOS.
#The following steps checkout Home Assistant and apply a github patch to the project. The patch adds
Expand Down Expand Up @@ -43,4 +44,3 @@ bundle exec fastlane test

cd "$current_dir"
rm -f -r "./integration-test"

9 changes: 3 additions & 6 deletions scripts/tests-with-thread-sanitizer.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash
set -euo pipefail

# When enableThreadSanitizer is enabled and ThreadSanitizer finds an issue,
# When enableThreadSanitizer is enabled and ThreadSanitizer finds an issue,
# the logs only show failing tests, but don't highlight the threading issues.
# Therefore we print a hint to find the threading issues.

env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace -scheme Sentry -configuration Test -enableThreadSanitizer YES \
-destination "platform=iOS Simulator,OS=latest,name=iPhone 11" \
# The test works when having thread sanitizer not enabled, we have no clue why it fails, and threading issues will be caught
# even when it is disabled.
-skip-testing:"Sentry/SentrySessionTestsSwift/testInitWithJson_IfJsonContainsWrongValues_SessionIsNil" \
-destination "platform=iOS Simulator,OS=14.4,name=iPhone 11" \
test | tee thread-sanitizer.log | xcpretty -t

testStatus=$?
Expand Down
2 changes: 1 addition & 1 deletion scripts/upload-dsyms-with-xcode-build-phase.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -uox pipefail
set -euxo pipefail

# Use this script to apply a patch so Xcode uploads the iOS-Swift's dSYMs to
# Sentry during Xcode's build phase.
Expand Down
3 changes: 2 additions & 1 deletion scripts/xcode-slowest-tests.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
set -eu

# Finds the x amount of slowest test cases in the raw-test-output.log file.
# Logic copied from https://stanislaw.github.io/2016/08/04/how-to-find-the-slowest-xctest.html.

RAW_TEST_OUTPUT_LOG=${1:-raw-test-output.log}
NUMBER_OF_SLOWEST_TEST="${2:-20}"

echo "The $NUMBER_OF_SLOWEST_TEST slowest test cases:"
echo "The $NUMBER_OF_SLOWEST_TEST slowest test cases:"
cat $RAW_TEST_OUTPUT_LOG | grep 'Test\ Case.*seconds' | awk -F '[()]' '{print $2 " -> " $1}' | sort -rn | head -n $NUMBER_OF_SLOWEST_TEST
Loading

0 comments on commit fe78f05

Please sign in to comment.