From f4c75d2a49f72ed661db9fb7e78154ae511beabf Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Mon, 1 Dec 2025 17:11:43 -0300 Subject: [PATCH 01/21] chore: Add test workflow for swift log --- .github/file-filters.yml | 8 ++ .github/workflows/integrations-common.yml | 98 ++++++++++++++ .github/workflows/integrations-swift-log.yml | 125 ++++++++++++++++++ scripts/integration-xcodebuild.sh | 128 +++++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100644 .github/workflows/integrations-common.yml create mode 100644 .github/workflows/integrations-swift-log.yml create mode 100755 scripts/integration-xcodebuild.sh diff --git a/.github/file-filters.yml b/.github/file-filters.yml index bbae62f26e..e7c8aef381 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -541,3 +541,11 @@ run_size_analysis_for_prs: &run_size_analysis_for_prs # Build configuration - "Makefile" - "Brewfile*" + +run_swift_log_for_prs: &run_swift_log_for_prs + - "integrations/logs/sentry-cocoa-swiftlog/**" + + # GH Actions + - ".github/workflows/integrations-common.yml" + - ".github/workflows/integrations-swift-log.yml" + - ".github/file-filters.yml" diff --git a/.github/workflows/integrations-common.yml b/.github/workflows/integrations-common.yml new file mode 100644 index 0000000000..2b0e5286aa --- /dev/null +++ b/.github/workflows/integrations-common.yml @@ -0,0 +1,98 @@ +name: Test Integrations + +on: + workflow_call: + inputs: + name: + description: "The name of the integration to test" + required: true + type: string + working_directory: + description: "The working directory to run the tests in" + required: true + type: string + xcode_version: + description: "The Xcode version to use for the job" + required: true + type: string + test-destination-os: + description: "The test destination OS to use for the job" + required: true + type: string + device: + description: "The device to test on" + required: false + default: "" + type: string + platform: + description: "The platform to test on" + required: true + type: string + package-name: + description: "The package name to test (same as Package.swift name)" + required: true + type: string + macos_version: + description: "macOS version" + required: true + default: macos-26 + type: string + +jobs: + xcode-build-integrations-tests: + name: "XCode for Integration: ${{ inputs.name }}" + runs-on: ${{ inputs.macos_version }} + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - name: Select Xcode version + env: + XCODE_VERSION: ${{ inputs.xcode_version }} + run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" + - name: Ensure required runtime is loaded + if: ${{ inputs.platform == 'iOS' }} + timeout-minutes: 5 # 5 minutes timeout + env: + OS_VERSION: ${{ inputs.test-destination-os }} + run: ./scripts/ci-ensure-runtime-loaded.sh --os-version "$OS_VERSION" + - name: Boot simulator + if: ${{ inputs.platform == 'iOS' }} + env: + XCODE_VERSION: ${{ inputs.xcode_version }} + DEVICE_NAME: ${{ inputs.device }} + OS_VERSION: ${{ inputs.test-destination-os }} + run: ./scripts/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" + + # We split building and running tests in two steps so we know how long running the tests takes. + - name: Build Tests + working-directory: ${{ inputs.working_directory }} + env: + PLATFORM: ${{ inputs.platform }} + OS_VERSION: ${{ inputs.test-destination-os }} + REF_NAME: ${{ github.ref_name }} + DEVICE_NAME: ${{ inputs.device }} + SCHEME: ${{ inputs.package-name }} + run: | + ../../../scripts/integration-xcodebuild.sh \ + --platform "$PLATFORM" \ + --os "$OS_VERSION" \ + --command build-for-testing \ + --device "$DEVICE_NAME" \ + --scheme "$SCHEME" + + - name: Run Tests + working-directory: ${{ inputs.working_directory }} + env: + PLATFORM: ${{ inputs.platform }} + OS_VERSION: ${{ inputs.test-destination-os }} + REF_NAME: ${{ github.ref_name }} + DEVICE_NAME: ${{ inputs.device }} + SCHEME: ${{ inputs.package-name }} + run: | + ../../../scripts/integration-xcodebuild.sh \ + --platform "$PLATFORM" \ + --os "$OS_VERSION" \ + --command test-without-building \ + --device "$DEVICE_NAME" \ + --scheme "$SCHEME" \ + --result-bundle integration-results.xcresult diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml new file mode 100644 index 0000000000..88df460ae4 --- /dev/null +++ b/.github/workflows/integrations-swift-log.yml @@ -0,0 +1,125 @@ +name: Test Integrations +on: + push: + branches: + - main + - release/** + + pull_request: + types: [opened, synchronize, reopened, labeled] + +# 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: + ready-to-merge-gate: + name: Ready-to-merge gate + uses: ./.github/workflows/ready-to-merge-workflow.yml + + # 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 + needs: ready-to-merge-gate + # Map a step output to a job output + outputs: + run_swift_log_for_prs: ${{ steps.changes.outputs.run_swift_log_for_prs }} + steps: + - uses: actions/checkout@v6 + - name: Get changed files + id: changes + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + + spm-integrations-tests: + name: "SPM Tests for Swift Log" + needs: files-changed + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_swift_log_for_prs == 'true' + runs-on: macos-15 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - name: Select Xcode version + env: + XCODE_VERSION: 16.4 + run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" + - name: Run SPM Tests + working-directory: integrations/logs/sentry-cocoa-swiftlog + run: swift test + + test-integration: + name: Unit Tests for Swift Log + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_swift_log_for_prs == 'true' + needs: files-changed + uses: ./.github/workflows/integrations-common.yml + with: + name: SwiftLog + package-name: SentrySwiftLog + working_directory: integrations/logs/sentry-cocoa-swiftlog + file-filter: run_swift_log_for_prs + xcode_version: ${{ matrix.xcode }} + test-destination-os: ${{ matrix.test-destination-os }} + device: ${{ matrix.device }} + platform: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + include: + - name: iOS 18 + xcode: "16.4" + macos_version: macos-15 + test-destination-os: "18.4" + platform: "iOS" + device: "iPhone 16 Pro" + + - name: iOS 26 Sentry + runs-on: tahoe + xcode: "26.1.1" + test-destination-os: "26.1" + platform: "iOS" + device: "iPhone 17 Pro" + + - name: macOS 15 + runs-on: macos-15 + xcode: "16.4" + test-destination-os: "latest" + platform: "macOS" + + - name: macOS 26 + runs-on: macos-26 + xcode: "26.1.1" + test-destination-os: "26.1" + platform: "macOS" + + unit-tests-required-check: + needs: + [ + ready-to-merge-gate, + files-changed, + test-integration, + ] + name: Swift Log 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 diff --git a/scripts/integration-xcodebuild.sh b/scripts/integration-xcodebuild.sh new file mode 100755 index 0000000000..896d935ce5 --- /dev/null +++ b/scripts/integration-xcodebuild.sh @@ -0,0 +1,128 @@ +#!/bin/bash +set -euxo pipefail + +# Disable SC1091 because it won't work with pre-commit +# shellcheck source=./scripts/ci-utils.sh disable=SC1091 +source "$(cd "$(dirname "$0")" && pwd)/ci-utils.sh" + +# This is a helper script for GitHub Actions Matrix. +# If we would specify the destinations in the GitHub Actions +# Matrix, the name of the job would include the destination, which would +# be, for example, platform=tvOS Simulator,OS=latest,name=Apple TV 4K. +# To fix this, we specify a readable platform in the matrix and then call +# this script to map the platform to the destination. + +# Parse named arguments +PLATFORM="" +OS="latest" +COMMAND="test" +DEVICE="iPhone 14 Pro" +TEST_SCHEME="Sentry" +RESULT_BUNDLE_PATH="results.xcresult" + +usage() { + echo "Usage: $0" + echo " -p|--platform Platform (macOS/Catalyst/iOS/tvOS)" + echo " -o|--os OS version (default: latest)" + echo " -c|--command Command (build/build-for-testing/test-without-building/test)" + echo " -d|--device Device name (default: iPhone 14 Pro)" + echo " -s|--scheme Test scheme (default: Sentry)" + echo " -R|--result-bundle Result bundle path (default: results.xcresult)" + exit 1 +} + +# Parse arguments +while [[ $# -gt 0 ]]; do + case $1 in + -p|--platform) + PLATFORM="$2" + shift 2 + ;; + -o|--os) + OS="$2" + shift 2 + ;; + -c|--command) + COMMAND="$2" + shift 2 + ;; + -d|--device) + DEVICE="$2" + shift 2 + ;; + -s|--scheme) + TEST_SCHEME="$2" + shift 2 + ;; + -R|--result-bundle) + RESULT_BUNDLE_PATH="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + usage + ;; + esac +done + +case $PLATFORM in + +"macOS") + DESTINATION="platform=macOS" + ;; + +"Catalyst") + DESTINATION="platform=macOS,variant=Mac Catalyst" + ;; + +"iOS") + DESTINATION="platform=iOS Simulator,OS=$OS,name=$DEVICE" + ;; + +"tvOS") + DESTINATION="platform=tvOS Simulator,OS=$OS,name=Apple TV" + ;; + +*) + echo "Xcode Test: Can't find destination for platform '$PLATFORM'" + exit 1 + ;; +esac + +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 + ;; +esac + +if [ "$RUN_BUILD_FOR_TESTING" == true ]; then + # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan + log_notice "Running xcodebuild build-for-testing" + + set -o pipefail && NSUnbufferedIO=YES xcodebuild \ + -scheme "$TEST_SCHEME" \ + -destination "$DESTINATION" \ + build-for-testing 2>&1 | + tee raw-build-for-testing-output.log | + xcbeautify --preserve-unbeautified +fi + +if [ "$RUN_TEST_WITHOUT_BUILDING" == true ]; then + # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan + log_notice "Running xcodebuild test-without-building" + + set -o pipefail && NSUnbufferedIO=YES xcodebuild \ + -scheme "$TEST_SCHEME" \ + -destination "$DESTINATION" \ + -resultBundlePath "$RESULT_BUNDLE_PATH" \ + test-without-building 2>&1 | + tee raw-test-output.log | + xcbeautify --report junit +fi + +log_notice "Finished xcodebuild" From 5c5779fb17d9a9e5b281b82b533382ea91604e3a Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Mon, 1 Dec 2025 17:14:15 -0300 Subject: [PATCH 02/21] Add macOS version --- .github/workflows/integrations-swift-log.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index 88df460ae4..53c5949295 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -75,6 +75,7 @@ jobs: test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} platform: ${{ matrix.platform }} + macos_version: ${{ matrix.macos_version }} strategy: fail-fast: false matrix: From 01001dc742ac9279518d738187abb71b97693b4e Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Mon, 1 Dec 2025 17:14:45 -0300 Subject: [PATCH 03/21] Remove file-filter --- .github/workflows/integrations-swift-log.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index 53c5949295..d9c17d9a4c 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -70,7 +70,6 @@ jobs: name: SwiftLog package-name: SentrySwiftLog working_directory: integrations/logs/sentry-cocoa-swiftlog - file-filter: run_swift_log_for_prs xcode_version: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} From 2e9908cc8ae1396d6615d9df311609d93fb1e21c Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Mon, 1 Dec 2025 17:38:19 -0300 Subject: [PATCH 04/21] Update integration's package to use local path --- .github/workflows/integrations-common.yml | 7 +++ .github/workflows/integrations-swift-log.yml | 14 +++-- scripts/use-local-sentry-dependency.sh | 59 ++++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100755 scripts/use-local-sentry-dependency.sh diff --git a/.github/workflows/integrations-common.yml b/.github/workflows/integrations-common.yml index 2b0e5286aa..a9d4959a35 100644 --- a/.github/workflows/integrations-common.yml +++ b/.github/workflows/integrations-common.yml @@ -63,6 +63,13 @@ jobs: OS_VERSION: ${{ inputs.test-destination-os }} run: ./scripts/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" + - name: Prepare Package.swift + shell: bash + run: | + ./scripts/use-local-sentry-dependency.sh \ + --package-file ${{ inputs.working_directory }}/Package.swift \ + --path-to-sentry-cocoa "../../../" + # We split building and running tests in two steps so we know how long running the tests takes. - name: Build Tests working-directory: ${{ inputs.working_directory }} diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index d9c17d9a4c..b68ece53ca 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -57,6 +57,12 @@ jobs: env: XCODE_VERSION: 16.4 run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" + - name: Prepare Package.swift + shell: bash + run: | + ./scripts/use-local-sentry-dependency.sh \ + --package-file integrations/logs/sentry-cocoa-swiftlog/Package.swift \ + --path-to-sentry-cocoa "../../../" - name: Run SPM Tests working-directory: integrations/logs/sentry-cocoa-swiftlog run: swift test @@ -86,21 +92,21 @@ jobs: platform: "iOS" device: "iPhone 16 Pro" - - name: iOS 26 Sentry - runs-on: tahoe + - name: iOS 26 + macos_version: macos-26 xcode: "26.1.1" test-destination-os: "26.1" platform: "iOS" device: "iPhone 17 Pro" - name: macOS 15 - runs-on: macos-15 + macos_version: macos-15 xcode: "16.4" test-destination-os: "latest" platform: "macOS" - name: macOS 26 - runs-on: macos-26 + macos_version: macos-26 xcode: "26.1.1" test-destination-os: "26.1" platform: "macOS" diff --git a/scripts/use-local-sentry-dependency.sh b/scripts/use-local-sentry-dependency.sh new file mode 100755 index 0000000000..d9b0d38013 --- /dev/null +++ b/scripts/use-local-sentry-dependency.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -euo pipefail + +# Script to replace sentry-cocoa remote dependency with local path in integration packages +# This is useful for CI testing where we want to test integrations against the current code + +usage() { + cat <<'USAGE' +Usage: prepare-package.sh [options] + +Options: + --package-file PATH Path to the Package.swift file (default: Package.swift) + --path-to-sentry-cocoa PATH Path to the sentry-cocoa directory (default: ../../../sentry-cocoa) + -h, --help Show this help message +USAGE +} + +PACKAGE_FILE="Package.swift" +PATH_TO_SENTRY_COCOA="../../../" + +while [[ $# -gt 0 ]]; do + case "$1" in + --package-file) + [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } + PACKAGE_FILE="$2" + shift 2 + ;; + --path-to-sentry-cocoa) + [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } + PATH_TO_SENTRY_COCOA="$2" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown option: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + +if [[ ! -f "$PACKAGE_FILE" ]]; then + echo "Package file not found: $PACKAGE_FILE" >&2 + exit 1 +fi + +echo "Updating $PACKAGE_FILE to use local sentry-cocoa dependency..." + +# Replace the sentry-cocoa dependency line +# Matches: .package(url: "https://github.com/getsentry/sentry-cocoa", from: "X.Y.Z") +# With: .package(path: "../../..") +sed -i '' \ + -e 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(path: "'"$PATH_TO_SENTRY_COCOA"'")|g' \ + "$PACKAGE_FILE" + +echo "✓ Successfully updated dependency to use local path: $PATH_TO_SENTRY_COCOA" From b00d89e7cf581f76796d82c358f2181408da4562 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 3 Dec 2025 17:10:31 -0300 Subject: [PATCH 05/21] Fix example commands --- scripts/integration-xcodebuild.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/integration-xcodebuild.sh b/scripts/integration-xcodebuild.sh index 896d935ce5..e342e748b2 100755 --- a/scripts/integration-xcodebuild.sh +++ b/scripts/integration-xcodebuild.sh @@ -15,7 +15,7 @@ source "$(cd "$(dirname "$0")" && pwd)/ci-utils.sh" # Parse named arguments PLATFORM="" OS="latest" -COMMAND="test" +COMMAND="test-without-building" DEVICE="iPhone 14 Pro" TEST_SCHEME="Sentry" RESULT_BUNDLE_PATH="results.xcresult" @@ -24,7 +24,7 @@ usage() { echo "Usage: $0" echo " -p|--platform Platform (macOS/Catalyst/iOS/tvOS)" echo " -o|--os OS version (default: latest)" - echo " -c|--command Command (build/build-for-testing/test-without-building/test)" + echo " -c|--command Command (build-for-testing/test-without-building)" echo " -d|--device Device name (default: iPhone 14 Pro)" echo " -s|--scheme Test scheme (default: Sentry)" echo " -R|--result-bundle Result bundle path (default: results.xcresult)" From c0d95c76e5828d0037c994a372abc7373d655eac Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 3 Dec 2025 17:11:19 -0300 Subject: [PATCH 06/21] Add SPM test to required checks --- .github/workflows/integrations-swift-log.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index b68ece53ca..a13d9db845 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -116,9 +116,10 @@ jobs: [ ready-to-merge-gate, files-changed, + spm-integrations-tests, test-integration, ] - name: Swift Log Tests + name: Swift Log Tests - Required Check # This is necessary since a failed/skipped dependent job would cause this job to be skipped if: always() runs-on: ubuntu-latest From 6516a2ea9b8c3352a6a9e30b9e8b601832c96151 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 15:40:15 -0300 Subject: [PATCH 07/21] Update `sentry-xcodebuild.sh` to be compatible with SPM packages --- .github/workflows/integrations-common.yml | 10 +- scripts/integration-xcodebuild.sh | 128 ---------------------- scripts/sentry-xcodebuild.sh | 21 +++- 3 files changed, 23 insertions(+), 136 deletions(-) delete mode 100755 scripts/integration-xcodebuild.sh diff --git a/.github/workflows/integrations-common.yml b/.github/workflows/integrations-common.yml index a9d4959a35..1489f9ed54 100644 --- a/.github/workflows/integrations-common.yml +++ b/.github/workflows/integrations-common.yml @@ -80,12 +80,13 @@ jobs: DEVICE_NAME: ${{ inputs.device }} SCHEME: ${{ inputs.package-name }} run: | - ../../../scripts/integration-xcodebuild.sh \ + ../../../scripts/sentry-xcodebuild.sh \ --platform "$PLATFORM" \ --os "$OS_VERSION" \ --command build-for-testing \ --device "$DEVICE_NAME" \ - --scheme "$SCHEME" + --scheme "$SCHEME" \ + --spm-project - name: Run Tests working-directory: ${{ inputs.working_directory }} @@ -96,10 +97,11 @@ jobs: DEVICE_NAME: ${{ inputs.device }} SCHEME: ${{ inputs.package-name }} run: | - ../../../scripts/integration-xcodebuild.sh \ + ../../../scripts/sentry-xcodebuild.sh \ --platform "$PLATFORM" \ --os "$OS_VERSION" \ --command test-without-building \ --device "$DEVICE_NAME" \ --scheme "$SCHEME" \ - --result-bundle integration-results.xcresult + --result-bundle integration-results.xcresult \ + --spm-project diff --git a/scripts/integration-xcodebuild.sh b/scripts/integration-xcodebuild.sh deleted file mode 100755 index e342e748b2..0000000000 --- a/scripts/integration-xcodebuild.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -set -euxo pipefail - -# Disable SC1091 because it won't work with pre-commit -# shellcheck source=./scripts/ci-utils.sh disable=SC1091 -source "$(cd "$(dirname "$0")" && pwd)/ci-utils.sh" - -# This is a helper script for GitHub Actions Matrix. -# If we would specify the destinations in the GitHub Actions -# Matrix, the name of the job would include the destination, which would -# be, for example, platform=tvOS Simulator,OS=latest,name=Apple TV 4K. -# To fix this, we specify a readable platform in the matrix and then call -# this script to map the platform to the destination. - -# Parse named arguments -PLATFORM="" -OS="latest" -COMMAND="test-without-building" -DEVICE="iPhone 14 Pro" -TEST_SCHEME="Sentry" -RESULT_BUNDLE_PATH="results.xcresult" - -usage() { - echo "Usage: $0" - echo " -p|--platform Platform (macOS/Catalyst/iOS/tvOS)" - echo " -o|--os OS version (default: latest)" - echo " -c|--command Command (build-for-testing/test-without-building)" - echo " -d|--device Device name (default: iPhone 14 Pro)" - echo " -s|--scheme Test scheme (default: Sentry)" - echo " -R|--result-bundle Result bundle path (default: results.xcresult)" - exit 1 -} - -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - -p|--platform) - PLATFORM="$2" - shift 2 - ;; - -o|--os) - OS="$2" - shift 2 - ;; - -c|--command) - COMMAND="$2" - shift 2 - ;; - -d|--device) - DEVICE="$2" - shift 2 - ;; - -s|--scheme) - TEST_SCHEME="$2" - shift 2 - ;; - -R|--result-bundle) - RESULT_BUNDLE_PATH="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - usage - ;; - esac -done - -case $PLATFORM in - -"macOS") - DESTINATION="platform=macOS" - ;; - -"Catalyst") - DESTINATION="platform=macOS,variant=Mac Catalyst" - ;; - -"iOS") - DESTINATION="platform=iOS Simulator,OS=$OS,name=$DEVICE" - ;; - -"tvOS") - DESTINATION="platform=tvOS Simulator,OS=$OS,name=Apple TV" - ;; - -*) - echo "Xcode Test: Can't find destination for platform '$PLATFORM'" - exit 1 - ;; -esac - -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 - ;; -esac - -if [ "$RUN_BUILD_FOR_TESTING" == true ]; then - # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan - log_notice "Running xcodebuild build-for-testing" - - set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - -scheme "$TEST_SCHEME" \ - -destination "$DESTINATION" \ - build-for-testing 2>&1 | - tee raw-build-for-testing-output.log | - xcbeautify --preserve-unbeautified -fi - -if [ "$RUN_TEST_WITHOUT_BUILDING" == true ]; then - # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan - log_notice "Running xcodebuild test-without-building" - - set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - -scheme "$TEST_SCHEME" \ - -destination "$DESTINATION" \ - -resultBundlePath "$RESULT_BUNDLE_PATH" \ - test-without-building 2>&1 | - tee raw-test-output.log | - xcbeautify --report junit -fi - -log_notice "Finished xcodebuild" diff --git a/scripts/sentry-xcodebuild.sh b/scripts/sentry-xcodebuild.sh index 2707fd7712..058cd1b646 100755 --- a/scripts/sentry-xcodebuild.sh +++ b/scripts/sentry-xcodebuild.sh @@ -23,6 +23,7 @@ DERIVED_DATA_PATH="" TEST_SCHEME="Sentry" TEST_PLAN="" RESULT_BUNDLE_PATH="results.xcresult" +SPM_PROJECT="false" usage() { echo "Usage: $0" @@ -36,6 +37,7 @@ usage() { echo " -s|--scheme Test scheme (default: Sentry)" echo " -t|--test-plan Test plan name (default: empty)" echo " -R|--result-bundle Result bundle path (default: results.xcresult)" + echo " -S|--spm-project Use SPM project (default: false)" exit 1 } @@ -82,6 +84,10 @@ while [[ $# -gt 0 ]]; do RESULT_BUNDLE_PATH="$2" shift 2 ;; + -S|--spm-project) + SPM_PROJECT="true" + shift 1 + ;; *) echo "Unknown option: $1" usage @@ -169,15 +175,22 @@ if [ -n "$TEST_PLAN" ]; then TEST_PLAN_ARGS+=("-testPlan" "$TEST_PLAN") fi +WORKSPACE_ARG="-workspace Sentry.xcworkspace" +CONFIGURATION_ARG="-configuration $CONFIGURATION" +if [ $SPM_PROJECT == "true" ]; then + WORKSPACE_ARG="" + CONFIGURATION_ARG="" +fi + if [ $RUN_BUILD_FOR_TESTING == true ]; then # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan log_notice "Running xcodebuild build-for-testing" set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - -workspace Sentry.xcworkspace \ + "$WORKSPACE_ARG" \ -scheme "$TEST_SCHEME" \ "${TEST_PLAN_ARGS[@]+${TEST_PLAN_ARGS[@]}}" \ - -configuration "$CONFIGURATION" \ + "$CONFIGURATION_ARG" \ -destination "$DESTINATION" \ build-for-testing 2>&1 | tee raw-build-for-testing-output.log | @@ -189,10 +202,10 @@ if [ $RUN_TEST_WITHOUT_BUILDING == true ]; then log_notice "Running xcodebuild test-without-building" set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - -workspace Sentry.xcworkspace \ + "$WORKSPACE_ARG" \ -scheme "$TEST_SCHEME" \ "${TEST_PLAN_ARGS[@]+${TEST_PLAN_ARGS[@]}}" \ - -configuration "$CONFIGURATION" \ + "$CONFIGURATION_ARG" \ -destination "$DESTINATION" \ -resultBundlePath "$RESULT_BUNDLE_PATH" \ test-without-building 2>&1 | From 7ab3886c07e10527636055b3857ac71f22f53335 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:00:31 -0300 Subject: [PATCH 08/21] Add `--update-path-to-sentry-cocoa` to prepare-package.sh --- scripts/prepare-package.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/prepare-package.sh b/scripts/prepare-package.sh index ee63744a66..5ab574253f 100755 --- a/scripts/prepare-package.sh +++ b/scripts/prepare-package.sh @@ -14,6 +14,8 @@ Options: --change-path true|false Whether to swap SPM binary URLs for local paths (default: false) --remove-binary-targets true|false Whether to keep only SentryDistribution product/target (default: false) + --update-path-to-sentry-cocoa true|false + Whether to update the path to the sentry-cocoa directory (default: false) -h, --help Show this help message USAGE } @@ -30,6 +32,7 @@ IS_PR="false" REMOVE_DUPLICATE="false" CHANGE_PATH="false" REMOVE_BINARY_TARGETS="false" +UPDATE_PATH_TO_SENTRY_COCOA="false" while [[ $# -gt 0 ]]; do case "$1" in @@ -58,6 +61,11 @@ while [[ $# -gt 0 ]]; do REMOVE_BINARY_TARGETS="$2" shift 2 ;; + --update-path-to-sentry-cocoa) + [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } + UPDATE_PATH_TO_SENTRY_COCOA="$2" + shift 2 + ;; -h|--help) usage exit 0 @@ -131,6 +139,10 @@ var targets: [Target] = [\ sed -i '' '/^let env = getenv("EXPERIMENTAL_SPM_BUILDS")/,/^}/d' "$PACKAGE_FILE" fi +if is_enabled "$UPDATE_PATH_TO_SENTRY_COCOA"; then + sed -i '' 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(path: "'../../../'")|g' "$PACKAGE_FILE" +fi + echo echo "===== $PACKAGE_FILE (after prepare-package.sh) =====" cat "$PACKAGE_FILE" From 77e3f6e7ecc8a361f803f422925ea3ceaa2c498c Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:27:10 -0300 Subject: [PATCH 09/21] Improve script --- scripts/sentry-xcodebuild.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/sentry-xcodebuild.sh b/scripts/sentry-xcodebuild.sh index 058cd1b646..fa9edbb9a3 100755 --- a/scripts/sentry-xcodebuild.sh +++ b/scripts/sentry-xcodebuild.sh @@ -175,23 +175,22 @@ if [ -n "$TEST_PLAN" ]; then TEST_PLAN_ARGS+=("-testPlan" "$TEST_PLAN") fi -WORKSPACE_ARG="-workspace Sentry.xcworkspace" -CONFIGURATION_ARG="-configuration $CONFIGURATION" -if [ $SPM_PROJECT == "true" ]; then - WORKSPACE_ARG="" - CONFIGURATION_ARG="" +# Build xcodebuild arguments based on project type +XCODEBUILD_ARGS=() +if [ $SPM_PROJECT != "true" ]; then + XCODEBUILD_ARGS+=("-workspace" "Sentry.xcworkspace") + XCODEBUILD_ARGS+=("-configuration" "$CONFIGURATION") fi +XCODEBUILD_ARGS+=("-scheme" "$TEST_SCHEME") +XCODEBUILD_ARGS+=("${TEST_PLAN_ARGS[@]+${TEST_PLAN_ARGS[@]}}") +XCODEBUILD_ARGS+=("-destination" "$DESTINATION") if [ $RUN_BUILD_FOR_TESTING == true ]; then # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan log_notice "Running xcodebuild build-for-testing" set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - "$WORKSPACE_ARG" \ - -scheme "$TEST_SCHEME" \ - "${TEST_PLAN_ARGS[@]+${TEST_PLAN_ARGS[@]}}" \ - "$CONFIGURATION_ARG" \ - -destination "$DESTINATION" \ + "${XCODEBUILD_ARGS[@]}" \ build-for-testing 2>&1 | tee raw-build-for-testing-output.log | xcbeautify --preserve-unbeautified @@ -201,13 +200,10 @@ if [ $RUN_TEST_WITHOUT_BUILDING == true ]; then # When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan log_notice "Running xcodebuild test-without-building" + XCODEBUILD_ARGS+=("-resultBundlePath" "$RESULT_BUNDLE_PATH") + set -o pipefail && NSUnbufferedIO=YES xcodebuild \ - "$WORKSPACE_ARG" \ - -scheme "$TEST_SCHEME" \ - "${TEST_PLAN_ARGS[@]+${TEST_PLAN_ARGS[@]}}" \ - "$CONFIGURATION_ARG" \ - -destination "$DESTINATION" \ - -resultBundlePath "$RESULT_BUNDLE_PATH" \ + "${XCODEBUILD_ARGS[@]}" \ test-without-building 2>&1 | tee raw-test-output.log | xcbeautify --report junit From 6636b7beae4e3d87663e5ec1d9110d1fb3c0dc00 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:35:16 -0300 Subject: [PATCH 10/21] Reuse existing `unit-test-common.yml` --- .github/workflows/integrations-common.yml | 6 ++-- .github/workflows/integrations-swift-log.yml | 9 ++--- .github/workflows/unit-test-common.yml | 38 +++++++++++++++----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/.github/workflows/integrations-common.yml b/.github/workflows/integrations-common.yml index 1489f9ed54..9bb25880c2 100644 --- a/.github/workflows/integrations-common.yml +++ b/.github/workflows/integrations-common.yml @@ -66,9 +66,9 @@ jobs: - name: Prepare Package.swift shell: bash run: | - ./scripts/use-local-sentry-dependency.sh \ - --package-file ${{ inputs.working_directory }}/Package.swift \ - --path-to-sentry-cocoa "../../../" + ./scripts/prepare-package.sh \ + --package-file ${{ inputs.working_directory }}/Package.swift \ + --update-path-to-sentry-cocoa true # We split building and running tests in two steps so we know how long running the tests takes. - name: Build Tests diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index a13d9db845..bd6b6618e4 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -60,9 +60,9 @@ jobs: - name: Prepare Package.swift shell: bash run: | - ./scripts/use-local-sentry-dependency.sh \ - --package-file integrations/logs/sentry-cocoa-swiftlog/Package.swift \ - --path-to-sentry-cocoa "../../../" + ./scripts/prepare-package.sh \ + --package-file integrations/logs/sentry-cocoa-swiftlog/Package.swift \ + --update-path-to-sentry-cocoa true - name: Run SPM Tests working-directory: integrations/logs/sentry-cocoa-swiftlog run: swift test @@ -71,11 +71,12 @@ jobs: name: Unit Tests for Swift Log if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_swift_log_for_prs == 'true' needs: files-changed - uses: ./.github/workflows/integrations-common.yml + uses: ./.github/workflows/unit-test-common.yml with: name: SwiftLog package-name: SentrySwiftLog working_directory: integrations/logs/sentry-cocoa-swiftlog + path_to_scripts_folder: ../../../ xcode_version: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index 39326849bf..38fc5ed85a 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -69,6 +69,17 @@ on: default: false type: boolean + working_directory: + description: "The working directory to run the tests in" + required: false + type: string + + path_to_scripts_folder: + description: "The path to the scripts folder" + default: . + required: false + type: string + jobs: unit-tests: name: Unit ${{inputs.name}} @@ -77,7 +88,9 @@ jobs: if: ${{!inputs.should_skip}} steps: - uses: actions/checkout@v6 - - run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" + - name: Select Xcode version + working-directory: ${{ inputs.working_directory }} + run: ${{ inputs.path_to_scripts_folder }}/ci-select-xcode.sh "$XCODE_VERSION" env: XCODE_VERSION: ${{inputs.xcode}} @@ -86,42 +99,47 @@ jobs: # Install platform runtimes that are not included by default - name: Install required platforms + working-directory: ${{ inputs.working_directory }} if: ${{ inputs.install_platforms }} env: PLATFORMS: ${{ inputs.platform }} OS_VERSION: ${{ inputs.test-destination-os }} - run: ./scripts/ci-install-platforms.sh --platforms "$PLATFORMS" --os-version "$OS_VERSION" + run: ${{ inputs.path_to_scripts_folder }}/ci-install-platforms.sh --platforms "$PLATFORMS" --os-version "$OS_VERSION" - name: Ensure required runtime is loaded # Ideally we will not need this, but CI sometimes is failing to load some runtimes, this will ensure they are loaded if: ${{ inputs.platform == 'iOS' }} timeout-minutes: 5 # 5 minutes timeout + working-directory: ${{ inputs.working_directory }} env: OS_VERSION: ${{ inputs.test-destination-os }} - run: ./scripts/ci-ensure-runtime-loaded.sh --os-version "$OS_VERSION" + run: ${{ inputs.path_to_scripts_folder }}/ci-ensure-runtime-loaded.sh --os-version "$OS_VERSION" # Create simulator devices for non-preinstalled simulators # Required for iOS 16.4, iOS 17.5 (on Xcode 15.4), and iOS/tvOS 26.1 - name: Create simulator device if: ${{ inputs.create_device }} + working-directory: ${{ inputs.working_directory }} env: PLATFORM: ${{ inputs.platform }} OS_VERSION: ${{ inputs.test-destination-os }} DEVICE_NAME: ${{inputs.device}} - run: ./scripts/ci-create-simulator.sh --platform "$PLATFORM" --os-version "$OS_VERSION" --device-name "$DEVICE_NAME" + run: ${{ inputs.path_to_scripts_folder }}/ci-create-simulator.sh --platform "$PLATFORM" --os-version "$OS_VERSION" --device-name "$DEVICE_NAME" # Boot created simulators to ensure they're ready before tests run # Based on CircleCI forum comment, booting is especially important for Xcode 26: https://discuss.circleci.com/t/xcode-26-rc/54066/18 - name: Boot simulator if: ${{ inputs.create_device && inputs.platform == 'iOS' }} + working-directory: ${{ inputs.working_directory }} env: XCODE_VERSION: ${{ inputs.xcode }} DEVICE_NAME: ${{ inputs.device }} OS_VERSION: ${{ inputs.test-destination-os }} - run: ./scripts/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" + run: ${{ inputs.path_to_scripts_folder }}/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" # We split building and running tests in two steps so we know how long running the tests takes. - name: Build Tests + working-directory: ${{ inputs.working_directory }} id: build_tests env: PLATFORM: ${{ inputs.platform }} @@ -130,7 +148,7 @@ jobs: DEVICE_NAME: ${{ inputs.device }} SCHEME: ${{ inputs.scheme }} run: | - ./scripts/sentry-xcodebuild.sh \ + ${{ inputs.path_to_scripts_folder }}/sentry-xcodebuild.sh \ --platform "$PLATFORM" \ --os "$OS_VERSION" \ --ref "$REF_NAME" \ @@ -146,6 +164,7 @@ jobs: - name: Run Flaky Tests # Only the Sentry Scheme has the Flaky TestPlan. if: ${{ inputs.scheme == 'Sentry' }} + working-directory: ${{ inputs.working_directory }} env: PLATFORM: ${{ inputs.platform }} OS_VERSION: ${{ inputs.test-destination-os }} @@ -153,7 +172,7 @@ jobs: DEVICE_NAME: ${{ inputs.device }} SCHEME: ${{ inputs.scheme }} run: | - ./scripts/sentry-xcodebuild.sh \ + ${{ inputs.path_to_scripts_folder }}/sentry-xcodebuild.sh \ --platform "$PLATFORM" \ --os "$OS_VERSION" \ --ref "$REF_NAME" \ @@ -169,6 +188,7 @@ jobs: # 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. + working-directory: ${{ inputs.working_directory }} env: PLATFORM: ${{ inputs.platform }} OS_VERSION: ${{ inputs.test-destination-os }} @@ -176,7 +196,7 @@ jobs: DEVICE_NAME: ${{ inputs.device }} SCHEME: ${{ inputs.scheme }} run: | - ./scripts/sentry-xcodebuild.sh \ + ${{ inputs.path_to_scripts_folder }}/sentry-xcodebuild.sh \ --platform "$PLATFORM" \ --os "$OS_VERSION" \ --ref "$REF_NAME" \ @@ -190,7 +210,7 @@ jobs: uses: mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6 # v6.0.1 if: always() with: - report_paths: "build/reports/junit.xml" + report_paths: "${{ inputs.working_directory }}/build/reports/junit.xml" fail_on_failure: true fail_on_parse_error: true detailed_summary: true From a12905bf15615367bfe03feb4654551e9f194d0d Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:37:28 -0300 Subject: [PATCH 11/21] Fix path --- .github/workflows/integrations-swift-log.yml | 2 +- .github/workflows/unit-test-common.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index bd6b6618e4..7171d01fc4 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -76,7 +76,7 @@ jobs: name: SwiftLog package-name: SentrySwiftLog working_directory: integrations/logs/sentry-cocoa-swiftlog - path_to_scripts_folder: ../../../ + path_to_scripts_folder: ../../../scripts xcode_version: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index 38fc5ed85a..92d6bfb491 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -76,7 +76,7 @@ on: path_to_scripts_folder: description: "The path to the scripts folder" - default: . + default: ./scripts required: false type: string From 6ed3e63c5a8eeb11fba3e4fb6ae6c84ce45c3c8b Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:41:08 -0300 Subject: [PATCH 12/21] Update GitHub Actions workflow to use 'runs-on' for macOS version --- .github/workflows/integrations-swift-log.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index 7171d01fc4..f3960c4bca 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -81,7 +81,7 @@ jobs: test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} platform: ${{ matrix.platform }} - macos_version: ${{ matrix.macos_version }} + runs-on: ${{ matrix.macos_version }} strategy: fail-fast: false matrix: From bb5691d23bb2f807883dae33b0b06f33c4b210eb Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:42:03 -0300 Subject: [PATCH 13/21] Remove unnecesary files --- .github/workflows/integrations-common.yml | 107 ---------------------- scripts/use-local-sentry-dependency.sh | 59 ------------ 2 files changed, 166 deletions(-) delete mode 100644 .github/workflows/integrations-common.yml delete mode 100755 scripts/use-local-sentry-dependency.sh diff --git a/.github/workflows/integrations-common.yml b/.github/workflows/integrations-common.yml deleted file mode 100644 index 9bb25880c2..0000000000 --- a/.github/workflows/integrations-common.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Test Integrations - -on: - workflow_call: - inputs: - name: - description: "The name of the integration to test" - required: true - type: string - working_directory: - description: "The working directory to run the tests in" - required: true - type: string - xcode_version: - description: "The Xcode version to use for the job" - required: true - type: string - test-destination-os: - description: "The test destination OS to use for the job" - required: true - type: string - device: - description: "The device to test on" - required: false - default: "" - type: string - platform: - description: "The platform to test on" - required: true - type: string - package-name: - description: "The package name to test (same as Package.swift name)" - required: true - type: string - macos_version: - description: "macOS version" - required: true - default: macos-26 - type: string - -jobs: - xcode-build-integrations-tests: - name: "XCode for Integration: ${{ inputs.name }}" - runs-on: ${{ inputs.macos_version }} - timeout-minutes: 30 - steps: - - uses: actions/checkout@v6 - - name: Select Xcode version - env: - XCODE_VERSION: ${{ inputs.xcode_version }} - run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" - - name: Ensure required runtime is loaded - if: ${{ inputs.platform == 'iOS' }} - timeout-minutes: 5 # 5 minutes timeout - env: - OS_VERSION: ${{ inputs.test-destination-os }} - run: ./scripts/ci-ensure-runtime-loaded.sh --os-version "$OS_VERSION" - - name: Boot simulator - if: ${{ inputs.platform == 'iOS' }} - env: - XCODE_VERSION: ${{ inputs.xcode_version }} - DEVICE_NAME: ${{ inputs.device }} - OS_VERSION: ${{ inputs.test-destination-os }} - run: ./scripts/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" - - - name: Prepare Package.swift - shell: bash - run: | - ./scripts/prepare-package.sh \ - --package-file ${{ inputs.working_directory }}/Package.swift \ - --update-path-to-sentry-cocoa true - - # We split building and running tests in two steps so we know how long running the tests takes. - - name: Build Tests - working-directory: ${{ inputs.working_directory }} - env: - PLATFORM: ${{ inputs.platform }} - OS_VERSION: ${{ inputs.test-destination-os }} - REF_NAME: ${{ github.ref_name }} - DEVICE_NAME: ${{ inputs.device }} - SCHEME: ${{ inputs.package-name }} - run: | - ../../../scripts/sentry-xcodebuild.sh \ - --platform "$PLATFORM" \ - --os "$OS_VERSION" \ - --command build-for-testing \ - --device "$DEVICE_NAME" \ - --scheme "$SCHEME" \ - --spm-project - - - name: Run Tests - working-directory: ${{ inputs.working_directory }} - env: - PLATFORM: ${{ inputs.platform }} - OS_VERSION: ${{ inputs.test-destination-os }} - REF_NAME: ${{ github.ref_name }} - DEVICE_NAME: ${{ inputs.device }} - SCHEME: ${{ inputs.package-name }} - run: | - ../../../scripts/sentry-xcodebuild.sh \ - --platform "$PLATFORM" \ - --os "$OS_VERSION" \ - --command test-without-building \ - --device "$DEVICE_NAME" \ - --scheme "$SCHEME" \ - --result-bundle integration-results.xcresult \ - --spm-project diff --git a/scripts/use-local-sentry-dependency.sh b/scripts/use-local-sentry-dependency.sh deleted file mode 100755 index d9b0d38013..0000000000 --- a/scripts/use-local-sentry-dependency.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Script to replace sentry-cocoa remote dependency with local path in integration packages -# This is useful for CI testing where we want to test integrations against the current code - -usage() { - cat <<'USAGE' -Usage: prepare-package.sh [options] - -Options: - --package-file PATH Path to the Package.swift file (default: Package.swift) - --path-to-sentry-cocoa PATH Path to the sentry-cocoa directory (default: ../../../sentry-cocoa) - -h, --help Show this help message -USAGE -} - -PACKAGE_FILE="Package.swift" -PATH_TO_SENTRY_COCOA="../../../" - -while [[ $# -gt 0 ]]; do - case "$1" in - --package-file) - [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } - PACKAGE_FILE="$2" - shift 2 - ;; - --path-to-sentry-cocoa) - [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } - PATH_TO_SENTRY_COCOA="$2" - shift 2 - ;; - -h|--help) - usage - exit 0 - ;; - *) - echo "Unknown option: $1" >&2 - usage >&2 - exit 1 - ;; - esac -done - -if [[ ! -f "$PACKAGE_FILE" ]]; then - echo "Package file not found: $PACKAGE_FILE" >&2 - exit 1 -fi - -echo "Updating $PACKAGE_FILE to use local sentry-cocoa dependency..." - -# Replace the sentry-cocoa dependency line -# Matches: .package(url: "https://github.com/getsentry/sentry-cocoa", from: "X.Y.Z") -# With: .package(path: "../../..") -sed -i '' \ - -e 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(path: "'"$PATH_TO_SENTRY_COCOA"'")|g' \ - "$PACKAGE_FILE" - -echo "✓ Successfully updated dependency to use local path: $PATH_TO_SENTRY_COCOA" From 817105718b344b1719dc00efcd3fd23c2b5225fc Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:44:51 -0300 Subject: [PATCH 14/21] Add missing parameters --- .github/workflows/integrations-swift-log.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index f3960c4bca..edeb23b587 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -74,14 +74,15 @@ jobs: uses: ./.github/workflows/unit-test-common.yml with: name: SwiftLog - package-name: SentrySwiftLog + scheme: SentrySwiftLog working_directory: integrations/logs/sentry-cocoa-swiftlog path_to_scripts_folder: ../../../scripts - xcode_version: ${{ matrix.xcode }} + xcode: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} platform: ${{ matrix.platform }} runs-on: ${{ matrix.macos_version }} + timeout: 10 strategy: fail-fast: false matrix: From 870d82f1eef8c37186736912916a45b29fa19f82 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:51:19 -0300 Subject: [PATCH 15/21] Update GitHub Actions workflow to correct script path for package preparation --- .github/workflows/integrations-swift-log.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index edeb23b587..ebaa140f5c 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -58,10 +58,11 @@ jobs: XCODE_VERSION: 16.4 run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" - name: Prepare Package.swift + working-directory: integrations/logs/sentry-cocoa-swiftlog shell: bash run: | - ./scripts/prepare-package.sh \ - --package-file integrations/logs/sentry-cocoa-swiftlog/Package.swift \ + ../../../scripts/prepare-package.sh \ + --package-file Package.swift \ --update-path-to-sentry-cocoa true - name: Run SPM Tests working-directory: integrations/logs/sentry-cocoa-swiftlog From 14d94751a2da97a0fbc3cba6bd0fd415344a2c97 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:52:38 -0300 Subject: [PATCH 16/21] Add debugging steps to unit-test-common.yml for improved visibility during testing --- .github/workflows/unit-test-common.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index 92d6bfb491..a05c2f1a6e 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -88,6 +88,11 @@ jobs: if: ${{!inputs.should_skip}} steps: - uses: actions/checkout@v6 + - name: Test + run: | + ls -la . + ls -la sentry-cocoa + ls -la ${{ inputs.working_directory }} - name: Select Xcode version working-directory: ${{ inputs.working_directory }} run: ${{ inputs.path_to_scripts_folder }}/ci-select-xcode.sh "$XCODE_VERSION" From b06321775dde2fbf583eacba0919604140d0c417 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 16:58:39 -0300 Subject: [PATCH 17/21] Update paths --- .github/file-filters.yml | 2 +- .github/workflows/integrations-swift-log.yml | 6 ++-- .github/workflows/test.yml | 31 -------------------- .github/workflows/unit-test-common.yml | 5 ---- 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 4e8fec2988..0102fdbd77 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -545,7 +545,7 @@ run_size_analysis_for_prs: &run_size_analysis_for_prs - "Brewfile*" run_swift_log_for_prs: &run_swift_log_for_prs - - "integrations/logs/sentry-cocoa-swiftlog/**" + - "3rd-party-integrations/SwiftLog/**" # GH Actions - ".github/workflows/integrations-common.yml" diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index ebaa140f5c..e903a972d9 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -58,14 +58,14 @@ jobs: XCODE_VERSION: 16.4 run: ./scripts/ci-select-xcode.sh "$XCODE_VERSION" - name: Prepare Package.swift - working-directory: integrations/logs/sentry-cocoa-swiftlog + working-directory: 3rd-party-integrations/SwiftLog shell: bash run: | ../../../scripts/prepare-package.sh \ --package-file Package.swift \ --update-path-to-sentry-cocoa true - name: Run SPM Tests - working-directory: integrations/logs/sentry-cocoa-swiftlog + working-directory: 3rd-party-integrations/SwiftLog run: swift test test-integration: @@ -76,7 +76,7 @@ jobs: with: name: SwiftLog scheme: SentrySwiftLog - working_directory: integrations/logs/sentry-cocoa-swiftlog + working_directory: 3rd-party-integrations/SwiftLog path_to_scripts_folder: ../../../scripts xcode: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b33c37fc6a..15075829c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -369,37 +369,6 @@ jobs: device: "Apple TV" scheme: "Sentry" - swiftlog-integration-unit-tests: - name: Integrations/Logs/SentrySwiftLog Unit Tests - if: needs.files-changed.outputs.run_unit_tests_for_prs == 'true' - needs: files-changed - runs-on: macos-15 - steps: - - uses: actions/checkout@v6 - - - name: Select Xcode - run: ./scripts/ci-select-xcode.sh 16.4 - - - name: Setup local sentry-cocoa dependency - working-directory: 3rd-party-integrations/SwiftLog - run: swift package edit sentry-cocoa --path ../.. - - - name: Run SwiftLog tests - working-directory: 3rd-party-integrations/SwiftLog - run: swift test - - - name: Archiving Raw Logs - uses: actions/upload-artifact@v5 - if: ${{ failure() || cancelled() }} - with: - name: raw-output-swiftlog-integration - path: | - 3rd-party-integrations/SwiftLog/.build/**/*.log - - - 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. diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index a05c2f1a6e..92d6bfb491 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -88,11 +88,6 @@ jobs: if: ${{!inputs.should_skip}} steps: - uses: actions/checkout@v6 - - name: Test - run: | - ls -la . - ls -la sentry-cocoa - ls -la ${{ inputs.working_directory }} - name: Select Xcode version working-directory: ${{ inputs.working_directory }} run: ${{ inputs.path_to_scripts_folder }}/ci-select-xcode.sh "$XCODE_VERSION" From e7db08912a0753811f8c7b8db2e65453f2ef228c Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 17:02:03 -0300 Subject: [PATCH 18/21] Update path --- .github/workflows/integrations-swift-log.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index e903a972d9..e3f1c08ed4 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -61,7 +61,7 @@ jobs: working-directory: 3rd-party-integrations/SwiftLog shell: bash run: | - ../../../scripts/prepare-package.sh \ + ../../scripts/prepare-package.sh \ --package-file Package.swift \ --update-path-to-sentry-cocoa true - name: Run SPM Tests @@ -77,7 +77,7 @@ jobs: name: SwiftLog scheme: SentrySwiftLog working_directory: 3rd-party-integrations/SwiftLog - path_to_scripts_folder: ../../../scripts + path_to_scripts_folder: ../../scripts xcode: ${{ matrix.xcode }} test-destination-os: ${{ matrix.test-destination-os }} device: ${{ matrix.device }} From 4162a716151cd7291d40989ea943c49c5406deea Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 17:07:24 -0300 Subject: [PATCH 19/21] Update path in prepare-package.sh for Sentry Cocoa package reference --- .github/workflows/integrations-swift-log.yml | 1 + .github/workflows/unit-test-common.yml | 14 ++++++++++++++ scripts/prepare-package.sh | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index e3f1c08ed4..459d44c3aa 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -84,6 +84,7 @@ jobs: platform: ${{ matrix.platform }} runs-on: ${{ matrix.macos_version }} timeout: 10 + update_path_to_sentry_cocoa: true strategy: fail-fast: false matrix: diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index 92d6bfb491..e49742bfc0 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -80,6 +80,12 @@ on: required: false type: string + update_path_to_sentry_cocoa: + description: "The path to the scripts folder" + default: false + required: false + type: boolean + jobs: unit-tests: name: Unit ${{inputs.name}} @@ -137,6 +143,14 @@ jobs: OS_VERSION: ${{ inputs.test-destination-os }} run: ${{ inputs.path_to_scripts_folder }}/ci-boot-simulator.sh --xcode "$XCODE_VERSION" --device "$DEVICE_NAME" --os-version "$OS_VERSION" + - name: Prepare Package.swift + working-directory: ${{ inputs.working_directory }} + shell: bash + run: | + ${{ inputs.path_to_scripts_folder }}/prepare-package.sh \ + --package-file Package.swift \ + --update-path-to-sentry-cocoa true + # We split building and running tests in two steps so we know how long running the tests takes. - name: Build Tests working-directory: ${{ inputs.working_directory }} diff --git a/scripts/prepare-package.sh b/scripts/prepare-package.sh index 5ab574253f..1e8c0eea39 100755 --- a/scripts/prepare-package.sh +++ b/scripts/prepare-package.sh @@ -140,7 +140,7 @@ var targets: [Target] = [\ fi if is_enabled "$UPDATE_PATH_TO_SENTRY_COCOA"; then - sed -i '' 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(path: "'../../../'")|g' "$PACKAGE_FILE" + sed -i '' 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(path: "'../../'")|g' "$PACKAGE_FILE" fi echo From 2fd7b3fadc1514eca3f307f5748b3a2d5a20b9d8 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 17:30:02 -0300 Subject: [PATCH 20/21] Add support for testing SPM packages in CI workflows --- .github/workflows/integrations-swift-log.yml | 1 + .github/workflows/unit-test-common.yml | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index 459d44c3aa..a947c9d579 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -85,6 +85,7 @@ jobs: runs-on: ${{ matrix.macos_version }} timeout: 10 update_path_to_sentry_cocoa: true + test_spm_package: true strategy: fail-fast: false matrix: diff --git a/.github/workflows/unit-test-common.yml b/.github/workflows/unit-test-common.yml index e49742bfc0..aa1aaee311 100644 --- a/.github/workflows/unit-test-common.yml +++ b/.github/workflows/unit-test-common.yml @@ -86,6 +86,12 @@ on: required: false type: boolean + test_spm_package: + description: "Whether to test the SPM package" + default: false + required: false + type: boolean + jobs: unit-tests: name: Unit ${{inputs.name}} @@ -169,7 +175,7 @@ jobs: --command build-for-testing \ --device "$DEVICE_NAME" \ --configuration TestCI \ - --scheme "$SCHEME" + --scheme "$SCHEME" ${{ inputs.test_spm_package && '--spm-project' || '' }} # Run Flaky Tests TestPlan which has a retry mechanism on failure. # We intentionally run these before the other test plan to fail early. @@ -217,7 +223,7 @@ jobs: --command test-without-building \ --device "$DEVICE_NAME" \ --configuration TestCI \ - --scheme "$SCHEME" \ + --scheme "$SCHEME" ${{ inputs.test_spm_package && '--spm-project' || '' }} \ --result-bundle results.xcresult - name: Publish Test Report From 250507bd4d1a9fe551d4c205578ad1e76a488490 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 4 Dec 2025 17:30:39 -0300 Subject: [PATCH 21/21] Add comment --- .github/workflows/integrations-swift-log.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integrations-swift-log.yml b/.github/workflows/integrations-swift-log.yml index a947c9d579..c2095db4f5 100644 --- a/.github/workflows/integrations-swift-log.yml +++ b/.github/workflows/integrations-swift-log.yml @@ -45,6 +45,7 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml + # TODO: All tests here are validating against the released SPM package, so we need to build the XCFramework first. spm-integrations-tests: name: "SPM Tests for Swift Log" needs: files-changed