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

Download javy and function-runner directly #4190

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

jeffcharles
Copy link
Contributor

@jeffcharles jeffcharles commented Jul 11, 2024

WHY are these changes introduced?

The current approach for working with Javy and function-runner is the Shopify CLI unconditionally downloads the latest released version of each tool. This means it's impossible to make breaking changes to the command line interface for these tools. Any bugs introduced in the latest released versions of these tools are also rolled out to all users of the Shopify CLI at the same time.

This change makes the Shopify CLI depend on a specific version of Javy and a specific version of function-runner. That way we can be certain that the way the Shopify CLI is invoking tools is compatible with command line interface these tools expose. This also means that if users find a regression in the version of Javy or funtion-runner that the Shopify CLI is using, they can downgrade their Shopify CLI version to use an older version of Javy or function-runner. Similarly, when a new version of Javy or function-runner is released, nightly versions of the Shopify CLI depend on these versions of Javy and function-runner and users can use a nightly version of the Shopify CLI and let us know if there are any issues that weren't caught when releasing the new versions of Javy or the function-runner.

WHAT is this pull request doing?

Instead of using npm exec javy-cli -- [args...] or npm exec @shopify/function-runner -- [args...] to download and install Javy and function-runner, perform the download in the Shopify CLI, and exec the downloaded binary.

How to test your changes?

Assuming you are using MacOS or Linux:

  1. Create a Shopify app containing at least one JS Function extension if you do not already have one.
  2. pnpm shopify app build --path <path_to_app> will perform the initial download of Javy.
  3. Verify there are no errors reported.
  4. pnpm shopify app build --path <path_to_app> will test that it uses the downloaded version of Javy.
  5. Verify there are no errors reported.
  6. echo "{}" | pnpm shopify app function run --path <path_to_js_function_extension> will test the initial download of function-runner.
  7. Verify there are no errors reported.
  8. echo "{}" | pnpm shopify app function run --path <path_to_js_function_extension> will it uses the downloaded version of function-runner.
  9. Verify there are no errors reported.

If you need to re-test the original downloads and are using MacOS, run rm -r packages/app/dist/cli/services/bin.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-management

Copy link
Contributor

github-actions bot commented Jul 11, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.55% (+0.19% 🔼)
7594/10467
🟡 Branches
69.27% (+0.01% 🔼)
3737/5395
🟡 Functions
71.5% (+0.22% 🔼)
2002/2800
🟡 Lines
72.88% (+0.24% 🔼)
7174/9843
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / binaries.ts
95.83% 90.48% 100% 95.83%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.test-data.ts
92.82% (+1.47% 🔼)
92.55% (-0.08% 🔻)
83.78% (+3.01% 🔼)
92.31% (+1.56% 🔼)
🟢
... / app.ts
86.23% (-0.84% 🔻)
71.43% (+0.54% 🔼)
90.91% (-1.09% 🔻)
87.7% (-0.67% 🔻)
🟢
... / loader.ts
94.32% (-0.03% 🔻)
86.13% (-0.08% 🔻)
98%
95.35% (-0.03% 🔻)
🟢
... / extension-instance.ts
85.29% (-0.11% 🔻)
77.45% 91.3%
86.61% (-0.1% 🔻)
🟢
... / utils.ts
88% (-1.47% 🔻)
75% (-5.77% 🔻)
100%
88% (-1.47% 🔻)
🟢
... / Logs.tsx
100% (+10% 🔼)
87.5% (-8.8% 🔻)
100%
100% (+10% 🔼)
🟢
... / usePollAppLogs.ts
94.29% (+0.54% 🔼)
92.86% (-3.14% 🔻)
80%
93.55% (+0.37% 🔼)
🔴
... / bundle.ts
0% (-100% 🔻)
0% (-60% 🔻)
0% (-100% 🔻)
0% (-100% 🔻)
🟡
... / common.ts
61.54% (-1.42% 🔻)
50% 60%
72.73% (-1.19% 🔻)
🟡
... / build.ts
72.55% (-3.21% 🔻)
60% (-4% 🔻)
70.59% (-5.88% 🔻)
71.28% (-2.35% 🔻)
🟢
... / common.ts
83.33% (-4.17% 🔻)
100%
60% (-6.67% 🔻)
80% (-6.67% 🔻)
🟢
... / extension.ts
91.21% (-0.19% 🔻)
73.58% 91.3%
91.01% (-0.2% 🔻)
🔴
... / partners-client.ts
18.42% (-0.07% 🔻)
34.62%
14.29% (+1.08% 🔼)
18.35% (-0.07% 🔻)
🟢
... / analytics.ts
85.71% (+2.38% 🔼)
40% (-2.11% 🔻)
100%
81.25% (+2.3% 🔼)

Test suite run success

1756 tests passing in 805 suites.

Report generated by 🧪jest coverage report action from 3c963d3

// The logic for determining the download URL and what to do with the response stream is _coincidentally_ the same for
// Javy and function-runner for now. Those methods may not continue to have the same logic in the future. If they
// diverge, make `Binary` an abstract class and create subclasses to handle the different logic polymorphically.
class DownloadableBinary {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an abstraction around the Javy and function-runner binaries. For the time being it's a class instead of an abstract class or interface because the way to determine the URL to use for the download and what to do with the response stream IMHO ought to be polymorphic but there is only one implementation currently. It's purely coincidental that the current implementation can be shared between them and there's no reason to expect that to continue indefinitely into the future. On the other hand, the other logic around downloading and installation should stay consistent between Javy and function-runner so that does not need to be polymorphic at this time.

@jeffcharles jeffcharles marked this pull request as ready for review July 11, 2024 19:08
Copy link
Contributor

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

@jeffcharles jeffcharles requested a review from isaacroldan July 11, 2024 19:09
@jeffcharles jeffcharles requested a review from isaacroldan July 15, 2024 18:58
@jeffcharles
Copy link
Contributor Author

/snapit

Copy link
Contributor

🫰✨ Thanks @jeffcharles! Your snapshot has been published to npm.

Test the snapshot by intalling your package globally:

pnpm i -g @shopify/cli@0.0.0-snapshot-20240718181555

After installing, validate the version by running just shopify in your terminal
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@jeffcharles
Copy link
Contributor Author

The snapshot build works! The Javy and function-runner binaries were written to ~/Library/pnpm/global/5/node_modules/@shopify/cli/bin.

}

const archPlatform = `${arch}-${platform}`
// These are currently the same between both binaries _coincidentally_.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this coincidence something that might change when we migrate to a newer version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that would be the only time it could possibly change. I don't foresee it changing the near future.

Copy link
Contributor

@DuncanUszkay1 DuncanUszkay1 Jul 19, 2024

Choose a reason for hiding this comment

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

Got it- sounds like it's worth adding a step in the version upgrade process doc to check on this detail

Copy link
Contributor

@DuncanUszkay1 DuncanUszkay1 left a comment

Choose a reason for hiding this comment

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

LGTM- since the versions aren't in a package manager, I think it'd be good to add some docs on how the functions team should be performing the updates. I think a short doc mentioning this file path and any other upgrade details in this repo's docs folder or our team vault docs would suffice. Given that the information isn't relevant to external contributors, the vault might be better.

I don't think we'll need more functions team eyes on this- seems fairly straightforward.

@jeffcharles jeffcharles added this pull request to the merge queue Jul 19, 2024
Merged via the queue into main with commit 0bad065 Jul 19, 2024
@jeffcharles jeffcharles deleted the jc.download-javy-and-function-runner-directly branch July 19, 2024 14:25
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