Skip to content
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

[CI] Enforce lockfile is kept up to date #21739

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ aliases:
command: |
./scripts/circleci/check_license.sh
./scripts/circleci/check_cache.sh
./scripts/circleci/validate_yarn_lockfile.sh
when: always

- &download-dependencies-gradle
Expand Down
39 changes: 39 additions & 0 deletions scripts/circleci/validate_yarn_lockfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Abort the mission if any command fails
set -e

# Allow the script to be invoked from various environments
if [[ -z "${OVERRIDE_YARN_BINARY}" ]]; then
YARN_BINARY=$(command -v yarn)
else
YARN_BINARY="${OVERRIDE_YARN_BINARY}"
fi

REACT_NATIVE_TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX)

function cleanup {
set +e
rm -rf "$REACT_NATIVE_TEMP_DIR"
set -e
}

function msg {
echo -e " "
echo -e "\\x1B[36m${1}\\x1B[0m";
echo -e "\\x1B[36m${1//?/=}\\x1B[0m"
}

trap cleanup EXIT

cp -R ./package.json "$REACT_NATIVE_TEMP_DIR"
cp -R ./yarn.lock "$REACT_NATIVE_TEMP_DIR"
pushd "$REACT_NATIVE_TEMP_DIR" >/dev/null

if ! $YARN_BINARY --ignore-scripts --silent --non-interactive --mutex network --frozen-lockfile; then
msg "Yarn validation failed."
echo "This means the package.json and yarn.lock disagree in some way."
echo "Try fixing it by running \`yarn\` and committing the changes."
fi

popd >/dev/null