Skip to content

[eas-cli] add support for build profiles in fingerprint generation#2951

Merged
quinlanj merged 7 commits intomainfrom
03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation
Mar 21, 2025
Merged

[eas-cli] add support for build profiles in fingerprint generation#2951
quinlanj merged 7 commits intomainfrom
03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation

Conversation

@quinlanj
Copy link
Copy Markdown
Member

@quinlanj quinlanj commented Mar 16, 2025

How you can help

This is my current understanding of how a build profile can affect a project's fingerprint. @szdziedzic and @sjchmiela, please let me know if it is correct, or if there are any nuances I am missing!

  • A fingerprint contains the following components which we use to determine compatibility at an app's native layer
  • In eas.json, we have a bunch of build profiles which define a bunch of parameters like build machine types, update channels, etc. However, it is the set of environment variables produced (specifying build profile parameter as input) which ultimately affects the fingerprint. Is there any other way a build profile can affect a fingerprint?

For example, I can define the TEST env var to differ based on the build profile that is chosen:
Screenshot 2025-03-18 at 3 33 58 PM

Next, I configure my app.config.js to determine the bundleIdentifier based on the TEST env var:

function getBundleIdentifier() {
  if (process.env.TEST === "production") {
    return "com.quintest110.stagingsdk52.production";
  } else if (process.env.TEST === "development") {
    return "com.quintest110.stagingsdk52.development";
  } else if (process.env.TEST === "preview") {
    return "com.quintest110.stagingsdk52.preview";
  }
  return "com.quintest110.stagingsdk52";
}

Since the fingerprint relies on the app config, I can see the fingerprint is changed when I run eas fingerprint:generate -p ios --profile production vs eas fingerprint:generate -p ios --profile development here

Why

This PR adds support for build profiles in eas fingeprint:generate by allowing the user to pass in the --profile flag.

How

After a build profile is chosen, the cli takes the generated Env and temporarily sets those env vars while calculating the fingerprint

Tests

  • Different fingerprints with expected diffs are generated with eas fingerprint:generate -p ios --profile production vs eas fingerprint:generate -p ios --profile development here

Copy link
Copy Markdown
Member Author

quinlanj commented Mar 16, 2025

@quinlanj quinlanj force-pushed the 03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation branch from 0953622 to 85d5174 Compare March 16, 2025 08:59
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2025

Size Change: +977 B (0%)

Total Size: 53.4 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 53.4 MB +977 B (0%)

compressed-size-action

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2025

Codecov Report

Attention: Patch coverage is 6.25000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 52.61%. Comparing base (4e8fc05) to head (05281af).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/eas-cli/src/fingerprint/cli.ts 0.00% 8 Missing ⚠️
...kages/eas-cli/src/commands/fingerprint/generate.ts 14.29% 6 Missing ⚠️
packages/eas-cli/src/fingerprint/utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2951      +/-   ##
==========================================
- Coverage   52.64%   52.61%   -0.03%     
==========================================
  Files         590      590              
  Lines       23300    23310      +10     
  Branches     4634     4638       +4     
==========================================
- Hits        12265    12263       -2     
- Misses      11001    11013      +12     
  Partials       34       34              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quinlanj quinlanj force-pushed the 03-08-_eas-cli_fingerprint_generate branch from 50c1faa to 68a8a3e Compare March 17, 2025 23:24
Base automatically changed from 03-08-_eas-cli_fingerprint_generate to main March 18, 2025 00:11
@quinlanj quinlanj force-pushed the 03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation branch from 8037cf6 to 0a22f90 Compare March 18, 2025 22:22
@quinlanj quinlanj requested review from sjchmiela and wschurman March 18, 2025 22:41
@quinlanj quinlanj marked this pull request as ready for review March 18, 2025 22:42
@github-actions
Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @szdziedzic, @khamilowicz, @sjchmiela, @radoslawkrzemien

Generated by CodeMention

Copy link
Copy Markdown
Member

@wschurman wschurman left a comment

Choose a reason for hiding this comment

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

How does this relate to EAS Environment Variables? (the environment flag in eas update). I was under the assumption that we didn't add the environment flag to eas build since this was specified in the eas json profile and they were automatically loaded. As a point of reference, for doing something similar in the github action we use eas env:exec: https://github.com/expo/expo-github-action/blob/main/src/fingerprintUtils.ts#L72

Copy link
Copy Markdown
Member

(requesting changes mainly to put back on your queue for discussion of environment variables, not for inline comments)

@quinlanj
Copy link
Copy Markdown
Member Author

quinlanj commented Mar 20, 2025

@wschurman makes sense (i see this pattern in a lot of other eas cli commands too), i updated the command so that it takes the environment arg instead of profile.

@quinlanj quinlanj requested a review from wschurman March 20, 2025 22:56
Comment on lines +78 to +83
let env: Env | undefined;
if (environment) {
env = environment
? { ...(await getServerSideEnvironmentVariablesAsync()), EXPO_NO_DOTENV: '1' }
: {};
}
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.

Suggested change
let env: Env | undefined;
if (environment) {
env = environment
? { ...(await getServerSideEnvironmentVariablesAsync()), EXPO_NO_DOTENV: '1' }
: {};
}
const env = environment
? { ...(await getServerSideEnvironmentVariablesAsync()), EXPO_NO_DOTENV: '1' }
: undefined;

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.

Also regarding EXPO_NO_DOTENV, I see this is the behavior for eas update for calling into the expo cli (which I assume fingerprint does under the hood hence why we add it to this call), but is it also the behavior for eas build?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i passed EXPO_NO_DOTENV because it is also passed to grab the config elsewhere in eas-cli (npx expo config is a shim over expo/config):

try {
const { stdout } = await spawnAsync(
'npx',
['expo', 'config', '--json', ...(opts.isPublicConfig ? ['--type', 'public'] : [])],
{
cwd: projectDir,
env: {
...process.env,
...opts.env,
EXPO_NO_DOTENV: '1',
},
}
);

under the hood, the fingerprint library calls into the expo/config library

try {
const { stdout } = await spawnAsync(
'npx',
['expo', 'config', '--json', ...(opts.isPublicConfig ? ['--type', 'public'] : [])],
{
cwd: projectDir,
env: {
...process.env,
...opts.env,
EXPO_NO_DOTENV: '1',
},
}
);

Temporary Commit at 3/16/2025, 6:31:01 PM

Temporary Commit at 3/16/2025, 6:37:24 PM

Temporary Commit at 3/16/2025, 7:59:29 PM

Temporary Commit at 3/16/2025, 8:01:21 PM

Temporary Commit at 3/18/2025, 2:38:20 PM

Temporary Commit at 3/18/2025, 3:21:52 PM
@quinlanj quinlanj force-pushed the 03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation branch from 8cd7554 to bfc296d Compare March 21, 2025 14:47
@quinlanj quinlanj merged commit 1da9573 into main Mar 21, 2025
10 checks passed
@quinlanj quinlanj deleted the 03-16-_eas-cli_add_support_for_build_profiles_in_fingerprint_generation branch March 21, 2025 19:21
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.

2 participants