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

Adjust install script for m1 macs & switch to Node 16 #10291

Merged
merged 3 commits into from Dec 8, 2021

Conversation

pgrzesik
Copy link
Contributor

Scope:

  • support for binary installation for M1 Macs (still using x86 binary)
  • Switch to Node 16 for standalone binaries
  • Use Node 16 as main in CI

@pgrzesik pgrzesik force-pushed the adjust-install-script-for-m1-macs branch from fa976ff to dcc0a86 Compare November 30, 2021 14:45
@codecov
Copy link

codecov bot commented Nov 30, 2021

Codecov Report

Merging #10291 (68581da) into master (d52526b) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10291      +/-   ##
==========================================
- Coverage   85.40%   85.38%   -0.02%     
==========================================
  Files         339      339              
  Lines       13877    13880       +3     
==========================================
  Hits        11852    11852              
- Misses       2025     2028       +3     
Impacted Files Coverage Δ
lib/utils/standalone.js 57.89% <0.00%> (-10.86%) ⬇️
scripts/pkg/build.js 0.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d52526b...68581da. Read the comment docs.

@pgrzesik
Copy link
Contributor Author

After review, I will change the required checks so the PR doesn't have any failing

@@ -20,7 +20,7 @@ const spawnOptions = { cwd: serverlessPath, stdio: 'inherit' };
// It's due to fact that npm tends to issue buggy releases
// Node.js confirms on given version before including it within its bundle
// Version mappings reference: https://nodejs.org/en/download/releases/
await spawn('npm', ['install', '--no-save', 'npm@6.14.15'], spawnOptions);
await spawn('npm', ['install', '--no-save', 'npm@8.1.0'], spawnOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just this change I'd save for v3. As it'll upgrade npm to version which will now also install serverless in node_modules if plugin has it set as peer dependency. I think this is ok, but it may come as unexpected shift to some users, so it's better if it comes with new major

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I've reverted from that change

@@ -30,6 +30,9 @@ fi
MACHINE_TYPE=`uname -m`
if [[ $MACHINE_TYPE == "x86_64" ]]; then
ARCH='x64'
elif [[ $OSTYPE == "darwin"* ]] && [[ $MACHINE_TYPE == "arm64" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you confirm wether we need to adjust this util:

const arch = (() => {
switch (process.arch) {
case 'x32':
return 'x86';
case 'arm':
case 'arm64':
return 'armv6';
default:
return process.arch;
}
})();

I assume that not, as I take that binary as run through rosetta will internally assume we run things on x84 architecture, but if it'll detect it's ARM, then it'll generate wrong link for binary update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch, I've tested and actually, it reports arm64 - I've adjusted and tested that update works correctly on M1 macs too

@pgrzesik pgrzesik force-pushed the adjust-install-script-for-m1-macs branch from dcc0a86 to 157f1b3 Compare November 30, 2021 15:37
@@ -13,6 +13,9 @@ const platform = (() => {
}
})();
const arch = (() => {
if (process.arch === 'arm64' && process.platform === 'darwin') {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'll be cleaner to include that logic in below switch statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, I wanted to highlight that edge case and handle it first, but you're right that it could've been done in a cleaner way

@pgrzesik pgrzesik force-pushed the adjust-install-script-for-m1-macs branch from 157f1b3 to 68581da Compare November 30, 2021 20:15
@pgrzesik pgrzesik requested a review from medikoo December 1, 2021 08:33
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Looks great 👍

@pgrzesik
Copy link
Contributor Author

pgrzesik commented Dec 8, 2021

Github issue has been resolved, I'm merging this and updating the required checks for master branch @medikoo

@pgrzesik pgrzesik merged commit b8cc13f into master Dec 8, 2021
@pgrzesik pgrzesik deleted the adjust-install-script-for-m1-macs branch December 8, 2021 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants