Skip to content

Commit 14c2936

Browse files
runningcodeclauderomtsn
authored
build(samples): [Sample Tests 44] Prepare the samples to build outside the SDK build (#6391)
* build(samples): Prepare the samples to build outside the SDK build The samples and Android integration tests are about to become their own builds, which include the SDK build. Several things tie them to the SDK build today: - They call buildSrc's Config, which other builds cannot see. They now name the coordinates directly, the way a customer's build would. - Five samples' shadowJar tasks use buildSrc's MergeSpringMetadataAction, which only the samples use. It moves to build-logic, which the new builds can include. - They pick the Kotlin stdlib version with KotlinCompilerVersion, a compiler-internal class that came from buildSrc's classpath. They now use KGP's getKotlinPluginVersion(), which returns the same version. - AGP came from Config.AGP on the root buildscript classpath. A composite build must use a single AGP version, so it now comes from the version catalog, and each build's settings applies the AGP matrix job's VERSION_AGP override. - The javac -Xlint:all -Werror flags came from the root allprojects block. They move to the io.sentry.jdk-target convention, which every subproject already applies and the new builds can apply too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Apply suggestion from @romtsn * build(samples): Move the Android sample to its own build The Android sample is now a standalone Gradle build that includes the SDK build. It depends on io.sentry:* coordinates, which Gradle substitutes with the SDK's projects, so there is nothing to publish first. The SDK build doesn't include it back, so the sample's plugins (KSP, SQLDelight, Room, CameraX) no longer load in the SDK build. The macrobenchmark moves into the sample's build, because AGP requires a benchmark and the app it targets to be in the same build. Root check and spotlessApply no longer reach the sample, so preMerge runs the sample build's check, and the format workflow runs its spotlessApply. That check covers what the root check ran for it: lint, unit tests, SQLDelight migrations and spotless. Run it with ./gradlew -p sentry-samples/sentry-samples-android <task>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Run the Android sample's check in its own workflow Instead of adding it to `make preMerge`, which the SDK's Build job runs, a new Samples workflow runs the Android sample build's `check` as its own job. A broken sample then fails its own check, it runs in parallel with the SDK build, and the Build job doesn't get longer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Drop the Gradle encryption key and buildSrc cache from the Samples workflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Check out the default ref without submodules in the Samples workflow The head-SHA ref only matters for build.yml's snapshot upload, and the repository has had no submodules since #3189. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Link the Android sample's Gradle files to the SDK build's gradle.properties, gradlew, gradle/wrapper and gradle/gradle-daemon-jvm.properties are now symlinks to the SDK build's files. Both builds pick the same daemon JDK and JVM arguments, so they can share a daemon, and the sample reads the SDK version from the versionName property instead of parsing the root file. The copied gradle.properties had drifted from the root one (-Xmx6g and CrashOnOutOfMemoryError instead of -Xmx8g and HeapDumpOnOutOfMemoryError). Dependabot also scans the sample build, so the Develocity plugins in its settings stay current. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Drop the JUnit report step from the Samples workflow The samples and integration test builds have no unit tests, and phoenix-actions/test-reporting fails the job when it finds no JUnit XML, even with fail-on-error set to false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Bring back make format for every build The root spotlessApply can't reach the Android sample, because the SDK build doesn't include it. make format runs spotlessApply in the root and in the sample build, and the format workflow, AGENTS.md, CONTRIBUTING.md and the create-java-pr skill use it. CONTRIBUTING.md already documented make format, which #4476 removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Read the sample's SDK version through the catalog The sample's settings now add versionName to the catalog as libs.versions.sentry, as the other separate builds do, and use the root build's Develocity plugin version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Use the setup-gradle version of the other workflows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the comment on the macrobenchmark's target project Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the header comment from the Android sample's settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Move the Android integration tests to their own build sentry-uitest-android, sentry-uitest-android-critical and test-app-size are now a standalone Gradle build that includes the SDK build, like the Android sample. They depend on io.sentry:* coordinates, which Gradle substitutes with the SDK's projects, including the unpublished sentry-test-support. The SDK build doesn't include them back, so SAGP, errorprone's uitest checks and their AndroidX test dependencies no longer load in the SDK build. AGP stays shared: a composite build can only use one AGP version, so the AGP matrix job's VERSION_AGP still applies to both builds. Root check and spotlessApply no longer reach these apps, so preMerge runs this build's check, which covers what the root check ran for them: lint, detekt and spotless. The format workflow runs its spotlessApply, and the AGP matrix, UI test and size workflows call it with -p. APK paths don't change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Run the Android integration tests' check in the Samples workflow Adds the integration tests build to the Samples workflow's matrix instead of a `make preMerge` target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build: Drop the root's SAGP declaration and local SAGP repository With the Android sample and integration tests in their own builds, no project in the SDK build applies the Sentry Android Gradle Plugin. The root no longer declares it or looks it up in mavenLocal when useSagp is set; those builds declare it and handle useSagp themselves. The root keeps the AGP declaration: the SDK's Android modules apply com.android.library without a version and get AGP from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Link the integration tests' Gradle files to the SDK build's gradle.properties, gradlew, gradle/wrapper and gradle/gradle-daemon-jvm.properties are now symlinks to the SDK build's files, as in the Android sample. The copied gradle.properties had drifted from the root one (-Xmx6g and CrashOnOutOfMemoryError), and the build had no wrapper or daemon JDK pin. The SDK version now comes from the shared versionName property instead of parsing the root file. The root drops android.experimental.lint.version. It equals the lint bundled with AGP 9.4.0, so it changes nothing for the SDK build, and sentry-uitest-android's warningsAsErrors fails on it once the integration tests share the root gradle.properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Include each integration test project on its own line Adding or removing a project then changes only its own line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Keep the integration tests' Develocity and dependency versions current The integration tests' settings use the root build's Develocity plugin version, and Dependabot also scans their build, as it does the Android sample's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the comment on the integration tests' root plugins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the header comment from the integration tests' settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
1 parent 1b8668a commit 14c2936

59 files changed

Lines changed: 426 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/create-java-pr/SKILL.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`,
7474
## Step 2: Format Code and Regenerate API Files
7575

7676
```bash
77-
./gradlew spotlessApply updateKotlinAbi
77+
make format api
7878
```
7979

80-
This is **required** before every PR in this repo. It formats all Java/Kotlin code via Spotless and regenerates the `.api` binary compatibility files.
80+
This is **required** before every PR in this repo. It formats all Java/Kotlin code via Spotless, including the separate builds the root `spotlessApply` doesn't reach, and regenerates the `.api` binary compatibility files.
8181
8282
If the command fails, diagnose and fix the issue before continuing.
8383

‎.github/dependabot.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ registries:
77
password: dummy # Required by dependabot
88
updates:
99
- package-ecosystem: "gradle"
10-
directory: "/"
10+
# The root build doesn't include the separate sample and test builds.
11+
directories:
12+
- "/"
13+
- "/sentry-samples/sentry-samples-android"
14+
- "/sentry-android-integration-tests"
1115
registries:
1216
- gradle-plugin-portal
1317
schedule:

‎.github/workflows/format-code.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
2121

2222
- name: Format with spotlessApply
23-
run: ./gradlew spotlessApply
23+
run: make format
2424

2525
# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
2626
# we need to pass the current branch, otherwise we can't commit the changes.

‎.github/workflows/integration-tests-macrobenchmark.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Integration Tests - Macrobenchmark'
2-
# Runs the sentry-uitest-android-macrobenchmark cold-start benchmark on a Sauce Labs real
2+
# Runs the sentry-samples-android macrobenchmark cold-start benchmark on a Sauce Labs real
33
# device and recovers timeToInitialDisplay from the device log.
44
#
55
on:
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Assemble target app and Macrobenchmark apk
3535
if: env.SAUCE_USERNAME != null
36-
run: ./gradlew :sentry-samples:sentry-samples-android:assembleRelease :sentry-android-integration-tests:sentry-uitest-android-macrobenchmark:assembleBenchmark
36+
run: ./gradlew -p sentry-samples/sentry-samples-android :assembleRelease :macrobenchmark:assembleBenchmark
3737

3838
- name: Run Macrobenchmark in SauceLab
3939
uses: saucelabs/saucectl-run-action@283660aa934c02723c497efa151d582a3acc5801 # pin@v3

‎.github/workflows/integration-tests-size.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
3030

3131
- name: Size Analysis
32-
run: ./gradlew :sentry-android-integration-tests:test-app-size:bundleRelease
32+
run: ./gradlew -p sentry-android-integration-tests :test-app-size:bundleRelease
3333
env:
3434
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

‎.github/workflows/samples.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Samples'
2+
# Runs `check` in each build the SDK build doesn't include, so a broken sample or
3+
# integration test fails its own job instead of the SDK's Build job.
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check:
16+
name: Check ${{ matrix.name }}
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- name: sentry-samples-android
24+
path: sentry-samples/sentry-samples-android
25+
- name: sentry-android-integration-tests
26+
path: sentry-android-integration-tests
27+
28+
steps:
29+
- name: Checkout Repo
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
32+
- name: Setup Java Version
33+
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
34+
with:
35+
distribution: 'temurin'
36+
java-version: '21'
37+
38+
- name: Setup Gradle
39+
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
40+
41+
- name: Run Tests and Lint
42+
run: ./gradlew -p ${{ matrix.path }} check
43+
44+
- name: Upload test results
45+
if: always()
46+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
47+
with:
48+
name: test-results-${{ matrix.name }}
49+
path: |
50+
**/build/reports/*

‎.sauce/sentry-uitest-android-macrobenchmark.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defaults:
1515

1616
espresso:
1717
app: ./sentry-samples/sentry-samples-android/build/outputs/apk/release/sentry-samples-android-release.apk
18-
testApp: ./sentry-android-integration-tests/sentry-uitest-android-macrobenchmark/build/outputs/apk/benchmark/sentry-uitest-android-macrobenchmark-benchmark.apk
18+
testApp: ./sentry-samples/sentry-samples-android/macrobenchmark/build/outputs/apk/benchmark/macrobenchmark-benchmark.apk
1919

2020
suites:
2121

‎AGENTS.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ The project uses **Gradle** with Kotlin DSL. Key build files:
4141
## Essential Commands
4242

4343
```bash
44-
# Format code and regenerate .api files (REQUIRED before committing)
45-
./gradlew spotlessApply updateKotlinAbi
44+
# Format code in every build and regenerate .api files (REQUIRED before committing)
45+
make format api
4646

4747
# Run all tests and linter
4848
./gradlew check
@@ -59,11 +59,14 @@ resolves the per-module test task, including integration test suites, for you.
5959

6060
### Android-Specific Commands
6161
```bash
62-
# Assemble Android test APKs
63-
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest
62+
# Assemble Android test APKs, in a separate Gradle build that includes this one
63+
./gradlew -p sentry-android-integration-tests :sentry-uitest-android:assembleRelease :sentry-uitest-android:assembleAndroidTest
6464

6565
# Run critical UI tests
6666
./scripts/test-ui-critical.sh
67+
68+
# Build the Android sample, a separate Gradle build that includes this one
69+
./gradlew -p sentry-samples/sentry-samples-android assembleDebug
6770
```
6871

6972
## Development Workflow Rules
@@ -74,7 +77,7 @@ resolves the per-module test task, including integration test suites, for you.
7477
3. **Use todo tracking**: Work through todo items, marking them as complete as you go
7578
4. **High-level communication**: Give high-level explanations of changes made, not step-by-step descriptions
7679
5. **Simplicity first**: Make every task and code change as simple as possible. Avoid massive or complex changes. Impact as little code as possible.
77-
6. **Format and regenerate**: Once done, format code and regenerate .api files: `./gradlew spotlessApply updateKotlinAbi`
80+
6. **Format and regenerate**: Once done, format code and regenerate .api files: `make format api`
7881
7. **Propose commit**: As final step, git stage relevant files and propose (but not execute) a single git commit command. This applies to implementation work; when the task is to open a PR, the `create-java-pr` skill takes over from here and does commit, push, and open it.
7982

8083
## Repository Skills
@@ -110,7 +113,7 @@ The repository is organized into multiple modules:
110113

111114
### Utility Modules
112115
- **`sentry-test-support`** - Shared test utilities, including `MockSentryServer` and envelope matchers
113-
- **`sentry-samples`** - Example applications
116+
- **`sentry-samples`** - Example applications. `sentry-samples-android` is a separate Gradle build that includes this one, so root tasks such as `check` and `spotlessApply` don't reach it
114117
- **`sentry-bom`** - Bill of Materials for dependency management
115118

116119
### Key Architectural Patterns

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ To format the changed code and make CI happy you can run:
7373
make format
7474
```
7575

76-
or
77-
78-
```shell
79-
./gradlew spotlessApply
80-
```
76+
`./gradlew spotlessApply` alone formats only the SDK build, not the separate builds it doesn't include, such as the Android sample.
8177

8278
# Binary compatibility validation
8379

‎Makefile‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all clean compile javadocs dryRelease update checkFormat api assembleUiTestRelease assembleUiTestCriticalRelease runUiTestCritical check preMerge publish
1+
.PHONY: all clean compile javadocs dryRelease update format checkFormat api assembleUiTestRelease assembleUiTestCriticalRelease runUiTestCritical check preMerge publish
22

33
all: stop clean javadocs compile
44
assembleUiTests: assembleUiTestRelease
@@ -25,21 +25,29 @@ dryRelease:
2525
update:
2626
./gradlew dependencyUpdates -Drevision=release
2727

28+
# Spotless formats the code. The root spotlessApply doesn't reach the separate builds.
29+
format:
30+
./gradlew spotlessApply
31+
./gradlew -p sentry-samples/sentry-samples-android spotlessApply
32+
./gradlew -p sentry-android-integration-tests spotlessApply
33+
2834
# Spotless check's code
2935
checkFormat:
3036
./gradlew spotlessJavaCheck spotlessKotlinCheck
37+
./gradlew -p sentry-samples/sentry-samples-android spotlessJavaCheck spotlessKotlinCheck
38+
./gradlew -p sentry-android-integration-tests spotlessJavaCheck spotlessKotlinCheck
3139

3240
# Binary compatibility validator
3341
api:
3442
./gradlew updateKotlinAbi
3543

3644
# Assemble release and Android test apk of the uitest-android module
3745
assembleUiTestRelease:
38-
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest
46+
./gradlew -p sentry-android-integration-tests :sentry-uitest-android:assembleRelease :sentry-uitest-android:assembleAndroidTest
3947

4048
# Assemble release of the uitest-android-critical module
4149
assembleUiTestCriticalRelease:
42-
./gradlew :sentry-android-integration-tests:sentry-uitest-android-critical:assembleRelease
50+
./gradlew -p sentry-android-integration-tests :sentry-uitest-android-critical:assembleRelease
4351

4452
# Run Maestro tests for the uitest-android-critical module
4553
runUiTestCritical:

0 commit comments

Comments
 (0)