Skip to content

build: don't apply snow to builds when --snow=false#23234

Merged
davidmurdoch merged 4 commits intodevelopfrom
conditional-snow
Apr 29, 2024
Merged

build: don't apply snow to builds when --snow=false#23234
davidmurdoch merged 4 commits intodevelopfrom
conditional-snow

Conversation

@davidmurdoch
Copy link
Copy Markdown
Contributor

@davidmurdoch davidmurdoch commented Feb 28, 2024

The build script has an option --snow that is supposed to enable or disable snow, but several parts of the build process don't respect it. This hasn't been a problem since the static.js part of the build process just makes the snow.js file used by the application a no-op. This PR changes it so that the snow.js (and related) file just never get imported when snow has been disabled.

This PR is also prep for the webpack build, which also uses this snow flag.

Open in GitHub Codespaces

@davidmurdoch davidmurdoch added the team-extension-platform Extension Platform team label Feb 28, 2024
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@davidmurdoch davidmurdoch changed the title fix: don't apply snow to builds when --snow=false build: don't apply snow to builds when --snow=false Feb 29, 2024
@davidmurdoch davidmurdoch force-pushed the conditional-snow branch 3 times, most recently from 21570f9 to 59f4e66 Compare March 1, 2024 18:24
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.49%. Comparing base (6c465bc) to head (6d514b8).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #23234   +/-   ##
========================================
  Coverage    67.49%   67.49%           
========================================
  Files         1264     1264           
  Lines        49362    49362           
  Branches     12863    12863           
========================================
  Hits         33313    33313           
  Misses       16049    16049           

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

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [59f4e66]
Page Load Metrics (1500 ± 342 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint692741474923
domContentLoaded983382311
load5521231500712342
domInteractive983382311
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [b23c7a1]
Page Load Metrics (1087 ± 436 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint692171344421
domContentLoaded1186442613
load5223701087908436
domInteractive1186442613
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TL;DR: the rest of the PR prevents the code from ever trying to load snow, so we don't need to copy an empty file anymore.

package.json Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dear reviewer: does the addition of --snow=false seem appropriate here?

package.json Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dear reviewer: does the addition of --snow=false seem appropriate here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

package.json Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewers:

I did not add --snow=false to the build:test:dev:mv3 script because I don't understand that script. It sets the task/buildTarget to testDev and sets --apply-lavamoat=false, but the MV3 build system running with the TEST_DEV buildTarget forces lavamoat anyway (but in "stats mode").

see (where buildTarget === testDev):

  1. /**
    * Returns whether the current build is an e2e test build or not.
    *
    * @param {BUILD_TARGETS} buildTarget - The current build target.
    * @returns Whether the current build is an e2e test build.
    */
    function isTestBuild(buildTarget) {
    return (
    buildTarget === BUILD_TARGETS.TEST || buildTarget === BUILD_TARGETS.TEST_DEV
    );
    }
  2. const testing = isTestBuild(buildTarget);
    variables.set({
    IN_TEST: testing,
  3. const testMode = process.env.IN_TEST;
  4. // Always apply LavaMoat in e2e test builds, so that we can capture initialization stats
    if (testMode || applyLavaMoat) {
    loadFile('./runtime-lavamoat.js');
    loadFile('./lockdown-more.js');
    loadFile('./policy-load.js');
    } else {
  5. // Code below is used to set statsMode to true when testing in MV3
    // This is used to capture module initialisation stats using lavamoat.
    if (isTestBuild(buildTarget)) {
    const content = readFileSync('./dist/chrome/runtime-lavamoat.js', 'utf8');
    const fileOutput = content.replace('statsMode = false', 'statsMode = true');
    writeFileSync('./dist/chrome/runtime-lavamoat.js', fileOutput);
    }

It actually more like a start: script than a build: script, so that makes it even more confusing.

Since this isn't used in CI I stopped investigating why it is the way it is and am writing this comment instead.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [4f97c9b]
Page Load Metrics (1499 ± 567 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint752441605024
domContentLoaded1199352311
load59318414991181567
domInteractive1199352311
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@davidmurdoch davidmurdoch force-pushed the conditional-snow branch 3 times, most recently from 397cfc6 to 0287c97 Compare March 4, 2024 17:09
@davidmurdoch davidmurdoch marked this pull request as ready for review March 4, 2024 17:29
@davidmurdoch davidmurdoch requested review from a team and kumavis as code owners March 4, 2024 17:29
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [0287c97]
Page Load Metrics (685 ± 392 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint792471254521
domContentLoaded107630189
load611962685816392
domInteractive107630189
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@legobeat legobeat requested a review from weizman March 14, 2024 08:53
@davidmurdoch davidmurdoch force-pushed the conditional-snow branch 2 times, most recently from 65bec7c to ebd9732 Compare March 18, 2024 23:31
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [ebd9732]
Page Load Metrics (1671 ± 446 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint762521504321
domContentLoaded1395362211
load6225751671928446
domInteractive1395362211
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [ebd9732]
Page Load Metrics (1433 ± 586 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint843451697737
domContentLoaded990342211
load61291214331220586
domInteractive990342211
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [8f1c874]
Page Load Metrics (944 ± 563 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint623081265225
domContentLoaded127429168
load5029179441172563
domInteractive117429168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@davidmurdoch davidmurdoch force-pushed the conditional-snow branch 3 times, most recently from 5f2fb57 to ca95fcf Compare March 28, 2024 15:43
@davidmurdoch davidmurdoch marked this pull request as draft March 28, 2024 15:44
@davidmurdoch davidmurdoch marked this pull request as ready for review March 28, 2024 21:35
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [a3786fc]
Page Load Metrics (727 ± 466 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722941295024
domContentLoaded106629178
load572462727970466
domInteractive106629178
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@brad-decker
Copy link
Copy Markdown
Contributor

@weizman could you review this one please?

DDDDDanica
DDDDDanica previously approved these changes Apr 22, 2024
@DDDDDanica
Copy link
Copy Markdown
Contributor

LGTM, let me know when the conflict is resolved ~

vthomas13
vthomas13 previously approved these changes Apr 24, 2024
@davidmurdoch davidmurdoch dismissed stale reviews from vthomas13 and DDDDDanica via a84e42b April 24, 2024 20:50
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [a84e42b]
Page Load Metrics (1646 ± 690 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint562841275627
domContentLoaded8190333919
load45369416461437690
domInteractive8190333919
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@socket-security
Copy link
Copy Markdown

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/tocbot@4.27.5 None 0 129 kB tscanlin

🚮 Removed packages: npm/tocbot@4.21.2

View full report↗︎

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [6d514b8]
Page Load Metrics (619 ± 539 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5711078147
domContentLoaded8251352
load4531256191123539
domInteractive8251352
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Copy Markdown
Contributor

@weizman weizman left a comment

Choose a reason for hiding this comment

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

Lgtm

@davidmurdoch davidmurdoch merged commit 4f80914 into develop Apr 29, 2024
@davidmurdoch davidmurdoch deleted the conditional-snow branch April 29, 2024 21:16
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2024
@gauthierpetetin gauthierpetetin added the release-12.0.0 Issue or pull request that will be included in release 12.0.0 label Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.0.0 Issue or pull request that will be included in release 12.0.0 team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants