mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +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:
|
- prep-build-test:
|
||||||
requires:
|
requires:
|
||||||
- prep-deps
|
- prep-deps
|
||||||
|
- prep-build-test-mv3:
|
||||||
|
requires:
|
||||||
|
- prep-deps
|
||||||
- prep-build-test-flask:
|
- prep-build-test-flask:
|
||||||
requires:
|
requires:
|
||||||
- prep-deps
|
- prep-deps
|
||||||
@ -200,8 +203,8 @@ jobs:
|
|||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: .
|
root: .
|
||||||
paths:
|
paths:
|
||||||
- node_modules
|
- node_modules
|
||||||
- build-artifacts
|
- build-artifacts
|
||||||
|
|
||||||
validate-lavamoat-config:
|
validate-lavamoat-config:
|
||||||
executor: node-browsers-medium-plus
|
executor: node-browsers-medium-plus
|
||||||
@ -305,6 +308,26 @@ jobs:
|
|||||||
- dist-test-flask
|
- dist-test-flask
|
||||||
- builds-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:
|
prep-build-test:
|
||||||
executor: node-browsers-medium-plus
|
executor: node-browsers-medium-plus
|
||||||
@ -419,7 +442,6 @@ jobs:
|
|||||||
name: Validate release candidate changelog
|
name: Validate release candidate changelog
|
||||||
command: yarn lint:changelog:rc
|
command: yarn lint:changelog:rc
|
||||||
|
|
||||||
|
|
||||||
test-deps-audit:
|
test-deps-audit:
|
||||||
executor: node-browsers
|
executor: node-browsers
|
||||||
steps:
|
steps:
|
||||||
@ -648,7 +670,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- add_ssh_keys:
|
- add_ssh_keys:
|
||||||
fingerprints:
|
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
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: .
|
at: .
|
||||||
@ -670,7 +692,7 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: test:coverage:jest
|
name: test:coverage:jest
|
||||||
command: yarn test:coverage:jest
|
command: yarn test:coverage:jest
|
||||||
- run:
|
- run:
|
||||||
name: Validate coverage thresholds
|
name: Validate coverage thresholds
|
||||||
command: |
|
command: |
|
||||||
if ! git diff --exit-code jest.config.js development/jest.config.js; then
|
if ! git diff --exit-code jest.config.js development/jest.config.js; then
|
||||||
|
@ -370,16 +370,20 @@ const postProcessServiceWorker = (
|
|||||||
mv3BrowserPlatforms,
|
mv3BrowserPlatforms,
|
||||||
fileList,
|
fileList,
|
||||||
applyLavaMoat,
|
applyLavaMoat,
|
||||||
|
testing,
|
||||||
) => {
|
) => {
|
||||||
mv3BrowserPlatforms.forEach((browser) => {
|
mv3BrowserPlatforms.forEach((browser) => {
|
||||||
const appInitFile = `./dist/${browser}/app-init.js`;
|
const appInitFile = `./dist/${browser}/app-init.js`;
|
||||||
const fileContent = readFileSync('./app/scripts/app-init.js', 'utf8');
|
const fileContent = readFileSync('./app/scripts/app-init.js', 'utf8');
|
||||||
const fileOutput = fileContent
|
let fileOutput = fileContent.replace('/** FILE NAMES */', fileList);
|
||||||
.replace('/** FILE NAMES */', fileList)
|
if (!testing) {
|
||||||
.replace(
|
// 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 = true;',
|
||||||
`const applyLavaMoat = ${applyLavaMoat};`,
|
`const applyLavaMoat = ${applyLavaMoat};`,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
writeFileSync(appInitFile, fileOutput);
|
writeFileSync(appInitFile, fileOutput);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -420,16 +424,32 @@ async function bundleMV3AppInitialiser({
|
|||||||
shouldLintFenceFiles,
|
shouldLintFenceFiles,
|
||||||
})();
|
})();
|
||||||
|
|
||||||
postProcessServiceWorker(mv3BrowserPlatforms, fileList, applyLavaMoat);
|
postProcessServiceWorker(
|
||||||
|
mv3BrowserPlatforms,
|
||||||
|
fileList,
|
||||||
|
applyLavaMoat,
|
||||||
|
testing,
|
||||||
|
);
|
||||||
|
|
||||||
let prevChromeFileContent;
|
if (devMode && !testing) {
|
||||||
watch('./dist/chrome/app-init.js', () => {
|
let prevChromeFileContent;
|
||||||
const chromeFileContent = readFileSync('./dist/chrome/app-init.js', 'utf8');
|
watch('./dist/chrome/app-init.js', () => {
|
||||||
if (chromeFileContent !== prevChromeFileContent) {
|
const chromeFileContent = readFileSync(
|
||||||
prevChromeFileContent = chromeFileContent;
|
'./dist/chrome/app-init.js',
|
||||||
postProcessServiceWorker(mv3BrowserPlatforms, fileList, applyLavaMoat);
|
'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`);
|
console.log(`Bundle end: service worker app-init.js`);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",
|
"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": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' yarn build test",
|
||||||
"build:test:flask": "yarn build test --build-type flask",
|
"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",
|
"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": "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'",
|
"dapp-chain": "GANACHE_ARGS='-b 2' concurrently -k -n ganache,dapp -p '[{time}][{name}]' 'yarn ganache:start' 'sleep 5 && yarn dapp'",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user