mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Adding tasks for MV3 test build (#15133)
This commit is contained in:
parent
0c163dd8aa
commit
aeb0147846
@ -53,6 +53,9 @@ workflows:
|
||||
- prep-build-test:
|
||||
requires:
|
||||
- prep-deps
|
||||
- prep-build-test-mv3:
|
||||
requires:
|
||||
- prep-deps
|
||||
- prep-build-test-flask:
|
||||
requires:
|
||||
- prep-deps
|
||||
@ -200,8 +203,8 @@ jobs:
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- node_modules
|
||||
- build-artifacts
|
||||
- node_modules
|
||||
- build-artifacts
|
||||
|
||||
validate-lavamoat-config:
|
||||
executor: node-browsers-medium-plus
|
||||
@ -305,6 +308,26 @@ jobs:
|
||||
- dist-test-flask
|
||||
- builds-test-flask
|
||||
|
||||
prep-build-test-mv3:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: Build extension in mv3 for testing
|
||||
command: yarn build:test:mv3
|
||||
- run:
|
||||
name: Move test build to 'dist-test' to avoid conflict with production build
|
||||
command: mv ./dist ./dist-test-mv3
|
||||
- run:
|
||||
name: Move test zips to 'builds-test' to avoid conflict with production build
|
||||
command: mv ./builds ./builds-test-mv3
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- dist-test-mv3
|
||||
- builds-test-mv3
|
||||
|
||||
prep-build-test:
|
||||
executor: node-browsers-medium-plus
|
||||
@ -419,7 +442,6 @@ jobs:
|
||||
name: Validate release candidate changelog
|
||||
command: yarn lint:changelog:rc
|
||||
|
||||
|
||||
test-deps-audit:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
@ -648,7 +670,7 @@ jobs:
|
||||
steps:
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- "3d:49:29:f4:b2:e8:ea:af:d1:32:eb:2a:fc:15:85:d8"
|
||||
- '3d:49:29:f4:b2:e8:ea:af:d1:32:eb:2a:fc:15:85:d8'
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
@ -670,7 +692,7 @@ jobs:
|
||||
- run:
|
||||
name: test:coverage:jest
|
||||
command: yarn test:coverage:jest
|
||||
- run:
|
||||
- run:
|
||||
name: Validate coverage thresholds
|
||||
command: |
|
||||
if ! git diff --exit-code jest.config.js development/jest.config.js; then
|
||||
|
@ -370,16 +370,20 @@ const postProcessServiceWorker = (
|
||||
mv3BrowserPlatforms,
|
||||
fileList,
|
||||
applyLavaMoat,
|
||||
testing,
|
||||
) => {
|
||||
mv3BrowserPlatforms.forEach((browser) => {
|
||||
const appInitFile = `./dist/${browser}/app-init.js`;
|
||||
const fileContent = readFileSync('./app/scripts/app-init.js', 'utf8');
|
||||
const fileOutput = fileContent
|
||||
.replace('/** FILE NAMES */', fileList)
|
||||
.replace(
|
||||
let fileOutput = fileContent.replace('/** FILE NAMES */', fileList);
|
||||
if (!testing) {
|
||||
// Lavamoat is always set to true in testing mode
|
||||
// This is to enable capturing initialisation time stats using e2e with lavamoat statsMode enabled
|
||||
fileOutput = fileContent.replace(
|
||||
'const applyLavaMoat = true;',
|
||||
`const applyLavaMoat = ${applyLavaMoat};`,
|
||||
);
|
||||
}
|
||||
writeFileSync(appInitFile, fileOutput);
|
||||
});
|
||||
};
|
||||
@ -420,16 +424,32 @@ async function bundleMV3AppInitialiser({
|
||||
shouldLintFenceFiles,
|
||||
})();
|
||||
|
||||
postProcessServiceWorker(mv3BrowserPlatforms, fileList, applyLavaMoat);
|
||||
postProcessServiceWorker(
|
||||
mv3BrowserPlatforms,
|
||||
fileList,
|
||||
applyLavaMoat,
|
||||
testing,
|
||||
);
|
||||
|
||||
let prevChromeFileContent;
|
||||
watch('./dist/chrome/app-init.js', () => {
|
||||
const chromeFileContent = readFileSync('./dist/chrome/app-init.js', 'utf8');
|
||||
if (chromeFileContent !== prevChromeFileContent) {
|
||||
prevChromeFileContent = chromeFileContent;
|
||||
postProcessServiceWorker(mv3BrowserPlatforms, fileList, applyLavaMoat);
|
||||
}
|
||||
});
|
||||
if (devMode && !testing) {
|
||||
let prevChromeFileContent;
|
||||
watch('./dist/chrome/app-init.js', () => {
|
||||
const chromeFileContent = readFileSync(
|
||||
'./dist/chrome/app-init.js',
|
||||
'utf8',
|
||||
);
|
||||
if (chromeFileContent !== prevChromeFileContent) {
|
||||
prevChromeFileContent = chromeFileContent;
|
||||
postProcessServiceWorker(mv3BrowserPlatforms, fileList, applyLavaMoat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (testing) {
|
||||
const content = readFileSync('./dist/chrome/runtime-lavamoat.js', 'utf8');
|
||||
const fileOutput = content.replace('statsMode = false', 'statsMode = true');
|
||||
writeFileSync('./dist/chrome/runtime-lavamoat.js', fileOutput);
|
||||
}
|
||||
|
||||
console.log(`Bundle end: service worker app-init.js`);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",
|
||||
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' yarn build test",
|
||||
"build:test:flask": "yarn build test --build-type flask",
|
||||
"build:test:mv3": "ENABLE_MV3=true yarn build test",
|
||||
"test": "yarn lint && yarn test:unit && yarn test:unit:jest",
|
||||
"dapp": "node development/static-server.js node_modules/@metamask/test-dapp/dist --port 8080",
|
||||
"dapp-chain": "GANACHE_ARGS='-b 2' concurrently -k -n ganache,dapp -p '[{time}][{name}]' 'yarn ganache:start' 'sleep 5 && yarn dapp'",
|
||||
|
Loading…
Reference in New Issue
Block a user