Skip to content
Merged
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
48 changes: 34 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,43 @@ async function run() {

if (chrome) {
cp.execSync('wget -q -O /tmp/chrome-versions.json "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json"')
const stableChannel = JSON.parse(fs.readFileSync('/tmp/chrome-versions.json', 'utf8')).channels.Stable
const downloads = stableChannel.downloads
const stableChannel = JSON.parse(fs.readFileSync('/tmp/chrome-versions.json', 'utf8')).channels.Stable;
const downloads = stableChannel.downloads;

const chromeUrl = downloads.chrome.find(d => d.platform === 'linux64').url
const chromedriverUrl = downloads.chromedriver.find(d => d.platform === 'linux64').url
const chromeUrl = downloads.chrome.find(d => d.platform === 'linux64').url;
const chromedriverUrl = downloads.chromedriver.find(d => d.platform === 'linux64').url;

console.log(`Downloading Chrome version: ${stableChannel.version}`)
cp.execSync(`wget -q -O /tmp/chrome-linux64.zip "${chromeUrl}"`)
cp.execSync('unzip -q /tmp/chrome-linux64.zip -d /tmp/chrome-linux64')
cp.execSync('sudo mv /tmp/chrome-linux64/chrome-linux64/chrome /usr/local/bin/google-chrome')
cp.execSync('sudo chmod +x /usr/local/bin/google-chrome')
console.log(`Downloading Chrome version: ${stableChannel.version}`);
cp.execSync(`wget -q -O /tmp/chrome.zip "${chromeUrl}"`);
cp.execSync('rm -rf /tmp/chrome');
cp.execSync('sudo rm -rf /opt/google/chrome');
cp.execSync('unzip -q /tmp/chrome.zip -d /tmp/chrome');

console.log(`Downloading Chromedriver version: ${stableChannel.version}`)
cp.execSync(`wget -q -O /tmp/chromedriver-linux64.zip "${chromedriverUrl}"`)
cp.execSync('unzip -q /tmp/chromedriver-linux64.zip -d /tmp/chromedriver-linux64')
cp.execSync('sudo mv /tmp/chromedriver-linux64/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver')
cp.execSync('sudo chmod +x /usr/local/bin/chromedriver')
// Install Chrome where Selenium is already finding it
cp.execSync('sudo mkdir -p /opt/google/chrome');
cp.execSync('sudo mv /tmp/chrome/chrome-linux64/* /opt/google/chrome/');

// Symlink
cp.execSync('sudo ln -sf /opt/google/chrome/chrome /usr/local/bin/google-chrome');
cp.execSync('sudo chmod +x /opt/google/chrome/chrome');

console.log(`Downloading Chromedriver version: ${stableChannel.version}`);
cp.execSync(`wget -q -O /tmp/chromedriver.zip "${chromedriverUrl}"`);
cp.execSync('rm -rf /tmp/chromedriver');
cp.execSync('sudo rm -rf /opt/chromedriver');
cp.execSync('unzip -q /tmp/chromedriver.zip -d /tmp/chromedriver');

cp.execSync('sudo mkdir -p /opt/chromedriver');
cp.execSync('sudo mv /tmp/chromedriver/chromedriver-linux64 /opt/chromedriver/');

// Symlink
cp.execSync('sudo ln -sf /opt/chromedriver/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver');
cp.execSync('sudo chmod +x /opt/chromedriver/chromedriver-linux64/chromedriver');

// Debug
cp.execSync('/opt/google/chrome/chrome --version', { stdio: 'inherit' });
cp.execSync('google-chrome --version', { stdio: 'inherit' });
cp.execSync('chromedriver --version', { stdio: 'inherit' });
}
if (chrome || prodAptDeps || postgres) {
cp.execSync("DEBIAN_FRONTEND=noninteractive sudo apt-get update")
Expand Down
Loading