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(ci): disable playwright test detection script on merge queue #4651

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .github/workflows/prbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ jobs:
- run: npm run build
- name: Identify E2E Test Files to run
id: determine-tests
run: node ./scripts/ci/determine-tests.mjs testsToRun shardIndex shardTotal
run: |
runAllTests=$([ "${{ github.event_name }}" == "merge_group" ] && echo true || echo false)
node ./scripts/ci/determine-tests.mjs testsToRun shardIndex shardTotal $runAllTests

env:
projectRoot: ${{ github.workspace }}
maximumShards: ${{ env.maximumShards }}
Expand Down
25 changes: 20 additions & 5 deletions scripts/ci/determine-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class PackageJsonChangeError extends Error {
}
}

class RunAllTestsInMergeQueueError extends Error {
constructor() {
super(`In a merge queue. Running all tests.`);
this.name = 'RunAllTestsInMergeQueueError';
}
}

/**
* Recursively finds all end-to-end test files with the `.e2e.ts` extension in a given directory.
*
Expand Down Expand Up @@ -176,18 +183,24 @@ const changedFiles = getChangedFiles(base, head).split(EOL);
const outputNameTestsToRun = process.argv[2];
const outputNameShardIndex = process.argv[3];
const outputNameShardTotal = process.argv[4];
const runAllTests = process.argv[5] === 'true';
const projectRoot = process.env.projectRoot;
const atomicSourceComponents = join('packages', 'atomic', 'src', 'components');

try {
if (runAllTests) {
throw new RunAllTestsInMergeQueueError();
}

const testFiles = findAllTestFiles(atomicSourceComponents);
const testDependencies = createTestFileMappings(testFiles, projectRoot);
const testsToRun = determineTestFilesToRun(changedFiles, testDependencies);

if (testsToRun === '') {
throw new NoRelevantChangesError();
}
const maximumShards = parseInt(process.env.maximumShards, 10);

const maximumShards = parseInt(process.env.maximumShards, 10);
const [shardIndex, shardTotal] = allocateShards(
testsToRun.split(' ').length,
maximumShards
Expand All @@ -202,11 +215,10 @@ try {
setOutput(outputNameTestsToRun, '');
setOutput(outputNameShardIndex, [0]);
setOutput(outputNameShardTotal, [0]);
}

if (
} else if (
error instanceof DependentPackageChangeError ||
error instanceof PackageJsonChangeError
error instanceof PackageJsonChangeError ||
error instanceof RunAllTestsInMergeQueueError
fpbrault marked this conversation as resolved.
Show resolved Hide resolved
) {
console.warn(error?.message || error);
setOutput(outputNameTestsToRun, '');
Expand All @@ -217,5 +229,8 @@ try {
setOutput(outputNameShardIndex, shardIndex);
const shardTotal = [process.env.maximumShards];
setOutput(outputNameShardTotal, shardTotal);
} else {
console.error('Unexpected error:', error);
process.exit(1);
}
}
Loading