Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,27 @@ high_risk_code: &high_risk_code
- "Sources/Sentry/SentryFileManager.m"
- "Sources/Sentry/SentrySerialization.m"
- "Sources/Sentry/SentrySerialization.h"

run_unit_tests_for_prs: &run_unit_tests_for_prs # Code
- "Sources/**"
- "Tests/**"
- "SentryTestUtils/**"
- "SentryTestUtilsDynamic/**"

# GH Actions
- ".github/workflows/test.yml"
- ".github/file-filters.yml"

# Scripts
- "scripts/ci-select-xcode.sh"
- "scripts/sentry-xcodebuild.sh"
- "scripts/tests-with-thread-sanitizer.sh"

# Other
- "test-server/**"
- "Sentry.xcodeproj"
- "**/*.xctestplan"
- "fastlane/**"
- ".codecov.yml"
- "Brewfile*" # Dependency installation affects test environment
- "Makefile" # Make commands used for CI build setup
59 changes: 43 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@ on:
- release/**

pull_request:
paths:
- "Sources/**"
- "Tests/**"
- "SentryTestUtils/**"
- "SentryTestUtilsDynamic/**" # Dynamic test utilities used by tests
- "test-server/**"
- ".github/workflows/test.yml"
- "fastlane/**"
- "scripts/tests-with-thread-sanitizer.sh"
- "scripts/ci-select-xcode.sh"
- "scripts/sentry-xcodebuild.sh"
- ".codecov.yml"
- "Sentry.xcodeproj"
- "**/*.xctestplan"
- "Makefile" # Make commands used for CI build setup
- "Brewfile*" # Dependency installation affects test environment

# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

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@v4
- 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@v4
Expand Down Expand Up @@ -300,3 +305,25 @@ jobs:
verbose: true
name: sentry-cocoa-unit-tests
flags: unittests-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.test-destination-os }}, unittests

# 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:
[
build-test-server,
unit-tests,
]
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
Loading