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] [ENG-9957] Don't overwrite distribution for simulator builds #2073

Conversation

radoslawkrzemien
Copy link
Contributor

@radoslawkrzemien radoslawkrzemien commented Oct 2, 2023

Why

https://linear.app/expo/issue/ENG-9957/fix-internal-distribution-pages-for-simulator-builds
Companion for: expo/eas-build#283, https://github.com/expo/universe/pull/13524, and https://github.com/expo/universe/pull/13523

How

  • distribution value is kept instead of hardcoded to simulator if simulator flag is set, keeping its original value
  • simulator field has been added to metadata to retain its value

Test Plan

Existing tests pass

Screens

Build run with old cli version

Logged in

Internal build

Screenshot 2024-01-31 at 17 03 36

Internal simulator build

Screenshot 2024-01-31 at 17 03 39

Store build

Screenshot 2024-01-31 at 17 03 42

Store simulator build

Screenshot 2024-01-31 at 17 03 47

Not logged in

Internal build

Screenshot 2024-01-31 at 17 04 01

Internal simulator build

Screenshot 2024-01-31 at 17 04 05

Store build

Screenshot 2024-01-31 at 17 04 08

Store simulator build

Screenshot 2024-01-31 at 17 04 13

Build run with new cli version

Logged in

Internal build

Screenshot 2024-01-31 at 16 52 09

Internal simulator build

Screenshot 2024-01-31 at 16 52 17

Store build

Screenshot 2024-01-31 at 16 52 21

Store simulator build

Screenshot 2024-01-31 at 16 52 26

Not logged in

Internal build

Screenshot 2024-01-31 at 16 52 45

Internal simulator build

Screenshot 2024-01-31 at 16 52 49

Store build

Screenshot 2024-01-31 at 16 52 53

Store simulator build

Screenshot 2024-01-31 at 16 52 57

Deployment

  1. www
  2. website
  3. cli

@linear
Copy link

linear bot commented Oct 2, 2023

ENG-9957 Fix internal distribution pages for simulator builds

While looking into ENG-6853I noticed that I wasn't able to access build pages for internal distribution builds that target simulators. We should support people using internal distribution for this case as well, it would allow you to share a URL to your build page where someone could then just press a button to launch in Orbit, or download and do whatever they want with it. This would work fine on Android because APKs are directly installable for devices and emulators.

For example, I created a build with this profile named "simulator": https://github.com/brentvatne/microfoam-app/blob/e29d622809172be8d271622f0a699f306bffb05e/apps/mobile/eas.json#L50-L60

That build should be accessible from an incognito tab without signing in to expo.dev, as is the case with all internal distribution builds, but it is not: https://expo.dev/accounts/brents/projects/microfoam/builds/87343bae-3105-4517-a46b-d3149dea442c

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Size Change: +457 B (0%)

Total Size: 51.5 MB

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

compressed-size-action

@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (ceb561a) 54.16% compared to head (049f177) 54.16%.

Files Patch % Lines
packages/eas-cli/src/commands/build/list.ts 16.67% 4 Missing and 1 partial ⚠️
packages/eas-cli/src/build/metadata.ts 33.34% 2 Missing ⚠️
packages/eas-cli/src/commands/build/run.ts 50.00% 1 Missing ⚠️
packages/eas-cli/src/run/utils.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2073      +/-   ##
==========================================
- Coverage   54.16%   54.16%   -0.00%     
==========================================
  Files         516      516              
  Lines       18808    18814       +6     
  Branches     3968     3969       +1     
==========================================
+ Hits        10186    10188       +2     
- Misses       7931     7934       +3     
- Partials      691      692       +1     

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

('simulator' in ctx.buildProfile && ctx.buildProfile.simulator
? 'simulator'
: ctx.buildProfile.distribution) ?? 'store';
const distribution = ctx.buildProfile.distribution ?? 'store';
Copy link
Member

Choose a reason for hiding this comment

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

This change will break stuff like eas build:run 🤔

I'm wondering if altering the distributionType behavior is necessary 🤔.

Maybe we can add some new field to Metadata to keep the raw buildProfile.distribution value there? I mean it's probably not optimal but I feel that this change can introduce some regressions in some parts of the codebase.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate on why eas build:run would be broken by this?
As for another field for "original distribution" or whatever we want to call it, I'm open for discussion but it feels to me like hacking around an existing hack (overwriting the distribution). I feel like we should remove the reliance on this hardcoded simulator value for distribution instead of building upon it, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, it runs a simulator build and fetches it by filtering by distribution = simulator.
Maybe it should handle both options (distribution = simulator or simulator = true) for a while instead of introducing another field?

Copy link
Contributor

Choose a reason for hiding this comment

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

I concur, we should list builds with both simulator: true and distribution: simulator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…-9957-dont-overwrite-distribution-for-simulator-builds

# Conflicts:
#	packages/eas-cli/package.json
#	packages/eas-cli/src/build/metadata.ts
#	yarn.lock
Updated build:run command to use simulator flag instead of overwritten distribution type

See: https://linear.app/expo/issue/ENG-9957/fix-internal-distribution-pages-for-simulator-builds
@radoslawkrzemien radoslawkrzemien marked this pull request as draft October 30, 2023 14:30
…-9957-dont-overwrite-distribution-for-simulator-builds

# Conflicts:
#	packages/eas-cli/src/build/metadata.ts
#	packages/eas-cli/src/commands/build/run.ts
#	packages/eas-json/package.json
#	yarn.lock
…-9957-dont-overwrite-distribution-for-simulator-builds

# Conflicts:
#	packages/eas-cli/src/graphql/generated.ts
Added warning to build:list command that the distribution=simulator is deprecated

See: https://linear.app/expo/issue/ENG-9957/fix-internal-distribution-pages-for-simulator-builds
@radoslawkrzemien radoslawkrzemien marked this pull request as ready for review January 19, 2024 14:02
Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

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

👍, but I'm with @szdziedzic, I think we should not "break" listing simulator builds for now.

…-9957-dont-overwrite-distribution-for-simulator-builds
@@ -13,6 +13,7 @@ export function isRunnableOnSimulatorOrEmulator(build: BuildFragment): boolean {
build.status === BuildStatus.Finished &&
!!build.artifacts?.applicationArchiveUrl &&
((build.platform === AppPlatform.Ios && build.distribution === DistributionType.Simulator) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
((build.platform === AppPlatform.Ios && build.distribution === DistributionType.Simulator) ||

I guess the isForSimulator already takes care of it?

Copy link
Member

@szdziedzic szdziedzic left a comment

Choose a reason for hiding this comment

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

Looks good, few small comments

('simulator' in ctx.buildProfile && ctx.buildProfile.simulator
? 'simulator'
: ctx.buildProfile.distribution) ?? 'store';
const distribution = ctx.buildProfile.distribution ?? 'store';
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
const distribution = ctx.buildProfile.distribution ?? 'store';
const distribution = ctx.buildProfile.distribution ?? BuildDistributionType.STORE;

Comment on lines 75 to 77
Log.warn(
`Using "distribution" flag with "simulator" value is deprecated - use "simulator" flag instead`
);
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👏

Suggested change
Log.warn(
`Using "distribution" flag with "simulator" value is deprecated - use "simulator" flag instead`
);
Log.warn(
`Using --distribution flag with "simulator" value is deprecated - use --simulator flag instead`
);

@@ -51,6 +52,7 @@ export default class BuildList extends EasCommand {
...EasPaginatedQueryFlags,
limit: getLimitFlagWithCustomValues({ defaultTo: 10, limit: BUILDS_LIMIT }),
...EasNonInteractiveAndJsonFlags,
simulator: Flags.boolean(),
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be good to add a description to this flag, putting emphasis on the fact that it will only filter the iOS simulator builds. People tend to confuse Android emulator with iOS simulator and one could think that this will also query for Android emulator builds.

@@ -51,6 +52,7 @@ export default class BuildList extends EasCommand {
...EasPaginatedQueryFlags,
limit: getLimitFlagWithCustomValues({ defaultTo: 10, limit: BUILDS_LIMIT }),
...EasNonInteractiveAndJsonFlags,
simulator: Flags.boolean(),
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should also enforce that this is only applicable when using the ios value for the --platform flag? What do you think?

Copy link
Member

@szdziedzic szdziedzic left a comment

Choose a reason for hiding this comment

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

Looks good

Remember to regenerate the GQL schema if there are any changes to it in WWW PR

I would also do one test run of the eas build command with the simulator target and see if you are prompted correctly to install it on your device afterward and run the eas build:run command just to double check

@radoslawkrzemien
Copy link
Contributor Author

/changelog-entry chore Add simulator flag to metadata

…-9957-dont-overwrite-distribution-for-simulator-builds

# Conflicts:
#	CHANGELOG.md
@radoslawkrzemien
Copy link
Contributor Author

Added screens for comparison

Copy link

✅ Thank you for adding the changelog entry!

@radoslawkrzemien radoslawkrzemien merged commit 315b5b2 into main Jan 31, 2024
9 checks passed
@radoslawkrzemien radoslawkrzemien deleted the @radoslawkrzemien/ENG-9957-dont-overwrite-distribution-for-simulator-builds branch January 31, 2024 16: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.

3 participants