-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat(snapshots): Add @SentrySnapshot runtime annotation (EME-1055) #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
runningcode
wants to merge
1
commit into
main
Choose a base branch
from
no/eme-1055-sentry-snapshot-annotation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .PHONY: compile all dist | ||
|
|
||
| compile: | ||
| ./gradlew assemble | ||
|
|
||
| # build distribution artifacts | ||
| dist: | ||
| ./gradlew distZip --no-parallel | ||
|
|
||
| all: compile dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| plugins { | ||
| alias(libs.plugins.kotlin) | ||
| id("distribution") | ||
| alias(libs.plugins.mavenPublish) | ||
| alias(libs.plugins.spotless) | ||
| } | ||
|
|
||
| spotless { | ||
| kotlin { | ||
| ktfmt(libs.versions.ktfmt.get()).googleStyle() | ||
| target("**/*.kt") | ||
| } | ||
| kotlinGradle { | ||
| target("**/*.kts") | ||
| ktfmt(libs.versions.ktfmt.get()).googleStyle() | ||
| } | ||
| } | ||
|
|
||
| val sep = File.separator | ||
|
|
||
| distributions { | ||
| main { | ||
| contents { | ||
| from("build${sep}libs") | ||
| from("build${sep}publications${sep}maven") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| listOf("distZip", "distTar").forEach { taskName -> | ||
| tasks.named(taskName) { | ||
| dependsOn("publishToMavenLocal") | ||
| onlyIf { inputs.sourceFiles.isEmpty.not().also { require(it) { "No distribution to zip." } } } | ||
| } | ||
| } | ||
|
|
||
| dependencies { compileOnly(libs.androidxAnnotation) } | ||
|
|
||
| plugins.withId("com.vanniktech.maven.publish.base") { | ||
| configure<PublishingExtension> { | ||
| repositories { | ||
| maven { | ||
| name = "mavenTestRepo" | ||
| url = file("${rootProject.projectDir}/../build/mavenTestRepo").toURI() | ||
| } | ||
| maven { | ||
| name = "mavenCentralSnapshots" | ||
| url = uri("https://central.sonatype.com/repository/maven-snapshots/") | ||
| credentials { | ||
| username = findProperty("mavenCentralUsername")?.toString() | ||
| password = findProperty("mavenCentralPassword")?.toString() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| kotlin { jvmToolchain(11) } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1536m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:+CrashOnOutOfMemoryError | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, copied from the sentry-kotlin-compiler-plugin |
||
| org.gradle.caching=true | ||
| org.gradle.parallel=true | ||
|
|
||
| GROUP = io.sentry | ||
| POM_ARTIFACT_ID = sentry-snapshots-runtime | ||
| VERSION_NAME = 6.4.0 | ||
|
|
||
| # publication pom properties | ||
| POM_NAME=Sentry Snapshots Runtime | ||
| POM_DESCRIPTION=Runtime annotations for configuring Sentry snapshot tests | ||
| POM_URL=https://github.com/getsentry/sentry-android-gradle-plugin | ||
| POM_SCM_URL=https://github.com/getsentry/sentry-android-gradle-plugin | ||
| POM_SCM_CONNECTION=scm:git:git://github.com/getsentry/sentry-android-gradle-plugin.git | ||
| POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/getsentry/sentry-android-gradle-plugin.git | ||
|
|
||
| POM_LICENCE_NAME=MIT | ||
| POM_LICENCE_URL=https://github.com/getsentry/sentry-android-gradle-plugin/blob/main/LICENSE | ||
|
|
||
| POM_DEVELOPER_ID=getsentry | ||
| POM_DEVELOPER_NAME=Sentry Team and Contributors | ||
| POM_DEVELOPER_URL=https://github.com/getsentry/ | ||
|
|
||
| RELEASE_SIGNING_ENABLED=false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| rootProject.name = ("sentry-snapshots-runtime") | ||
|
|
||
| dependencyResolutionManagement { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
| versionCatalogs.create("libs") { from(files("../gradle/libs.versions.toml")) } | ||
| repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | ||
| } |
22 changes: 22 additions & 0 deletions
22
sentry-snapshots-runtime/src/main/kotlin/io/sentry/snapshots/runtime/SentrySnapshot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package io.sentry.snapshots.runtime | ||
|
|
||
| import androidx.annotation.FloatRange | ||
|
|
||
| /** | ||
| * Configures how Sentry compares this preview snapshot against the baseline. | ||
| * | ||
| * Apply alongside `@Preview` on a composable to override the global diff threshold on a | ||
| * per-snapshot basis. | ||
| */ | ||
| @Retention(AnnotationRetention.BINARY) | ||
| @Target(AnnotationTarget.FUNCTION) | ||
| annotation class SentrySnapshot( | ||
| /** | ||
| * Minimum pixel-difference percentage required to report this snapshot as changed. Differences | ||
| * below this value are treated as unchanged. | ||
| * | ||
| * Range: `0.0`..`1.0`. Example: `0.01f` reports a change only when at least 1% of pixels differ. | ||
| * Defaults to `0f` (report any difference). | ||
| */ | ||
| @FloatRange(from = 0.0, to = 1.0) val diffThreshold: Float = 0f | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from the
sentry-kotlin-compiler-pluginbut simplified a bit