-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update chrome installation flow
- Loading branch information
Showing
4 changed files
with
430 additions
and
2,254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,44 @@ | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const downloadChromium = require('hermione-headless-chrome/lib/download-chromium-by-version'); | ||
const {pipeline} = require('stream'); | ||
const {promisify} = require('util'); | ||
const AdmZip = require('adm-zip'); | ||
const got = require('got'); | ||
|
||
downloadChromium(process.env.CHROME_VERSION, path.join(os.homedir(), 'chrome-cache'), 10) | ||
.then(chromePath => console.log(chromePath)); | ||
const streamPipeline = promisify(pipeline); | ||
|
||
const download = async (url) => { | ||
// Create a temporary directory to store the downloaded file | ||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chrome-download-')); | ||
|
||
// Path for the downloaded zip file | ||
const zipFilePath = path.join(tempDir, 'chrome-linux64.zip'); | ||
|
||
await streamPipeline( | ||
got.stream(url), | ||
fs.createWriteStream(zipFilePath) | ||
); | ||
|
||
return zipFilePath; | ||
}; | ||
|
||
const extract = async (zipFilePath) => { | ||
const zip = new AdmZip(zipFilePath); | ||
|
||
const outPath = path.dirname(zipFilePath); | ||
|
||
zip.extractAllTo(outPath); | ||
|
||
return path.join(outPath, 'chrome-linux64'); | ||
}; | ||
|
||
(async () => { | ||
// Available good versions of Chrome for testing: https://googlechromelabs.github.io/chrome-for-testing/known-good-versions.json | ||
const CHROME_URL = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.49/linux64/chrome-linux64.zip'; | ||
|
||
const chromeZipPath = await download(CHROME_URL); | ||
const chromePath = await extract(chromeZipPath); | ||
|
||
console.log(chromePath); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The download script outputs progress messages, but we need only final path, hence we filter output here | ||
CHROME_PATH=$(node ./download-chromium.js |& grep '^/home') | ||
CHROME_PATH=$(dirname $CHROME_PATH) | ||
CHROME_PATH=$(node ./download-chromium.js) | ||
mkdir ~/browsers | ||
mv $CHROME_PATH ~/browsers/chrome-linux |
Oops, something went wrong.