From 9a12a62dfa9ade613f89f3722169be5d13144ab1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 27 Aug 2025 17:13:35 +0000 Subject: [PATCH 1/3] chore(ci): Add required checks job for build [skip ci] - Add run_build_for_prs filter to .github/file-filters.yml containing all paths from build.yml's current pull_request paths - Remove paths filtering from build.yml so workflow runs always for all pull requests - Add files-changed job that detects file changes using the new filter - Make all main jobs conditional with file change detection and needs dependency - Add build-required-check job at end that validates completion using if: always() pattern - Follow exact pattern from api-stability.yml and test.yml workflows This enables reliable required checks for build workflow that can be used in branch protection rules. --- .github/file-filters.yml | 24 +++++++++++ .github/workflows/build.yml | 83 ++++++++++++++++++++++++++++++------- 2 files changed, 92 insertions(+), 15 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index f1862e54fe..44b817ac23 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -64,3 +64,27 @@ run_api_stability_for_prs: &run_api_stability_for_prs # API-related code - "Makefile" # Make commands used for API generation - "sdk_api.json" - "sdk_api_v9.json" + +run_build_for_prs: &run_build_for_prs # Build-related code + - "Sources/**" + - "test-server/**" + - "Samples/**" + + # GH Actions + - ".github/workflows/build.yml" + - ".github/file-filters.yml" + + # Project files + - "Sentry.xcworkspace/**" + - "Sentry.xcodeproj/**" + - "Package*.swift" + + # Scripts + - "scripts/ci-select-xcode.sh" + - "scripts/ci-diagnostics.sh" + + # Other + - "fastlane/**" + - "Gemfile.lock" + - "Makefile" # Make commands used for CI build setup + - "Brewfile*" # Dependency installation affects build environment diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9de2235eb..bbe08d9170 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,20 +6,6 @@ on: - release/** pull_request: - paths: - - "Sources/**" - - "test-server/**" - - "Samples/**" - - ".github/workflows/build.yml" - - "fastlane/**" - - "scripts/ci-select-xcode.sh" - - "scripts/ci-diagnostics.sh" - - Sentry.xcworkspace/** - - Sentry.xcodeproj/** - - Gemfile.lock - - "Package*.swift" - - "Makefile" # Make commands used for CI build setup - - "Brewfile*" # Dependency installation affects build environment # Concurrency configuration: # - We use workflow-specific concurrency groups to prevent multiple build runs of the same code, @@ -33,10 +19,32 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # This job detects if the PR contains changes that require running build checks. + # If yes, the job will output a flag that will be used by the next job to run the build checks. + # If no, the job will output a flag that will be used by the next job to skip running the build checks. + # At the end of this workflow, we run a check that validates that either all build checks passed or were + # skipped, called build-required-check. + files-changed: + name: Detect File Changes + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + run_build_for_prs: ${{ steps.changes.outputs.run_build_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 + # We had issues that the release build was broken on main. # With this we catch potential issues already in the PR. ios-swift-release: name: Release Build of iOS Swift + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-15 steps: - uses: actions/checkout@v5 @@ -63,6 +71,8 @@ jobs: build-sample: name: Sample ${{ matrix.scheme }} ${{ matrix.config }} + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-15 strategy: fail-fast: false @@ -127,7 +137,8 @@ jobs: name: Build with SPM runs-on: macos-15 # Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions. - if: startsWith(github.ref, 'refs/heads/release/') == false + if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true') + needs: files-changed steps: - uses: actions/checkout@v5 @@ -154,6 +165,8 @@ jobs: build-v9: name: Build SDK v9 + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-15 steps: - uses: actions/checkout@v5 @@ -178,6 +191,8 @@ jobs: check-debug-without-UIKit: name: Check no UIKit linkage (DebugWithoutUIKit) + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-14 steps: - uses: actions/checkout@v5 @@ -201,6 +216,8 @@ jobs: check-release-without-UIKit: name: Check no UIKit linkage (ReleaseWithoutUIKit) + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-14 steps: - uses: actions/checkout@v5 @@ -224,6 +241,8 @@ jobs: check-debug-with-UIKit: name: Check UIKit linkage (Debug) + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-14 steps: - uses: actions/checkout@v5 @@ -247,6 +266,8 @@ jobs: check-release-with-UIKit: name: Check UIKit linkage (Release) + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-14 steps: - uses: actions/checkout@v5 @@ -274,6 +295,8 @@ jobs: check-compiling-async-safe-logs: name: Check compiling Async Safe Logs + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + needs: files-changed runs-on: macos-15 steps: - uses: actions/checkout@v5 @@ -302,3 +325,33 @@ jobs: - name: Debug Xcode environment if: ${{ failure() || cancelled() }} run: ./scripts/ci-diagnostics.sh + + # This check validates that either all build checks passed or were skipped, which allows us + # to make build checks a required check with only running the build checks when required. + # So, we don't have to run build checks, for example, for Changelog or ReadMe changes. + + build-required-check: + needs: + [ + files-changed, + ios-swift-release, + build-sample, + build-spm, + build-v9, + check-debug-without-UIKit, + check-release-without-UIKit, + check-debug-with-UIKit, + check-release-with-UIKit, + check-compiling-async-safe-logs, + ] + name: Build + # 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 build jobs has failed." && exit 1 From 1d019a282eebecf86bf41abb91e7805e503aad56 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Wed, 27 Aug 2025 19:43:41 +0200 Subject: [PATCH 2/3] cleanup --- .github/file-filters.yml | 2 +- .github/workflows/build.yml | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 44b817ac23..69b9b001ab 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -65,7 +65,7 @@ run_api_stability_for_prs: &run_api_stability_for_prs # API-related code - "sdk_api.json" - "sdk_api_v9.json" -run_build_for_prs: &run_build_for_prs # Build-related code +run_build_for_prs: &run_build_for_prs - "Sources/**" - "test-server/**" - "Samples/**" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbe08d9170..d140af80f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,15 +19,9 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - # This job detects if the PR contains changes that require running build checks. - # If yes, the job will output a flag that will be used by the next job to run the build checks. - # If no, the job will output a flag that will be used by the next job to skip running the build checks. - # At the end of this workflow, we run a check that validates that either all build checks passed or were - # skipped, called build-required-check. files-changed: name: Detect File Changes runs-on: ubuntu-latest - # Map a step output to a job output outputs: run_build_for_prs: ${{ steps.changes.outputs.run_build_for_prs }} steps: @@ -43,7 +37,7 @@ jobs: # With this we catch potential issues already in the PR. ios-swift-release: name: Release Build of iOS Swift - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: @@ -71,7 +65,7 @@ jobs: build-sample: name: Sample ${{ matrix.scheme }} ${{ matrix.config }} - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 strategy: @@ -137,7 +131,7 @@ jobs: name: Build with SPM runs-on: macos-15 # Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions. - if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true') + if: startsWith(github.ref, 'refs/heads/release/') == false && needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed steps: - uses: actions/checkout@v5 @@ -165,7 +159,7 @@ jobs: build-v9: name: Build SDK v9 - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: @@ -191,7 +185,7 @@ jobs: check-debug-without-UIKit: name: Check no UIKit linkage (DebugWithoutUIKit) - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -216,7 +210,7 @@ jobs: check-release-without-UIKit: name: Check no UIKit linkage (ReleaseWithoutUIKit) - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -241,7 +235,7 @@ jobs: check-debug-with-UIKit: name: Check UIKit linkage (Debug) - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -266,7 +260,7 @@ jobs: check-release-with-UIKit: name: Check UIKit linkage (Release) - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -295,7 +289,7 @@ jobs: check-compiling-async-safe-logs: name: Check compiling Async Safe Logs - if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' + if: needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: From 51d5c1d24361ca47d6a449f632f73878828dc187 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Wed, 27 Aug 2025 20:08:06 +0200 Subject: [PATCH 3/3] fix run condition --- .github/workflows/build.yml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d140af80f1..cb69dd001e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,8 @@ jobs: # With this we catch potential issues already in the PR. ios-swift-release: name: Release Build of iOS Swift - if: needs.files-changed.outputs.run_build_for_prs == 'true' + # Run the job only for PRs with related changes or non-PR events. + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: @@ -65,7 +66,7 @@ jobs: build-sample: name: Sample ${{ matrix.scheme }} ${{ matrix.config }} - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 strategy: @@ -131,7 +132,7 @@ jobs: name: Build with SPM runs-on: macos-15 # Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions. - if: startsWith(github.ref, 'refs/heads/release/') == false && needs.files-changed.outputs.run_build_for_prs == 'true' + if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true') needs: files-changed steps: - uses: actions/checkout@v5 @@ -159,7 +160,7 @@ jobs: build-v9: name: Build SDK v9 - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: @@ -185,7 +186,7 @@ jobs: check-debug-without-UIKit: name: Check no UIKit linkage (DebugWithoutUIKit) - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -210,7 +211,7 @@ jobs: check-release-without-UIKit: name: Check no UIKit linkage (ReleaseWithoutUIKit) - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -235,7 +236,7 @@ jobs: check-debug-with-UIKit: name: Check UIKit linkage (Debug) - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -260,7 +261,7 @@ jobs: check-release-with-UIKit: name: Check UIKit linkage (Release) - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-14 steps: @@ -289,7 +290,7 @@ jobs: check-compiling-async-safe-logs: name: Check compiling Async Safe Logs - if: needs.files-changed.outputs.run_build_for_prs == 'true' + if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true' needs: files-changed runs-on: macos-15 steps: @@ -320,10 +321,6 @@ jobs: if: ${{ failure() || cancelled() }} run: ./scripts/ci-diagnostics.sh - # This check validates that either all build checks passed or were skipped, which allows us - # to make build checks a required check with only running the build checks when required. - # So, we don't have to run build checks, for example, for Changelog or ReadMe changes. - build-required-check: needs: [