From 67eed9ab81601c5d2744a5c41997e35e330ab785 Mon Sep 17 00:00:00 2001 From: Andrej Zachar Date: Sat, 26 Nov 2016 22:18:31 +0100 Subject: [PATCH] feat: cache support + $USE_LATEST_CHROME save chrome to ~/downloads folder that is cached downloading is managed by the environmental variable $USE_LATEST_CHROME (if true, it will install the latest chrome, if anything else, it does nothing) --- README.md | 11 ++++++----- use_chrome_stable_version.sh | 13 ++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 630bdd4..6e02f03 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Circleci Use Chrome Stable Version -To force the use of the latest stable version of Chrome on Circle CI, define those lines in your circle.yml configuration file +To force the use of the latest stable version of Chrome on Circle CI, define those lines in your circle.yml configuration file and set enviromental variable $USE_LATEST_CHROME=true ``` dependencies: - pre: - - curl -s https://raw.githubusercontent.com/chronogolf/circleci-google-chrome/master/use_chrome_stable_version.sh | bash -``` - + cache_directories: + - '~/downloads' +pre: + # download the latest Google Chrome if enabled by enviromental variable $USE_LATEST_CHROME + - if [[ $USE_LATEST_CHROME == true ]]; then if test -f "$HOME/downloads/use_chrome_stable_version.sh"; then sh $HOME/downloads/use_chrome_stable_version.sh; else curl -o $HOME/downloads/use_chrome_stable_version.sh --create-dirs https://raw.githubusercontent.com/azachar/circleci-google-chrome/master/use_chrome_stable_version.sh && bash $HOME/downloads/use_chrome_stable_version.sh; fi; fi; diff --git a/use_chrome_stable_version.sh b/use_chrome_stable_version.sh index ef9b9f6..87d75f4 100644 --- a/use_chrome_stable_version.sh +++ b/use_chrome_stable_version.sh @@ -1,10 +1,17 @@ #!/bin/bash -function use_chrome_stable_version { - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; +use_chrome_stable_version() { + echo 'Upgrading the current Chrome version:'; + google-chrome --version + cd $HOME/downloads + if ! test -f "google-chrome.deb" + then + curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; + fi sudo dpkg -i google-chrome.deb; sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome; - rm google-chrome.deb + echo 'The latest Chrome version is:'; + google-chrome --version } use_chrome_stable_version