diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 4d7459783d..bb32146f38 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -25,7 +25,6 @@ run_unit_tests_for_prs: &run_unit_tests_for_prs - "SentryTestUtils/**" - "SentryTestUtilsDynamic/**" - "SentryTestUtilsTests/**" - - "3rd-party-integrations/**" # GH Actions - ".github/workflows/test.yml" @@ -528,3 +527,21 @@ run_size_analysis_for_prs: &run_size_analysis_for_prs # Build configuration - "Makefile" - "Brewfile*" + +run_3rd_party_integrations_tests_for_prs: &run_3rd_party_integrations_tests_for_prs + - "Sources/**" + - "3rd-party-integrations/**" + + # GH Actions + - ".github/workflows/test-3rd-party-integrations.yml" + - ".github/file-filters.yml" + + # Scripts + - "scripts/ci-select-xcode.sh" + - "scripts/ci-utils.sh" + - "scripts/ci-diagnostics.sh" + - "scripts/prepare-package.sh" + - "scripts/build-xcframework-local.sh" + + # Project files + - "Package*.swift" diff --git a/.github/workflows/test-3rd-party-integrations.yml b/.github/workflows/test-3rd-party-integrations.yml new file mode 100644 index 0000000000..a664d85a25 --- /dev/null +++ b/.github/workflows/test-3rd-party-integrations.yml @@ -0,0 +1,132 @@ +name: Test 3rd Party 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 tests for 3rd-party integrations. + # If yes, the job will output a flag that will be used by the next job to run the tests for 3rd-party integrations. + # If no, the job will output a flag that will be used by the next job to skip running the tests for 3rd-party integrations. + # At the end of this workflow, we run a check that validates that either all tests for 3rd-party integrations 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_3rd_party_integrations_tests_for_prs: ${{ steps.changes.outputs.run_3rd_party_integrations_tests_for_prs }} + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + - name: Get changed files + id: changes + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + + # Build xcframeworks from source code once for all integration tests. + # This ensures tests use the current source code instead of the latest GitHub release. + # We only build the Static variant since 3rd-party integrations only use the "Sentry" product. + # Intentionally skipped on release branches. + build-xcframeworks: + name: Build XCFrameworks + needs: files-changed + if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_3rd_party_integrations_tests_for_prs == 'true') + runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] + timeout-minutes: 30 + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + - name: Select Xcode + run: ./scripts/ci-select-xcode.sh 16.4 + - name: Build XCFramework (Static) + run: ./scripts/build-xcframework-local.sh macOSOnly StaticOnly --not-signed + - name: Upload XCFrameworks + uses: actions/upload-artifact@v6 + with: + name: xcframeworks-for-3rd-party-integration-tests + path: "XCFrameworkBuildPath/*.xcframework.zip" + retention-days: 1 + + # SPM tests for all 3rd-party integrations + test-integrations-spm: + name: SPM Tests | ${{matrix.integration_dir}} + needs: [files-changed, build-xcframeworks] + if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_3rd_party_integrations_tests_for_prs == 'true') + runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - integration_dir: SentrySwiftLog + - integration_dir: SentrySwiftyBeaver + - integration_dir: SentryCocoaLumberjack + - integration_dir: SentryPulse + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + - name: Select Xcode + run: ./scripts/ci-select-xcode.sh 16.4 + - name: Download XCFrameworks + uses: actions/download-artifact@v7 + with: + name: xcframeworks-for-3rd-party-integration-tests + - name: Modify Package.swift to use local xcframeworks + run: ./scripts/prepare-package.sh --package-file Package.swift --is-pr true --remove-duplicate true --change-path true + - name: Use local sentry-cocoa + working-directory: 3rd-party-integrations/${{matrix.integration_dir}} + run: | + sed -i '' 's|\.package(url: "https://github\.com/getsentry/sentry-cocoa", from: "[^"]*")|.package(name: "sentry-cocoa", path: "../..")|g' Package.swift + - name: Run SPM Tests + working-directory: 3rd-party-integrations/${{matrix.integration_dir}} + run: swift test + - name: Archiving Raw Logs + uses: actions/upload-artifact@v6 + if: ${{ failure() || cancelled() }} + with: + name: raw-output-${{matrix.integration_dir}}-integration + path: | + 3rd-party-integrations/${{matrix.integration_dir}}/.build/**/*.log + - name: Run CI Diagnostics + if: failure() + run: ./scripts/ci-diagnostics.sh + + unit-tests-required-check: + needs: + [ + ready-to-merge-gate, + files-changed, + build-xcframeworks, + test-integrations-spm, + ] + name: 3rd Party Integration 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 + 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 3rd party integration test jobs has failed." && exit 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c01272fdd..e663427a57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -360,134 +360,6 @@ jobs: device: "Apple Vision Pro" timeout: 30 - # This will be replaced once #6945 is merged. - swiftlog-integration-unit-tests: - name: SentrySwiftLog Unit Tests - if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_unit_tests_for_prs == 'true') - needs: files-changed - runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] - 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/SentrySwiftLog - run: swift package edit sentry-cocoa --path ../.. - - - name: Run SwiftLog tests - working-directory: 3rd-party-integrations/SentrySwiftLog - run: swift test - - - name: Archiving Raw Logs - uses: actions/upload-artifact@v6 - if: ${{ failure() || cancelled() }} - with: - name: raw-output-swiftlog-integration - path: | - 3rd-party-integrations/SentrySwiftLog/.build/**/*.log - - - name: Run CI Diagnostics - if: failure() - run: ./scripts/ci-diagnostics.sh - - # This will be replaced once #6945 is merged. - swiftybeaver-integration-unit-tests: - name: SentrySwiftyBeaver Unit Tests - if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_unit_tests_for_prs == 'true') - needs: files-changed - runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] - 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/SentrySwiftyBeaver - run: swift package edit sentry-cocoa --path ../.. - - - name: Run SwiftyBeaver tests - working-directory: 3rd-party-integrations/SentrySwiftyBeaver - run: swift test - - - name: Archiving Raw Logs - uses: actions/upload-artifact@v6 - if: ${{ failure() || cancelled() }} - with: - name: raw-output-swiftybeaver-integration - path: | - 3rd-party-integrations/SentrySwiftyBeaver/.build/**/*.log - - - name: Run CI Diagnostics - if: failure() - run: ./scripts/ci-diagnostics.sh - - # This will be replaced once #6945 is merged. - cocoalumberjack-integration-unit-tests: - name: SentryCocoaLumberjack Unit Tests - if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_unit_tests_for_prs == 'true') - needs: files-changed - runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] - 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/SentryCocoaLumberjack - run: swift package edit sentry-cocoa --path ../.. - - - name: Run CocoaLumberjack tests - working-directory: 3rd-party-integrations/SentryCocoaLumberjack - run: swift test - - - name: Archiving Raw Logs - uses: actions/upload-artifact@v6 - if: ${{ failure() || cancelled() }} - with: - name: raw-output-cocoalumberjack-integration - path: | - 3rd-party-integrations/SentryCocoaLumberjack/.build/**/*.log - - - name: Run CI Diagnostics - if: failure() - run: ./scripts/ci-diagnostics.sh - - # This will be replaced once #6945 is merged. - pulse-integration-unit-tests: - name: SentryPulse Unit Tests - if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_unit_tests_for_prs == 'true') - needs: files-changed - runs-on: ["ghcr.io/cirruslabs/macos-runner:sequoia", "runner_group_id:10"] - 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/SentryPulse - run: swift package edit sentry-cocoa --path ../.. - - - name: Run Pulse tests - working-directory: 3rd-party-integrations/SentryPulse - run: swift test - - - name: Archiving Raw Logs - uses: actions/upload-artifact@v6 - if: ${{ failure() || cancelled() }} - with: - name: raw-output-pulse-integration - path: | - 3rd-party-integrations/SentryPulse/.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. @@ -499,10 +371,6 @@ jobs: build-test-server, distribution-tests, unit-tests, - swiftlog-integration-unit-tests, - swiftybeaver-integration-unit-tests, - cocoalumberjack-integration-unit-tests, - pulse-integration-unit-tests, ready-to-merge-gate, unit-tests-with-test-server, ]