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

chore: adds quality gate for rerunning e2e spec files that are new or have been modified #24556

Merged
merged 54 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e66f2fa
quality gate mock alt
seaona May 16, 2024
d2298f6
fix export
seaona May 16, 2024
d89be42
fix PR number match
seaona May 16, 2024
57269c9
overwrite retries number for retry-until-failure cases
seaona May 16, 2024
3a8b0fa
change file to ts and add log for debugging
seaona May 16, 2024
90690cd
revert js
seaona May 16, 2024
65b3467
add ts spec files to the filter and make another test fail to verify …
seaona May 20, 2024
df8d21e
address dev review: move retries to variable remove try/catch
seaona May 21, 2024
5029d49
leave the specs as they were before (changed for ci testing purposes)
seaona May 21, 2024
71bbf50
Merge branch 'develop' into quality-gate-gh
seaona May 21, 2024
1c728ac
Quality gate gh ci job (#24787)
seaona May 27, 2024
c46b3b8
address comments
seaona Jun 4, 2024
b6d1f45
origin develop
seaona Jun 4, 2024
870f875
depth update
seaona Jun 4, 2024
81f954a
50 fetch
seaona Jun 4, 2024
8c0516c
rename funcs
seaona Jun 4, 2024
bc6b76c
Merge branch 'develop' into quality-gate-gh
seaona Jun 4, 2024
8179d2d
switch from sh to js file
seaona Jun 5, 2024
27a4be3
fix changedfilesUtils
seaona Jun 5, 2024
af6e4d6
move script to config file
seaona Jun 6, 2024
e781327
git diff incremental depth
seaona Jun 6, 2024
a26f7ea
fix git fetch incremental
seaona Jun 6, 2024
cd0027f
git fetch pr branch with depth too
seaona Jun 6, 2024
6ef0174
console log path
seaona Jun 6, 2024
48482c8
define output path
seaona Jun 6, 2024
b061ba5
format spec entries with path and new lines
seaona Jun 6, 2024
580eee5
fix back the spec files for testing ci
seaona Jun 6, 2024
c3dbacf
only do for loop if there are changed e2e files
seaona Jun 6, 2024
2da87eb
update git diff fallback and adjust
seaona Jun 18, 2024
918e1fb
testing git diff with full checkout
seaona Jun 18, 2024
6f429d3
fix fetch develop
seaona Jun 18, 2024
4ee548d
unshallow
seaona Jun 18, 2024
ab52848
separate job
seaona Jun 18, 2024
7726eb3
remove requried job
seaona Jun 18, 2024
475764a
Merge branch 'develop' into quality-gate-gh
seaona Jun 18, 2024
49ab885
Merge branch 'develop' into quality-gate-gh
seaona Jun 19, 2024
7cd00e4
Merge branch 'develop' into quality-gate-gh
seaona Jun 25, 2024
2d8a65a
addressing some of the review comments
seaona Jun 25, 2024
94bae47
change .js to .ts
seaona Jun 25, 2024
5ebf061
addressed comments and test failing test
seaona Jun 26, 2024
0a548d2
update function name
seaona Jun 26, 2024
0821ecb
add console logs and remove extra path
seaona Jun 26, 2024
e91024c
tweak path
seaona Jun 26, 2024
1eb2ea0
add missing /
seaona Jun 26, 2024
89b6fc5
remove changes used to test ci
seaona Jun 26, 2024
fa71fa9
cleanup
seaona Jun 26, 2024
3e952e7
add missing newline Mark's suggestion
seaona Jun 28, 2024
2ae6c6f
Omit type from tsdoc - Mark's suggestion
seaona Jun 28, 2024
ecea19c
simplifying variables - Mark's suggestion
seaona Jun 28, 2024
eb79c08
avoid using any in ts - Mark's suggestion
seaona Jun 28, 2024
5874bb0
add job comment for config
seaona Jun 28, 2024
9b1c7cc
changed changedOrnew var definition
seaona Jun 28, 2024
0974070
missing to remove the rest of the types in the descriptions - Mark's …
seaona Jun 28, 2024
07e81d8
Merge branch 'develop' into quality-gate-gh
HowardBraham Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions development/lib/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ async function retry(
}
}

if (retryUntilFailure) {
return null;
}

seaona marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(rejectionMessage);
}

Expand Down
33 changes: 33 additions & 0 deletions test/e2e/fetch-changed-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const axios = require('axios');
seaona marked this conversation as resolved.
Show resolved Hide resolved

const PR_URL = `${process.env.CIRCLE_PULL_REQUEST}`;
const PR_NUMBER = PR_URL.match(/\/(\d+)$/u)[1];

const GH_API_URL = `https://api.github.com/repos/MetaMask/metamask-extension/pulls/${PR_NUMBER}/files`;
const headers = {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
'X-GitHub-Api-Version': '2022-11-28',
};

async function fetchChangedE2eFiles() {
try {
const response = await axios.get(GH_API_URL, { headers });
const filesChanged = response.data
.filter(
(file) =>
file.filename.startsWith('test/e2e/') &&
(file.filename.endsWith('.spec.js') ||
file.filename.endsWith('.spec.ts')),
)
.map((file) => file.filename)
.join('\n');

return filesChanged;
} catch (error) {
console.error('Error making request:', error);
throw error;
}
}

module.exports = { fetchChangedE2eFiles };
22 changes: 21 additions & 1 deletion test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { hideBin } = require('yargs/helpers');
const { runInShell } = require('../../development/lib/run-command');
const { exitWithError } = require('../../development/lib/exit-with-error');
const { loadBuildTypesConfig } = require('../../development/lib/build-type');
const { fetchChangedE2eFiles } = require('./fetch-changed-files');

// These tests should only be run on Flask for now.
const FLASK_ONLY_TESTS = ['test-snap-namelookup.spec.js'];
Expand Down Expand Up @@ -212,12 +213,31 @@ async function main() {

console.log('My test list:', myTestList);

let changedOrNewTests = '';
try {
changedOrNewTests = await fetchChangedE2eFiles();
} catch (error) {
console.error('Error fetching changed e2e files:', error);
}
DDDDDanica marked this conversation as resolved.
Show resolved Hide resolved
console.log('Spec files that will be re-run:', changedOrNewTests);
seaona marked this conversation as resolved.
Show resolved Hide resolved

// spawn `run-e2e-test.js` for each test in myTestList
for (let testPath of myTestList) {
if (testPath !== '') {
testPath = testPath.replace('\n', ''); // sometimes there's a newline at the end of the testPath
console.log(`\nExecuting testPath: ${testPath}\n`);
await runInShell('node', [...args, testPath]);

const testFileName = testPath.split('/').pop();
const isTestChangedOrNew = changedOrNewTests.includes(testFileName);
const retryIndex = args.indexOf('--retries');
if (retryIndex !== -1) {
args.splice(retryIndex, 2);
}

const extraArgs = isTestChangedOrNew
? ['--retry-until-failure', '--retries=5']
DDDDDanica marked this conversation as resolved.
Show resolved Hide resolved
: [];
await runInShell('node', [...args, ...extraArgs, testPath]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/signature/eth-sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
const FixtureBuilder = require('../../fixture-builder');

describe('Eth sign', function () {
it('will detect if eth_sign is disabled', async function () {
it('CHANGED TO TEST CI -will detect if eth_sign is disabled', async function () {
await withFixtures(
{
dapp: true,
Expand All @@ -25,7 +25,7 @@ describe('Eth sign', function () {
await unlockWallet(driver);

await openDapp(driver);
await driver.clickElement('#ethSign');
await driver.clickElement('#BAD-ID-TO-FAIL-ON-PURPOSE');

await driver.delay(1000);
const ethSignButton = await driver.findElement('#ethSign');
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/signature/personal-sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
const FixtureBuilder = require('../../fixture-builder');

describe('Personal sign', function () {
it('can initiate and confirm a personal sign', async function () {
it('CHANGED TO TEST CI -can initiate and confirm a personal sign', async function () {
await withFixtures(
{
dapp: true,
Expand Down
Loading