Merge pull request #4743 from MetaMask/circle-ci-node-modules-caching-fix

Improve CircleCI workflow
This commit is contained in:
Bruno Barbieri 2018-07-06 17:58:10 -04:00 committed by GitHub
commit b4aaf30d6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 37 deletions

View File

@ -101,29 +101,31 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} keys:
- dependency-cache-{{ checksum "package-lock.json" }}
# fallback to using the latest cache if no exact match is found
- dependency-cache-
- run: - run:
name: Install deps via npm name: Install npm 6 + deps via npm
command: npm install command: |
sudo npm install -g npm@6.1.0 && npm install
- save_cache: - save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }} key: dependency-cache-{{ checksum "package-lock.json" }}
paths: paths:
- node_modules - node_modules
- save_cache:
key: dependency-cache-{{ .Revision }}
paths:
- node_modules
prep-deps-firefox: prep-deps-firefox:
docker: docker:
- image: circleci/node:8.11.3-browsers - image: circleci/node:8.11.3-browsers
steps: steps:
- checkout - checkout
- restore_cache:
key: dependency-cache-firefox-
- run: - run:
name: Download Firefox name: Download Firefox If needed
command: ./.circleci/scripts/firefox-download.sh command: ./.circleci/scripts/firefox-download.sh
- save_cache: - save_cache:
key: dependency-cache-firefox-{{ .Revision }} key: dependency-cache-firefox-
paths: paths:
- firefox - firefox
@ -133,7 +135,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: build:dist name: build:dist
command: npm run dist command: npm run dist
@ -152,7 +154,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: build:dist name: build:dist
command: npm run doc command: npm run doc
@ -167,7 +169,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Get Scss Cache key name: Get Scss Cache key
# this allows us to checksum against a whole directory # this allows us to checksum against a whole directory
@ -186,7 +188,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Test name: Test
command: npm run lint command: npm run lint
@ -197,7 +199,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Test name: Test
command: npx nsp check command: npx nsp check
@ -208,7 +210,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- run: - run:
@ -224,12 +226,12 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-firefox-{{ .Revision }} key: dependency-cache-firefox-
- run: - run:
name: Install firefox name: Install firefox
command: ./.circleci/scripts/firefox-install.sh command: ./.circleci/scripts/firefox-install.sh
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- run: - run:
@ -245,7 +247,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- run: - run:
@ -261,12 +263,12 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-firefox-{{ .Revision }} key: dependency-cache-firefox-
- run: - run:
name: Install firefox name: Install firefox
command: ./.circleci/scripts/firefox-install.sh command: ./.circleci/scripts/firefox-install.sh
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- run: - run:
@ -282,7 +284,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- run: - run:
@ -299,7 +301,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- restore_cache: - restore_cache:
@ -326,7 +328,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- restore_cache: - restore_cache:
key: build-cache-{{ .Revision }} key: build-cache-{{ .Revision }}
- restore_cache: - restore_cache:
@ -349,7 +351,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: test:coverage name: test:coverage
command: npm run test:coverage command: npm run test:coverage
@ -362,12 +364,12 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-firefox-{{ .Revision }} key: dependency-cache-firefox-
- run: - run:
name: Install firefox name: Install firefox
command: ./.circleci/scripts/firefox-install.sh command: ./.circleci/scripts/firefox-install.sh
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Get Scss Cache key name: Get Scss Cache key
# this allows us to checksum against a whole directory # this allows us to checksum against a whole directory
@ -386,7 +388,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Get Scss Cache key name: Get Scss Cache key
# this allows us to checksum against a whole directory # this allows us to checksum against a whole directory
@ -405,12 +407,12 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-firefox-{{ .Revision }} key: dependency-cache-firefox-
- run: - run:
name: Install firefox name: Install firefox
command: ./.circleci/scripts/firefox-install.sh command: ./.circleci/scripts/firefox-install.sh
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Get Scss Cache key name: Get Scss Cache key
# this allows us to checksum against a whole directory # this allows us to checksum against a whole directory
@ -429,7 +431,7 @@ jobs:
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
key: dependency-cache-{{ .Revision }} key: dependency-cache-{{ checksum "package-lock.json" }}
- run: - run:
name: Get Scss Cache key name: Get Scss Cache key
# this allows us to checksum against a whole directory # this allows us to checksum against a whole directory

View File

@ -1,6 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Checking if firefox was already downloaded"
echo "Downloading firefox..." if [ -d "firefox" ]
wget https://ftp.mozilla.org/pub/firefox/releases/58.0/linux-x86_64/en-US/firefox-58.0.tar.bz2 \ then
&& tar xjf firefox-58.0.tar.bz2 echo "Firefox found. No need to download"
echo "firefox download complete" else
FIREFOX_VERSION="61.0.1"
FIREFOX_BINARY="firefox-$FIREFOX_VERSION.tar.bz2"
echo "Downloading firefox..."
wget "https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/$FIREFOX_BINARY" \
&& tar xjf "$FIREFOX_BINARY"
echo "firefox download complete"
fi

View File

@ -2,7 +2,7 @@
echo "Installing firefox..." echo "Installing firefox..."
sudo rm -r /opt/firefox sudo rm -r /opt/firefox
sudo mv firefox /opt/firefox58 sudo mv firefox /opt/firefox61
sudo mv /usr/bin/firefox /usr/bin/firefox-old sudo mv /usr/bin/firefox /usr/bin/firefox-old
sudo ln -s /opt/firefox58/firefox /usr/bin/firefox sudo ln -s /opt/firefox61/firefox /usr/bin/firefox
echo "Firefox installed." echo "Firefox installed."