@@ -217,11 +217,21 @@ jobs:
217217
218218 unit-tests :
219219 name : Unit ${{matrix.name}}
220- runs-on : ${{matrix.runs-on}}
221- timeout-minutes : ${{ matrix.timeout || 20 }}
222220 needs : files-changed
223- if : needs.files-changed.outputs.run_unit_tests_for_prs == 'true'
224-
221+ uses : ./.github/workflows/unit-test-common.yml
222+ secrets : inherit
223+ with :
224+ name : ${{matrix.name}}
225+ runs-on : ${{matrix.runs-on}}
226+ should_skip : ${{needs.files-changed.outputs.run_unit_tests_for_prs != 'true'}}
227+ xcode : ${{matrix.xcode}}
228+ platform : ${{matrix.platform}}
229+ test-destination-os : ${{matrix.test-destination-os || 'latest'}}
230+ timeout : ${{matrix.timeout || 20}}
231+ create_device : ${{matrix.create_device || false}}
232+ install_platforms : ${{matrix.install_platforms || false}}
233+ device : ${{matrix.device || ''}}
234+ scheme : ${{matrix.scheme || 'Sentry'}}
225235 strategy :
226236 fail-fast : false
227237 matrix :
@@ -359,172 +369,6 @@ jobs:
359369 device : " Apple TV"
360370 scheme : " Sentry"
361371
362- steps :
363- - uses : actions/checkout@v5
364- - run : ./scripts/ci-select-xcode.sh ${{matrix.xcode}}
365-
366- - name : Install Slather
367- run : gem install slather
368-
369- # Install platform runtimes that are not included by default
370- # For iOS 16.4: Not included with Xcode 15.4 on macOS-14 (macOS-13 sunset)
371- # For iOS/tvOS 26.1: Beta platforms not included by default
372- - name : Install required platforms
373- if : ${{ matrix.install_platforms }}
374- run : ./scripts/ci-install-platforms.sh --platforms "${{ matrix.platform }}" --os-version "${{ matrix.test-destination-os }}"
375-
376- # Create simulator devices for non-preinstalled simulators
377- # Required for iOS 16.4, iOS 17.5 (on Xcode 15.4), and iOS/tvOS 26.1
378- - name : Create simulator device
379- if : ${{ matrix.create_device }}
380- run : ./scripts/ci-create-simulator.sh --platform "${{ matrix.platform }}" --os-version "${{ matrix.test-destination-os }}" --device-name "${{ matrix.device }}"
381-
382- # Boot created simulators to ensure they're ready before tests run
383- # Based on CircleCI forum comment, booting is especially important for Xcode 26: https://discuss.circleci.com/t/xcode-26-rc/54066/18
384- - name : Boot simulator
385- if : ${{ matrix.create_device && matrix.platform == 'iOS' }}
386- run : ./scripts/ci-boot-simulator.sh --xcode ${{ matrix.xcode }} --device "${{ matrix.device }}" --os-version "${{ matrix.test-destination-os }}"
387-
388- # We split building and running tests in two steps so we know how long running the tests takes.
389- - name : Build Tests
390- id : build_tests
391- run : |
392- ./scripts/sentry-xcodebuild.sh \
393- --platform ${{matrix.platform}} \
394- --os ${{matrix.test-destination-os}} \
395- --ref ${{ github.ref_name }} \
396- --command build-for-testing \
397- --device "${{matrix.device}}" \
398- --configuration TestCI \
399- --scheme ${{matrix.scheme}}
400-
401- # Run Flaky Tests TestPlan which has a retry mechanism on failure.
402- # We intentionally run these before the other test plan to fail early.
403- # Use a separate result bundle name to avoid conflicts with the regular test run.
404- # xcodebuild fails if a result bundle already exists at the target path.
405- - name : Run Flaky Tests
406- # Only the Sentry Scheme has the Flaky TestPlan.
407- if : ${{ matrix.scheme == 'Sentry' }}
408- run : |
409- ./scripts/sentry-xcodebuild.sh \
410- --platform ${{matrix.platform}} \
411- --os ${{matrix.test-destination-os}} \
412- --ref ${{ github.ref_name }} \
413- --command test-without-building \
414- --device "${{matrix.device}}" \
415- --configuration TestCI \
416- --scheme ${{matrix.scheme}} \
417- --test-plan Sentry_Flaky \
418- --result-bundle flaky-results.xcresult
419-
420- - name : Run tests
421- # We call a script with the platform so the destination
422- # passed to xcodebuild doesn't end up in the job name,
423- # because GitHub Actions don't provide an easy way of
424- # manipulating string in expressions.
425- run : |
426- ./scripts/sentry-xcodebuild.sh \
427- --platform ${{matrix.platform}} \
428- --os ${{matrix.test-destination-os}} \
429- --ref ${{ github.ref_name }} \
430- --command test-without-building \
431- --device "${{matrix.device}}" \
432- --configuration TestCI \
433- --scheme ${{matrix.scheme}} \
434- --result-bundle results.xcresult
435-
436- - name : Publish Test Report
437- uses : mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6 # v6.0.1
438- if : always()
439- with :
440- report_paths : " build/reports/junit.xml"
441- fail_on_failure : true
442- fail_on_parse_error : true
443- detailed_summary : true
444-
445- - name : Archiving DerivedData Logs
446- uses : actions/upload-artifact@v5
447- if : steps.build_tests.outcome == 'failure'
448- with :
449- name : derived-data-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
450- path : |
451- /Users/runner/Library/Developer/Xcode/DerivedData/**/Logs/**
452-
453- - name : Archiving Raw Logs
454- uses : actions/upload-artifact@v5
455- if : ${{ failure() || cancelled() }}
456- with :
457- name : raw-output-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
458- path : |
459- raw-build-output.log
460- raw-build-for-testing-output.log
461- raw-test-output.log
462-
463- - name : Archiving Crash Logs
464- uses : actions/upload-artifact@v5
465- if : ${{ failure() || cancelled() }}
466- with :
467- name : crash-logs-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
468- path : |
469- ~/Library/Logs/DiagnosticReports/**
470-
471- - name : Archiving Test Results
472- uses : actions/upload-artifact@v5
473- if : ${{ failure() || cancelled() }}
474- with :
475- name : result-bundle-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
476- path : |
477- results.xcresult
478- flaky-results.xcresult
479-
480- - name : Gather code coverage information via slather
481- run : slather coverage --configuration TestCI --scheme Sentry
482-
483- # We can upload all coverage reports, because codecov merges them.
484- # See https://docs.codecov.io/docs/merging-reports
485- # Checkout .codecov.yml to see the config of Codecov
486- # We don't upload codecov for release branches, as we don't want a failing coverage check to block a release.
487- # We don't upload codecov for scheduled runs as CodeCov only accepts a limited amount of uploads per commit.
488- - name : Push code coverage to codecov
489- id : codecov_1
490- uses :
codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # [email protected] 491- if : ${{ contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
492- with :
493- # Although public repos should not have to specify a token there seems to be a bug with the Codecov GH action, which can
494- # be solved by specifying the token, see https://github.com/codecov/codecov-action/issues/557#issuecomment-1224970469
495- token : ${{ secrets.CODECOV_TOKEN }}
496- fail_ci_if_error : false
497- verbose : true
498-
499- # Sometimes codecov uploads etc can fail. Retry one time to rule out e.g. intermittent network failures.
500- - name : Push code coverage to codecov
501- id : codecov_2
502- uses :
codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # [email protected] 503- if : ${{ steps.codecov_1.outcome == 'failure' && contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
504- with :
505- token : ${{ secrets.CODECOV_TOKEN }}
506- fail_ci_if_error : true
507- verbose : true
508-
509- - name : Codecov test analytics
510- if : ${{ !cancelled() && !contains(github.ref, 'release') && github.event.schedule == '' }}
511- uses :
codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # [email protected] 512- with :
513- token : ${{ secrets.CODECOV_TOKEN }}
514- verbose : true
515- name : sentry-cocoa-unit-tests
516- flags : unittests-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.test-destination-os }}, unittests
517-
518- - name : Run CI Diagnostics
519- if : failure()
520- run : ./scripts/ci-diagnostics.sh
521-
522- - name : Store screenshot
523- uses : ./.github/actions/capture-screenshot
524- if : failure()
525- with :
526- suffix : unit-tests-${{ matrix.platform }}-xcode-${{ matrix.xcode }}-os-${{ matrix.test-destination-os }}
527-
528372 # This check validates that either all unit tests passed or were skipped, which allows us
529373 # to make unit tests a required check with only running the unit tests when required.
530374 # So, we don't have to run unit tests, for example, for Changelog or ReadMe changes.
0 commit comments