Skip to content

feat: Add propagating of traceparent #15571

feat: Add propagating of traceparent

feat: Add propagating of traceparent #15571

Workflow file for this run

name: Test
on:
push:
branches:
- main
- release/**
pull_request:
# Concurrency configuration:
# - We use workflow-specific concurrency groups to allow independent test runs across different workflows
# while preventing multiple runs of the same test suite on the same branch/commit.
# - For pull requests, we cancel in-progress runs when new commits are pushed to save CI resources
# and provide faster feedback on the latest changes.
# - For main branch pushes and scheduled runs, we never cancel in-progress runs to ensure the complete
# test suite always finishes, maintaining the integrity of our main branch quality gates.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# This job detects if the PR contains changes that require running unit tests.
# If yes, the job will output a flag that will be used by the next job to run the unit tests.
# If no, the job will output a flag that will be used by the next job to skip running the unit tests.
# At the end of this workflow, we run a check that validates that either all unit tests passed or were
# called unit-tests-required-check.
files-changed:
name: Detect File Changes
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
run_unit_tests_for_prs: ${{ steps.changes.outputs.run_unit_tests_for_prs }}
steps:
- uses: actions/checkout@v5
- name: Get changed files
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
build-test-server:
name: Build test server
if: needs.files-changed.outputs.run_unit_tests_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- name: Cache for Test Server
id: cache_test_server
uses: actions/cache@v4
with:
path: ./test-server/.build
key: test-server-${{ hashFiles('./test-server') }}-universal
restore-keys: |
test-server-${{ hashFiles('./test-server') }}-universal
test-server-
- name: Build Test Server for Intel CPU
if: steps.cache_test_server.outputs.cache-hit != 'true'
working-directory: test-server
run: >-
swift build -c release --triple x86_64-apple-macosx 2>&1 | tee test-server-build-intel.log
- name: Build Test Server for M1 CPU
if: steps.cache_test_server.outputs.cache-hit != 'true'
working-directory: test-server
run: >-
swift build -c release --arch arm64 2>&1 | tee test-server-build-arm64.log
- name: Combine Test Server
working-directory: test-server
run: >-
lipo -create -output test-server-exec $(swift build --show-bin-path -c release --triple arm64-apple-macosx)/Run $(swift build --show-bin-path -c release --triple x86_64-apple-macosx)/Run
- name: Archiving DerivedData
uses: actions/upload-artifact@v4
with:
name: test-server
path: |
./test-server/test-server-exec
- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: test-server-build-log
path: |
test-server-build-intel.log
test-server-build-arm64.log
- name: Run CI Diagnostics
if: failure()
run: ./scripts/ci-diagnostics.sh
distribution-tests:
name: Distribution Tests
runs-on: macos-15
needs: files-changed
steps:
- uses: actions/checkout@v5
- name: Prepare Package.swift
uses: ./.github/actions/prepare-package.swift
with:
is-pr: ${{ github.event_name == 'pull_request' }}
change-path: false
remove-duplicate: true
- run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace
- run: set -o pipefail && NSUnbufferedIO=YES SKIP_BINARIES=1 xcodebuild test -scheme Sentry-Package -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=18.4,name=iPhone 16 Pro' | tee raw-test-output-distribution.log | xcbeautify --preserve-unbeautified
shell: sh
- name: Upload Distribution Test Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-test-output-distribution
path: |
raw-test-output-distribution.log
# This matrix runs only the unit tests requiring the test server.
# We do this to speed up the other unit test jobs and to avoid running the
# test server with potential side effects in GH actions for all unit tests.
# We don't run this matrix for all different OS versions, because the chances
# of a bug solely on a specific OS version is minimal.
unit-tests-with-test-server:
name: Unit with Test Server ${{matrix.name}}
runs-on: ${{matrix.runs-on}}
timeout-minutes: 20
needs: build-test-server
strategy:
fail-fast: false
matrix:
include:
# Running the tests with simulators is incredibly flaky. Our assumption is that simulators might have difficulties
# with communicating with the test server in CI.
# We are going to add these back in https://github.com/getsentry/sentry-cocoa/issues/6361
- name: macOS 15
runs-on: macos-15
platform: "macOS"
xcode: "16.4"
test-destination-os: "15.0"
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v5
with:
name: test-server
- name: Start Test Server
run: ./scripts/start-test-server.sh
- run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}}
# Note: We don't install Slather or gather code coverage for this job because it only runs
# the SentryTestServerTests target, which contains minimal tests that don't significantly
# contribute to overall code coverage metrics. The main unit-tests job handles comprehensive
# code coverage reporting.
# We split building and running tests in two steps so we know how long running the tests takes.
- name: Build tests
id: build_tests
run: |
./scripts/sentry-xcodebuild.sh \
--platform ${{matrix.platform}} \
--os ${{matrix.test-destination-os}} \
--ref ${{ github.ref_name }} \
--command build-for-testing \
--device "${{matrix.device}}" \
--configuration TestCI \
--scheme Sentry \
--test-plan Sentry_TestServer
- name: Run tests
run: |
./scripts/sentry-xcodebuild.sh \
--platform ${{matrix.platform}} \
--os ${{matrix.test-destination-os}} \
--ref ${{ github.ref_name }} \
--command test-without-building \
--device "${{matrix.device}}" \
--configuration TestCI \
--scheme Sentry \
--test-plan Sentry_TestServer
- name: Archiving DerivedData Logs
uses: actions/upload-artifact@v4
if: steps.build_tests.outcome == 'failure'
with:
name: derived-data-test-server-${{matrix.platform}}-xcode-${{matrix.xcode}}
path: |
/Users/runner/Library/Developer/Xcode/DerivedData/**/Logs/**
- name: Archiving Raw Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-output-test-server-${{matrix.platform}}-xcode-${{matrix.xcode}}
path: |
raw-build-output.log
raw-build-for-testing-output.log
raw-test-output.log
- name: Archiving Crash Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: crash-logs-test-server-${{matrix.platform}}-xcode-${{matrix.xcode}}
path: |
~/Library/Logs/DiagnosticReports/**
- name: Run CI Diagnostics
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
- name: Store screenshot
uses: ./.github/actions/capture-screenshot
if: ${{ failure() || cancelled() }}
with:
suffix: ${{ matrix.platform }}-xcode-${{ matrix.xcode }}
unit-tests:
name: Unit ${{matrix.name}}
runs-on: ${{matrix.runs-on}}
timeout-minutes: 20
needs: files-changed
if: needs.files-changed.outputs.run_unit_tests_for_prs == 'true'
strategy:
fail-fast: false
matrix:
# Can't run tests on watchOS because XCTest is not available
include:
# We are running tests on iOS 17 and later, as there were OS-internal changes introduced in succeeding versions.
# iOS 16
- name: iOS 16 Sentry
runs-on: macos-13
platform: "iOS"
xcode: "14.3.1"
test-destination-os: "16.4"
device: "iPhone 14 Pro"
scheme: "Sentry"
# iOS 17
- name: iOS 17 Sentry
runs-on: macos-14
platform: "iOS"
xcode: "15.4"
test-destination-os: "17.5"
device: "iPhone 15 Pro"
scheme: "Sentry"
# iOS 18
- name: iOS 18 Sentry
runs-on: macos-15
platform: "iOS"
xcode: "16.4"
test-destination-os: "18.4"
device: "iPhone 16 Pro"
scheme: "Sentry"
# iOS 26 with Xcode 26
- name: iOS 26 Sentry
runs-on: macos-26
platform: "iOS"
xcode: "26.0.1"
test-destination-os: "26.0"
device: "iPhone 17 Pro"
scheme: "Sentry"
# We don't run the unit tests on macOS 13 cause we run them on all on GH actions available iOS versions.
# The chance of missing a bug solely on tvOS 16 that doesn't occur on iOS, macOS 12 or macOS 14 is minimal.
# We are running tests on macOS 14 and later, as there were OS-internal changes introduced in succeeding versions.
# macOS 14
- name: macOS 14 Sentry
runs-on: macos-14
platform: "macOS"
xcode: "15.4"
test-destination-os: "latest"
scheme: "Sentry"
# macOS 15
- name: macOS 15 Sentry
runs-on: macos-15
platform: "macOS"
xcode: "16.4"
test-destination-os: "latest"
scheme: "Sentry"
# macOS 26
- name: macOS 26 Sentry
runs-on: macos-26
platform: "macOS"
xcode: "26.0.1"
test-destination-os: "26.0"
scheme: "Sentry"
# Catalyst. We test the latest version, as the risk something breaking on Catalyst and not
# on an older iOS or macOS version is low.
# In addition we are running tests on macOS 14, as there were OS-internal changes introduced in succeeding versions.
- name: Catalyst 14 Sentry
runs-on: macos-14
platform: "Catalyst"
xcode: "15.4"
test-destination-os: "latest"
scheme: "Sentry"
- name: Catalyst 15 Sentry
runs-on: macos-15
platform: "Catalyst"
xcode: "16.4"
test-destination-os: "latest"
scheme: "Sentry"
## We don't run unit tests on macCatalyst 26 yet because of https://github.com/getsentry/sentry-cocoa/issues/6165.
# We don't run the unit tests on tvOS 16 cause we run them on all on GH actions available iOS versions.
# The chance of missing a bug solely on tvOS 16 that doesn't occur on iOS, tvOS 15 or tvOS 16 is minimal.
# We are running tests on tvOS 17 and latest, as there were OS-internal changes introduced in succeeding versions.
# tvOS 17
- name: tvOS 17 Sentry
runs-on: macos-14
platform: "tvOS"
xcode: "15.4"
test-destination-os: "17.5"
scheme: "Sentry"
# iOS 17
- name: iOS 17 SentrySwiftUI
runs-on: macos-14
platform: "iOS"
xcode: "15.4"
test-destination-os: "17.5"
device: "iPhone 15 Pro"
scheme: "SentrySwiftUI"
# tvOS 18
- name: tvOS 18 Sentry
runs-on: macos-15
platform: "tvOS"
xcode: "16.4"
test-destination-os: "18.4"
scheme: "Sentry"
# tvOS 26
- name: tvOS 26 Sentry
runs-on: macos-26
platform: "tvOS"
xcode: "26.0.1"
test-destination-os: "26.0"
device: "Apple TV"
scheme: "Sentry"
steps:
- uses: actions/checkout@v5
- run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}}
- 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
id: build_tests
run: |
./scripts/sentry-xcodebuild.sh \
--platform ${{matrix.platform}} \
--os ${{matrix.test-destination-os}} \
--ref ${{ github.ref_name }} \
--command build-for-testing \
--device "${{matrix.device}}" \
--configuration TestCI \
--scheme ${{matrix.scheme}}
- 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/sentry-xcodebuild.sh \
--platform ${{matrix.platform}} \
--os ${{matrix.test-destination-os}} \
--ref ${{ github.ref_name }} \
--command test-without-building \
--device "${{matrix.device}}" \
--configuration TestCI \
--scheme ${{matrix.scheme}}
- name: Publish Test Report
uses: mikepenz/action-junit-report@3585e9575db828022551b4231f165eb59a0e74e3 # v5.6.2
if: always()
with:
report_paths: "build/reports/junit.xml"
fail_on_failure: true
fail_on_parse_error: true
detailed_summary: true
- name: Archiving DerivedData Logs
uses: actions/upload-artifact@v4
if: steps.build_tests.outcome == 'failure'
with:
name: derived-data-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
path: |
/Users/runner/Library/Developer/Xcode/DerivedData/**/Logs/**
- name: Archiving Raw Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-output-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
path: |
raw-build-output.log
raw-build-for-testing-output.log
raw-test-output.log
- name: Archiving Crash Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: crash-logs-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
path: |
~/Library/Logs/DiagnosticReports/**
- name: Gather code coverage information via slather
run: slather coverage --configuration TestCI --scheme Sentry
# We can upload all coverage reports, because codecov merges them.
# See https://docs.codecov.io/docs/merging-reports
# Checkout .codecov.yml to see the config of Codecov
# We don't upload codecov for release branches, as we don't want a failing coverage check to block a release.
# We don't upload codecov for scheduled runs as CodeCov only accepts a limited amount of uploads per commit.
- name: Push code coverage to codecov
id: codecov_1
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # [email protected]
if: ${{ contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
with:
# Although public repos should not have to specify a token there seems to be a bug with the Codecov GH action, which can
# be solved by specifying the token, see https://github.com/codecov/codecov-action/issues/557#issuecomment-1224970469
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
# Sometimes codecov uploads etc can fail. Retry one time to rule out e.g. intermittent network failures.
- name: Push code coverage to codecov
id: codecov_2
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # [email protected]
if: ${{ steps.codecov_1.outcome == 'failure' && contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
- name: Codecov test analytics
if: ${{ !cancelled() && !contains(github.ref, 'release') && github.event.schedule == '' }}
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # [email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
name: sentry-cocoa-unit-tests
flags: unittests-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.test-destination-os }}, unittests
- name: Run CI Diagnostics
if: failure()
run: ./scripts/ci-diagnostics.sh
# This check validates that either all unit tests passed or were skipped, which allows us
# to make unit tests a required check with only running the unit tests when required.
# So, we don't have to run unit tests, for example, for Changelog or ReadMe changes.
unit-tests-required-check:
needs:
[
files-changed,
build-test-server,
distribution-tests,
unit-tests,
unit-tests-with-test-server,
]
name: Unit Tests
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-latest
steps:
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
# Skipped jobs are not considered failures.
- name: Check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One of the unit test jobs has failed." && exit 1