diff --git a/scripts/circleci/pipeline_selection.js b/scripts/circleci/pipeline_selection.js index 5804ce82755ffc..5312caa03f6dc6 100644 --- a/scripts/circleci/pipeline_selection.js +++ b/scripts/circleci/pipeline_selection.js @@ -54,10 +54,6 @@ const mapping = [ name: 'RUN_ANDROID', filterFN: name => name.indexOf('ReactAndroid/') > -1, }, - // { - // name: 'RUN_E2E', - // filterFN: name => name.indexOf('rn-tester-e2e/') > -1, - // }, { name: 'RUN_JS', filterFN: name => isJSChange(name), @@ -109,8 +105,7 @@ yargs 'filter-jobs', 'Filters the jobs based on the list of chaged files in the PR', filterJobsOptions, - argv => - filterJobs(argv.output_path).then(() => console.info('Filtering done!')), + argv => filterJobs(argv.output_path), ) .demandCommand() .strict() @@ -135,7 +130,23 @@ function _getFilesFromGit() { } } -async function _computeAndSavePipelineParameters(pipelineType, outputPath) { +function _shouldRunE2E() { + try { + const gitCommand = 'git log -1 --pretty=format:"%B" | head -n 1'; + const commitMessage = String(execSync(gitCommand)).trim(); + console.log(`commitMessage: ${commitMessage}`); + return commitMessage.includes('#run-e2e-tests'); + } catch (error) { + console.error(error); + return false; + } +} + +function _computeAndSavePipelineParameters( + pipelineType, + outputPath, + shouldRunE2E, +) { fs.mkdirSync(outputPath, {recursive: true}); const filePath = `${outputPath}/pipeline_config.json`; @@ -144,8 +155,12 @@ async function _computeAndSavePipelineParameters(pipelineType, outputPath) { return; } + console.log(`Should run e2e? ${shouldRunE2E}`); if (pipelineType === 'ALL') { - fs.writeFileSync(filePath, JSON.stringify({run_all: true}, null, 2)); + fs.writeFileSync( + filePath, + JSON.stringify({run_all: true, run_e2e: shouldRunE2E}, null, 2), + ); return; } @@ -154,7 +169,7 @@ async function _computeAndSavePipelineParameters(pipelineType, outputPath) { run_ios: pipelineType === 'RUN_IOS', run_android: pipelineType === 'RUN_ANDROID', run_js: pipelineType === 'RUN_JS', - // run_e2e: pipelineType === 'RUN_E2E' || pipelineType === 'RUN_JS', + run_e2e: shouldRunE2E, }; const stringifiedParams = JSON.stringify(params, null, 2); @@ -180,8 +195,8 @@ function createConfigs(inputPath, outputPath, configFile) { const testConfigs = { run_ios: ['testIOS.yml'], run_android: ['testAndroid.yml'], - // run_e2e: ['testE2E.yml'], - run_all: [/*'testE2E.yml',*/ 'testJS.yml', 'testAll.yml'], + run_e2e: ['testE2E.yml'], + run_all: ['testJS.yml', 'testAll.yml'], run_js: ['testJS.yml'], }; @@ -211,20 +226,22 @@ function createConfigs(inputPath, outputPath, configFile) { ); } -async function filterJobs(outputPath) { +function filterJobs(outputPath) { const fileList = _getFilesFromGit(); if (fileList.length === 0) { - await _computeAndSavePipelineParameters('SKIP', outputPath); + _computeAndSavePipelineParameters('SKIP', outputPath); return; } + const shouldRunE2E = _shouldRunE2E(); + for (const filter of mapping) { const found = fileList.every(filter.filterFN); if (found) { - await _computeAndSavePipelineParameters(filter.name, outputPath); + _computeAndSavePipelineParameters(filter.name, outputPath, shouldRunE2E); return; } } - await _computeAndSavePipelineParameters('ALL', outputPath); + _computeAndSavePipelineParameters('ALL', outputPath, shouldRunE2E); }