Skip to content

RUM-7562: Provide SDK commit SHA1 to the Shopist App#2993

Merged
kikoveiga merged 3 commits into
developfrom
kikoveiga/RUM-7562/sha1-snapshot
Nov 12, 2025
Merged

RUM-7562: Provide SDK commit SHA1 to the Shopist App#2993
kikoveiga merged 3 commits into
developfrom
kikoveiga/RUM-7562/sha1-snapshot

Conversation

@kikoveiga

@kikoveiga kikoveiga commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the latest Git commit SHA1 to the dd-sdk-android-core build.gradle file as a BuildConfig constant, so the Shopist app can send it as a global RUM attribute.

Motivation

The Shopist app uses SNAPSHOT versions of the SDK. When multiple snapshot builds are published to the repository, it becomes difficult to determine which exact commit was used in a particular release.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@kikoveiga kikoveiga self-assigned this Nov 7, 2025
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 7, 2025

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 100.00%
Total Coverage: 71.23% (+0.12%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3918198 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter

codecov-commenter commented Nov 7, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.27%. Comparing base (d96dcda) to head (3918198).
⚠️ Report is 1109 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2993      +/-   ##
===========================================
- Coverage    71.34%   71.27%   -0.06%     
===========================================
  Files          859      859              
  Lines        31309    31314       +5     
  Branches      5275     5275              
===========================================
- Hits         22335    22319      -16     
- Misses        7505     7522      +17     
- Partials      1469     1473       +4     

see 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@satween

satween commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

LGTM, but question is - will you have access to this BuildConfig field from the Shopist app ?

@kikoveiga kikoveiga changed the title RUM-7562: Include git commit sha1 inside the publishing config RUM-7562: Provide SDK Snapshot Commit SHA1 to the Shopist App Nov 11, 2025
@kikoveiga kikoveiga changed the title RUM-7562: Provide SDK Snapshot Commit SHA1 to the Shopist App RUM-7562: Provide SDK commit SHA1 to the Shopist App Nov 11, 2025
@kikoveiga
kikoveiga marked this pull request as ready for review November 11, 2025 13:51
@kikoveiga
kikoveiga requested review from a team as code owners November 11, 2025 13:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +73
buildConfigField(
"String",
"SDK_COMMIT_SHA1",
"\"${providers.exec {
commandLine("git", "rev-parse", "HEAD")
}.standardOutput.asText.get().trim()}\""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid caching stale commit SHA in BuildConfig

The Git SHA is resolved eagerly by calling providers.exec { … }.standardOutput.asText.get() while configuring SDK_COMMIT_SHA1. When the configuration cache is enabled, Gradle will cache the generated value and skip rerunning this block on subsequent builds as long as the script itself is unchanged. After checking out a different commit, the build will therefore reuse the old cached value and embed an outdated SHA in BuildConfig, which defeats the purpose of exposing the current commit to the app. Consider computing the value at task execution time or wiring the current HEAD into the cache key so configuration cache reuse cannot return a stale SHA.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a valid note. Although we care only about CI builds, so we shouldn't be hit by Configuration Cache there since we don't reuse it so far between the builds (unlike Build Cache), but we may do it in the future.

On another hand, we don't want to run git command for every local build as well, since it may steal some time (although on my machine it takes 0.03s).

Did you consider any other options of adding commit hash to the build?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a valid note. Although we care only about CI builds, so we shouldn't be hit by Configuration Cache there since we don't reuse it so far between the builds (unlike Build Cache), but we may do it in the future.

I tested what Codex mentioned and it didn't happen. The command is rerun everytime the app is built: even with ./gradlew assembleDebug --configuration-cache and when there are no changes to the dd-sdk-android-core module, which is where we do this BuildConfig field.

Did you consider any other options of adding commit hash to the build?

The first implementation was different, it added a property in the .pom file of the SDK release. This was better on the SDK side, as it only ran the git command once per release, but it looked much more complex to parse this .pom file from the Shopist app.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the current solution needs to be optimized, or is the time difference insignificant?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time is insignificant, so let's keep it like that. My concern is only about the caching.

We could write hash to the file using a dedicated task (it can be invoked only from publish jobs, it is not really needed for the local builds) and read it from file declaring it as an input, so that Gradle know that input is invalidated.

But let's keep it simple for now.

@kikoveiga
kikoveiga requested a review from satween November 11, 2025 17:55
@kikoveiga
kikoveiga requested a review from 0xnm November 12, 2025 12:08
@kikoveiga
kikoveiga merged commit bc35e34 into develop Nov 12, 2025
26 of 27 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/RUM-7562/sha1-snapshot branch November 12, 2025 16:02
@ncreated
ncreated restored the kikoveiga/RUM-7562/sha1-snapshot branch April 9, 2026 10:19
@0xnm
0xnm deleted the kikoveiga/RUM-7562/sha1-snapshot branch April 24, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants