Skip to content
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

[eas-cli] release fingerprint:compare #2821

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

quinlanj
Copy link
Member

@quinlanj quinlanj commented Jan 16, 2025

Why

This PR releases eas fingerprint:compare from the hidden state. It also adds support for the following scenarios:

  • eas fingerprint:compare [HASH1] : If provided alone, HASH1 is compared against the current project's fingerprint.
  • eas fingerprint:compare [HASH1] [HASH2]: If two hashes are provided, HASH1 is compared against HASH2.

More details: https://www.notion.so/expo/Soft-fingerprinting-116e5b5735248071951cddcab32ae43d

How

  • Added support for comparing fingerprints using hashes via new command arguments hash1 and hash2
  • Improved platform detection from fingerprint sources
  • Enhanced workflow handling for multi-platform projects
  • Updated the GraphQL schema to use a dedicated Fingerprint type
  • Refactored fingerprint comparison logic into separate functions for better maintainability
  • Added proper error handling for missing or invalid fingerprints

Test Plan

Test the following scenarios:

  • Compare current project with a build, EXPO_STAGING=1 ~/Documents/eas-cli/packages/eas-cli/bin/run fingerprint:compare --build-id 1aa82a8d-6fed-4c4c-ab93-ef07d0c7ca97
  • Compare two specific fingerprint hashes EXPO_STAGING=1 ~/Documents/eas-cli/packages/eas-cli/bin/run fingerprint:compare f0d6a916e73f401d428e6e006e07b12453317ba2 c71a7d475aa6f75291bc93cd74aef395c3c94eee
  • Compare a specific hash with current project EXPO_STAGING=1 ~/Documents/eas-cli/packages/eas-cli/bin/run fingerprint:compare c71a7d475aa6f75291bc93cd74aef395c3c94eee

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

github-actions bot commented Jan 16, 2025

Size Change: +2.21 kB (0%)

Total Size: 53.4 MB

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

compressed-size-action

Copy link

❌ It looks like a changelog entry is missing for this PR. Add it manually to CHANGELOG.md.
⏩ If this PR doesn't require a changelog entry, such as if it's an internal change that doesn't affect the user experience, you can add the "no changelog" label to the PR.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 8.92857% with 102 lines in your changes missing coverage. Please review.

Project coverage is 52.34%. Comparing base (b1edff7) to head (d9597f0).

Files with missing lines Patch % Lines
...ckages/eas-cli/src/commands/fingerprint/compare.ts 5.44% 87 Missing ⚠️
packages/eas-cli/src/utils/fingerprintCli.ts 0.00% 8 Missing ⚠️
...es/eas-cli/src/graphql/queries/FingerprintQuery.ts 41.67% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2821      +/-   ##
==========================================
- Coverage   52.48%   52.34%   -0.14%     
==========================================
  Files         584      585       +1     
  Lines       22626    22701      +75     
  Branches     4464     4478      +14     
==========================================
+ Hits        11873    11880       +7     
- Misses      10718    10786      +68     
  Partials       35       35              

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

@quinlanj quinlanj marked this pull request as ready for review January 16, 2025 07:38
Copy link

Subscribed to pull request

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

Generated by CodeMention

Copy link
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.

Talked offline, but the summary of changes:

To avoid the platform inference, either:
a) if need to calculate fingerprint locally and need a platform, look for a linked build to get the platform from either from build-id flag or from builds linked to that fingerprint. If none is linked, throw error.
b) if need to calculate fingerprint locally, require build-id flag. get platform from build.
c) split this into two commands. I prefer this since the human-readable description of the allowed arg/flag combinations is simpler (see inline comment), but am happy to be overridden if others prefer something else:
1. fingerprint:diff hash1 hash2 - diffs two fingerprints by id/hash. no build/update arg for this one. instead it just simply diffs.
2. fingerprint:diff-local-directory-with-remote --build/--update - diffs local with fingerprint used by a build or an update. this satisfies the requirement of the spec in notion. doesn't take a hash. command name should be something else, but I called it diff-local-directory-with-remote to demonstrate intent.
d) maybe get rid of local-remote compatibility in its own command altogether and instead just include it in the build info (build:info, build:list)? maybe it's too slow for this. could be behind a flag on those commands, i.e. eas build:info <id> --compare-to-local-fingerprint returns {id: ...., isLocalFingerprintCompatible: bool}. I guess maybe not this option since the diff would be helpful.

Couple additional questions:

  1. What is the behavior when a debug fingerprint is compared to a non-debug fingerprint?

@@ -54,70 +80,48 @@ export default class FingerprintCompare extends EasCommand {
nonInteractive,
withServerSideEnvironment: null,
});
if (jsonFlag) {
if (json) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is probably not limited to this command, but I think the way it works is that we'd need to explicitly print to printJsonOnlyOutput in json mode?

Comment on lines +286 to +289
const displayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
const fingerprint = await FingerprintQuery.byHashAsync(graphqlClient, {
appId: projectId,
hash,
Copy link
Member

Choose a reason for hiding this comment

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

parallelize via Promise.all.

edit: or, even better, only fetch the displayName in the error case?

return fingerprint;
}

async function getFingerprintAsync(fingerprintFragment: FingerprintFragment): Promise<Fingerprint> {
Copy link
Member

Choose a reason for hiding this comment

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

optional:

Suggested change
async function getFingerprintAsync(fingerprintFragment: FingerprintFragment): Promise<Fingerprint> {
async function getFingerprintFromFingerprintFragmentAsync(fingerprintFragment: FingerprintFragment): Promise<Fingerprint> {

filters: { hasFingerprint: true },
});
if (!buildId) {
throw new Error(); // exit, explanation already printed in prompt
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new Error(); // exit, explanation already printed in prompt
throw new Error('Must select build with fingerprint for comparison.');

so the output will have both:

No fingerprints have been computed for builds of project ${projectDisplayName}.
Must select build with fingerprint for comparison.

(this matches the exit pattern for similar cases in other commands I believe)

return { ignorePaths };
}

function inferPlatformsFromSource(fingerprint: Fingerprint): AppPlatform[] {
Copy link
Member

Choose a reason for hiding this comment

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

talked about this offline, but I think if we can avoid this by limiting args or splitting out commands that'd be preferable. The main issue is that (I believe) it's possible to create a fingerprint for either platform or both that doesn't have either string being checked for (by using a specially-crafted .fingerprintIgnore or sourceSkips).

static override hidden = true;
static override strict = false;

static override args = [
Copy link
Member

Choose a reason for hiding this comment

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

while the command does the correct thing to error when an invalid combination of args and flags is passed in, I think it might be a bit tough to explain the different combinations that are allowed and what each combination does, and thus potentially cause a UX issue. See my note about maybe splitting them up into different commands based on use case so we can better require and explain different combinations of args.

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