Skip to content

build: ensure dependencies are properly locked #13482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ before_install:
- if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]; then ./scripts/install-angular-snapshot.sh --only-save; fi

install:
- yarn install --frozen-lockfile --non-interactive
- ./scripts/ci/travis-install.sh

before_script:
- mkdir -p $LOGS_DIR
Expand Down
24 changes: 24 additions & 0 deletions scripts/ci/travis-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Script that installs the project node module dependencies within Travis. The script also ensures that the cached
# node modules are in sync with the lock file and also checks that if the lock file is in sync with the
# project `package.json` file.

# Go to the project root directory
cd $(dirname $0)/../..

# Yarn's integrity check command throws in the following scenarios:
# 1) Cached node modules are not in sync with lock file
# 2) Lock file is not in sync with `package.json`

# In case the integrity check passes, we just use the cached/locked node modules. If it fails, we want to purge the
# node modules and run Yarn with `--frozen-lockfile`. Running with a frozen lockfile ensures that outdated/cached node
# modules will be refreshed to **match** the actual lock file. Otherwise, if the `package.json` does not match with
# the lock file, Yarn automatically throws an error due to the `--frozen-lockfile` option.
if ! (yarn check --integrity &> /dev/null); then
echo "Cached node modules are not in sync. Purging and refreshing..."
rm -rf ./node_modules/
yarn install --frozen-lockfile --non-interactive
else
echo "Cached node modules have been checked and are in sync with the lock file."
fi