Skip to content

Commit

Permalink
🏗 Persist test sharding filelist as an artifact on CircleCI (#36302)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha committed Oct 8, 2021
1 parent 2fe42ef commit 0aef555
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ commands:
path: result-reports
- store_test_results:
path: result-reports
store_filelist:
steps:
- store_artifacts:
path: /tmp/filelist.txt
skip_on_push_builds:
steps:
- when:
Expand Down Expand Up @@ -299,6 +303,7 @@ jobs:
name: '⭐ All Unit Tests ⭐'
command: node build-system/pr-check/unit-tests.js
- store_test_output
- store_filelist
- teardown_vm
unminified_tests:
executor:
Expand Down Expand Up @@ -354,6 +359,7 @@ jobs:
name: '⭐ End-to-End Tests ⭐'
command: node build-system/pr-check/e2e-tests.js
- store_test_output
- store_filelist
- teardown_vm
browser_tests_safari:
executor:
Expand Down Expand Up @@ -433,6 +439,7 @@ jobs:
name: '⭐ Experiment << parameters.exp >> End-to-End Tests ⭐'
command: node build-system/pr-check/experiment-e2e-tests.js --experiment=experiment<< parameters.exp >>
- store_test_output
- store_filelist
- teardown_vm
amp_release:
executor:
Expand Down
6 changes: 3 additions & 3 deletions build-system/pr-check/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const {
TEST_FILES_LIST_FILE_NAME,
FILELIST_PATH,
generateCircleCiShardTestFileList,
skipDependentJobs,
timedExecOrDie,
Expand All @@ -24,7 +24,7 @@ function pushBuildWorkflow() {
try {
generateCircleCiShardTestFileList(e2eTestPaths);
timedExecOrThrow(
`amp e2e --nobuild --headless --minified --report --filelist ${TEST_FILES_LIST_FILE_NAME}`,
`amp e2e --nobuild --headless --minified --report --filelist ${FILELIST_PATH}`,
'End-to-end tests failed!'
);
} catch (e) {
Expand All @@ -43,7 +43,7 @@ function prBuildWorkflow() {
if (buildTargetsInclude(Targets.RUNTIME, Targets.E2E_TEST)) {
generateCircleCiShardTestFileList(e2eTestPaths);
timedExecOrDie(
`amp e2e --nobuild --headless --minified --filelist ${TEST_FILES_LIST_FILE_NAME}`
`amp e2e --nobuild --headless --minified --filelist ${FILELIST_PATH}`
);
} else {
skipDependentJobs(
Expand Down
4 changes: 2 additions & 2 deletions build-system/pr-check/experiment-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const {
TEST_FILES_LIST_FILE_NAME,
FILELIST_PATH,
generateCircleCiShardTestFileList,
skipDependentJobs,
timedExecOrDie,
Expand All @@ -31,7 +31,7 @@ function runExperimentTests(config) {
const reportFlag = isPushBuild() ? '--report' : '';
generateCircleCiShardTestFileList(e2eTestPaths);
timedExecOrThrow(
`amp e2e --nobuild --minified --headless ${experimentFlag} ${defineFlag} ${reportFlag} --filelist ${TEST_FILES_LIST_FILE_NAME}`
`amp e2e --nobuild --minified --headless ${experimentFlag} ${defineFlag} ${reportFlag} --filelist ${FILELIST_PATH}`
);
} catch (e) {
if (e.status) {
Expand Down
6 changes: 3 additions & 3 deletions build-system/pr-check/unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const {
TEST_FILES_LIST_FILE_NAME,
FILELIST_PATH,
generateCircleCiShardTestFileList,
skipDependentJobs,
timedExecOrDie,
Expand All @@ -24,7 +24,7 @@ function pushBuildWorkflow() {
try {
generateCircleCiShardTestFileList(unitTestPaths);
timedExecOrThrow(
`amp unit --headless --coverage --report --filelist ${TEST_FILES_LIST_FILE_NAME}`,
`amp unit --headless --coverage --report --filelist ${FILELIST_PATH}`,
'Unit tests failed!'
);
timedExecOrThrow(
Expand All @@ -47,7 +47,7 @@ function prBuildWorkflow() {
if (buildTargetsInclude(Targets.RUNTIME, Targets.UNIT_TEST)) {
generateCircleCiShardTestFileList(unitTestPaths);
timedExecOrDie(
`amp unit --headless --coverage --filelist ${TEST_FILES_LIST_FILE_NAME}`
`amp unit --headless --coverage --filelist ${FILELIST_PATH}`
);
timedExecOrDie('amp codecov-upload');
} else {
Expand Down
8 changes: 4 additions & 4 deletions build-system/pr-check/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MODULE_CONTAINER_DIRECTORY = 'module';

const ARTIFACT_DIRECTORY = '/tmp/artifacts/';
const ARTIFACT_FILE_NAME = `${ARTIFACT_DIRECTORY}/amp_nomodule_build.tar.gz`;
const TEST_FILES_LIST_FILE_NAME = '/tmp/testfiles.txt';
const FILELIST_PATH = '/tmp/filelist.txt';

const BUILD_OUTPUT_DIRS = ['build', 'dist', 'dist.3p', 'dist.tools'];
const APP_SERVING_DIRS = [
Expand Down Expand Up @@ -327,17 +327,17 @@ function generateCircleCiShardTestFileList(globs) {
)
.trim()
.replace(/\s+/g, ',');
fs.writeFileSync(TEST_FILES_LIST_FILE_NAME, fileList, 'utf8');
fs.writeFileSync(FILELIST_PATH, fileList, 'utf8');
logWithoutTimestamp(
'Stored list of',
cyan(fileList.split(',').length),
'test files in',
cyan(TEST_FILES_LIST_FILE_NAME)
cyan(FILELIST_PATH)
);
}

module.exports = {
TEST_FILES_LIST_FILE_NAME,
FILELIST_PATH,
abortTimedJob,
printChangeSummary,
skipDependentJobs,
Expand Down

0 comments on commit 0aef555

Please sign in to comment.