Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Automate collection of serverless chrome (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawndrape authored Nov 23, 2018
1 parent 17cc7a8 commit eb160d7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ npm-debug.log
dist/
example/repo/yarn.lock
example/repo/node_modules/
example/repo/output/
example/repo/output/

serverless_chromium.zip
headless-chromium
25 changes: 25 additions & 0 deletions infrastructure/scripts/download-serverless-chrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -x

if ! type -p jq &>/dev/null; then
echo "Could not find dependency 'jq'. Aborting."
exit 1
fi

if [ -z $SERVERLESS_CHROME_VERSION ]
then
SERVERLESS_CHROME_VERSION=v1.0.0-55
fi

if [ $OUTPUT_DIR ]
then
cd $OUTPUT_DIR
fi

DOWNLOAD_URL=`curl --silent https://api.github.com/repos/adieuadieu/serverless-chrome/releases/tags/${SERVERLESS_CHROME_VERSION} | jq -r '.assets[] | select(.name | startswith("stable")) | .browser_download_url'`
echo "Downloading from URL: ${DOWLOAD_URL}"
curl -L $DOWNLOAD_URL --output serverless_chromium.zip

unzip serverless_chromium.zip

tar -cvzf HeadlessChromium-${SERVERLESS_CHROME_VERSION}.tar.gz headless-chromium
rm headless-chromium serverless_chromium.zip
6 changes: 5 additions & 1 deletion service/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package: check-versions
serverless package --package "${BUILD_DIR}"

.PHONY: deploy
deploy: check-versions
deploy: check-versions download-serverless-chrome
serverless deploy --package "${BUILD_DIR}"
aws s3 sync ./chrome s3://sanity-runner-chrome-images-${AWS_PROFILE}

Expand All @@ -47,6 +47,10 @@ check-versions:
@../infrastructure/scripts/check-versions.sh


.PHONY: download-serverless-chrome
download-serverless-chrome:
OUTPUT_DIR=./chrome ../infrastructure/scripts/download-serverless-chrome.sh

.PHONY: clean
clean:
@rm -rf .serverless
Expand Down
2 changes: 1 addition & 1 deletion service/src/lambdaHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports.handler = async function(event, context, callback) {
const chrome = new ChromeInstaller({
executablePath: paths.chrome(),
s3Bucket: process.env.CHROME_BUCKET,
s3Key: 'HeadlessChromium-69.0.3497.81.tar.gz',
s3Key: 'HeadlessChromium-v1.0.0-55.tar.gz',
debug: process.env.DEBUG || false,
})
await chrome.setupChrome()
Expand Down
2 changes: 1 addition & 1 deletion service/src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')

module.exports = {
chrome: function() {
return path.join(os.tmpdir(), 'headless_shell')
return path.join(os.tmpdir(), 'headless-chromium')
},
jest: function() {
return path.resolve(__dirname, '../node_modules/jest-cli/bin/jest.js')
Expand Down

0 comments on commit eb160d7

Please sign in to comment.