Skip to content

Commit

Permalink
ci: Split building and running tests (#2945)
Browse files Browse the repository at this point in the history
Split building and running tests into two different jobs in CI,
so we know how long each one of them takes.
  • Loading branch information
philipphofmann authored Apr 24, 2023
1 parent eed479f commit 102f2a6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,17 @@ jobs:
- name: Install Slather
run: gem install slather

# We split building and running tests in two steps so we know how long running the tests takes.
- name: Build tests
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci build-for-testing

- name: Running tests
- name: Run tests
# We call a script with the platform so the destination
# passed to xcodebuild doesn't end up in the job name,
# because GitHub Actions don't provide an easy way of
# manipulating string in expressions.
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci test-without-building

- name: Archiving DerivedData Logs
uses: actions/upload-artifact@v3
Expand Down
43 changes: 39 additions & 4 deletions scripts/xcode-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PLATFORM="${1}"
OS=${2:-latest}
REF_NAME="${3-HEAD}"
IS_LOCAL_BUILD="${4:-ci}"
COMMAND="${5:-test}"
DESTINATION=""
CONFIGURATION=""

Expand Down Expand Up @@ -58,7 +59,41 @@ case $IS_LOCAL_BUILD in
;;
esac

env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \
-scheme Sentry -configuration $CONFIGURATION \
-destination "$DESTINATION" \
test | tee raw-test-output.log | $RUBY_ENV_ARGS xcpretty -t && slather coverage --configuration $CONFIGURATION && exit ${PIPESTATUS[0]}
case $COMMAND in
"build-for-testing")
RUN_BUILD_FOR_TESTING=true
RUN_TEST_WITHOUT_BUILDING=false
;;
"test-without-building")
RUN_BUILD_FOR_TESTING=false
RUN_TEST_WITHOUT_BUILDING=true
;;
*)
RUN_BUILD_FOR_TESTING=true
RUN_TEST_WITHOUT_BUILDING=true
;;
esac

if [ $RUN_BUILD_FOR_TESTING == true ]; then
# build everything for testing
env NSUnbufferedIO=YES xcodebuild \
-workspace Sentry.xcworkspace \
-scheme Sentry \
-configuration $CONFIGURATION \
-destination "$DESTINATION" -quiet \
build-for-testing
fi

if [ $RUN_TEST_WITHOUT_BUILDING == true ]; then
# run the tests
env NSUnbufferedIO=YES xcodebuild \
-workspace Sentry.xcworkspace \
-scheme Sentry \
-configuration $CONFIGURATION \
-destination "$DESTINATION" \
test-without-building \
| tee raw-test-output.log \
| $RUBY_ENV_ARGS xcpretty -t \
&& slather coverage --configuration $CONFIGURATION \
&& exit ${PIPESTATUS[0]}
fi

0 comments on commit 102f2a6

Please sign in to comment.