From 3638e7a2ae484f7d3d8cb39606fab8bdfeea09ee Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 14:55:41 -0700 Subject: [PATCH] Temporarily hardcode chromedriver to 112.0.0 to enable all ftr tests (#3976) (#4038) The latest version of chromedriver is 112.0.1 which does not support node 14. This PR hardcodes chromedriver to 112.0.0 temporarily. Pls revert it once we bump to node 18. Issue Resolved https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3975 Signed-off-by: ananzh (cherry picked from commit 5ea0cbe25223e24badfe27f79813ee313c9af0b0) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- scripts/upgrade_chromedriver.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade_chromedriver.js b/scripts/upgrade_chromedriver.js index 49e1d23bfa8c..7f54c7fa9c17 100644 --- a/scripts/upgrade_chromedriver.js +++ b/scripts/upgrade_chromedriver.js @@ -72,16 +72,31 @@ const versionCheckOutputTokens = (versionCheckOutput || '').match(/(?:^|\s)(9\d| const majorVersion = Array.isArray(versionCheckOutputTokens) && versionCheckOutputTokens[1]; if (majorVersion) { + let targetVersion = `^${majorVersion}`; + + // TODO: Temporary fix to install chromedriver 112.0.0 if major version is 112. + // Exit if major version is greater than 112. + // Revert this once node is bumped to 16+. + // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3975 + if (parseInt(majorVersion) === 112) { + targetVersion = '112.0.0'; + } else if (parseInt(majorVersion) > 112) { + console.error( + `::error::Chrome version (${majorVersion}) is not supported by this script. The largest chrome version we support is 112.` + ); + process.exit(1); + } + if (process.argv.includes('--install')) { - console.log(`Installing chromedriver@^${majorVersion}`); + console.log(`Installing chromedriver@${targetVersion}`); - spawnSync(`yarn add --dev chromedriver@^${majorVersion}`, { + spawnSync(`yarn add --dev chromedriver@${targetVersion}`, { stdio: 'inherit', cwd: process.cwd(), shell: true, }); } else { - console.log(`Upgrading to chromedriver@^${majorVersion}`); + console.log(`Upgrading to chromedriver@${targetVersion}`); let upgraded = false; const writeStream = createWriteStream('package.json.upgrading-chromedriver', { flags: 'w' }); @@ -93,7 +108,7 @@ if (majorVersion) { if (line.includes('"chromedriver": "')) { line = line.replace( /"chromedriver":\s*"[~^]?\d[\d.]*\d"/, - `"chromedriver": "^${majorVersion}"` + `"chromedriver": "${targetVersion}"` ); upgraded = true; } @@ -108,11 +123,11 @@ if (majorVersion) { renameSync('package.json', 'package.json.bak'); renameSync('package.json.upgrading-chromedriver', 'package.json'); - console.log(`Backed up package.json and updated chromedriver to ${majorVersion}`); + console.log(`Backed up package.json and updated chromedriver to ${targetVersion}`); } else { unlinkSync('package.json.upgrading-chromedriver'); console.error( - `Failed to update chromedriver to ${majorVersion}. Try adding the \`--install\` switch.` + `Failed to update chromedriver to ${targetVersion}. Try adding the \`--install\` switch.` ); } });