metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

Add validation to production build script

Open Gudahtt opened this issue 2 years ago • 7 comments

Validation has been added to the build script when the "prod" target is selected. We now ensure that all expected environment variables are set, and that no extra environment variables are present (which might indicate that the wrong configuration file is being used).

The prod target uses a new .metamaskprodrc configuration file. Each required variable can be specified either via environment variable or via this config file. CI will continue set these via environment variable, but for local manual builds we can use the config file to simplify the build process and ensure consistency.

A new "dist" target has been added to preserve the ability to build a "production-like" build without this validation.

The config validation is invoked early in the script, in the CLI argument parsing step, so that it would fail more quickly. Otherwise we'd have to wait a few minutes longer for the validation to run. This required some refactoring, moving functions to the utility module and moving the config to a dedicated module.

Closes #15003

Manual Testing Steps

The build targets of dev, devTest, test should all remain unchanged. The new build target dist should behave the same as the old prod target (which confusingly was invoked as yarn dist).

The new prod target has this new behavior:

  • It should demand that all required variables are set either via environment variable or the .metamaskprodrc config file.
    • The required variables are:
      • SENTRY_DSN
      • PUBNUB_PUB_KEY
      • PUBNUB_SUB_KEY
      • INFURA_[build type]_PROJECT_ID
      • SEGMENT_[build type]_WRITE_KEY
    • For the build-type-specific variables, only those used by the current build are required.
  • Extra values specified in .metamaskprodrc should produce an error.
  • Extra environment variables should not produce an error (of course - that would make this impossible to use)
  • The validation should occur early in the build process, before any tasks have started.

Pre-Merge Checklist

  • [x] PR template is filled out
  • [x] IF this PR fixes a bug, a test that would have caught the bug has been added
  • [x] PR is linked to the appropriate GitHub issue
  • [x] PR has been added to the appropriate release Milestone

+ If there are functional changes:

  • [ ] Manual testing complete & passed
  • [x] "Extension QA Board" label has been applied

Gudahtt avatar Aug 04 '22 16:08 Gudahtt

~This depends upon #15464, #15447, and #15493~

This is ready for review

Gudahtt avatar Aug 04 '22 16:08 Gudahtt

Builds ready [843d76c]
Page Load Metrics (1863 ± 109 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint87156114199
domContentLoaded155122441837218105
load156422631863228109
domInteractive155122441837218105

metamaskbot avatar Aug 04 '22 18:08 metamaskbot

Builds ready [faf5b3d]
Page Load Metrics (1717 ± 35 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint931721152210
domContentLoaded1562187916978038
load1585187917177335
domInteractive1561187916978038

metamaskbot avatar Aug 05 '22 11:08 metamaskbot

Builds ready [c491453]
Page Load Metrics (1814 ± 61 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint85145114147
domContentLoaded15912015178311354
load15912045181412661
domInteractive15912015178311354

metamaskbot avatar Aug 05 '22 14:08 metamaskbot

Builds ready [6a9ac31]
Page Load Metrics (1909 ± 81 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint893661325727
domContentLoaded16062138188214971
load16072178190916981
domInteractive16062138188214971

metamaskbot avatar Aug 05 '22 17:08 metamaskbot

Builds ready [e2c4872]
Page Load Metrics (1753 ± 41 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint971759280480230
domContentLoaded1551184717207837
load1577190317538641
domInteractive1551184717207837

metamaskbot avatar Aug 05 '22 20:08 metamaskbot

Builds ready [6154caf]
Page Load Metrics (1630 ± 35 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint831560177318153
domContentLoaded1511179216267234
load1511179216307235
domInteractive1511179216267234

metamaskbot avatar Aug 06 '22 12:08 metamaskbot

Builds ready [a6f17bc]
Page Load Metrics (1802 ± 56 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint89163109189
domContentLoaded16061966177310450
load16161992180211756
domInteractive16061966177310450

metamaskbot avatar Aug 15 '22 15:08 metamaskbot

Builds ready [a7c29c6]
Page Load Metrics (1933 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint891753201357172
domContentLoaded17132322189716077
load17452323193315976
domInteractive17132322189716077

metamaskbot avatar Aug 17 '22 14:08 metamaskbot

Also validated that extra vars invalidate the build

brad-decker avatar Aug 19 '22 14:08 brad-decker