Skip to content

Commit

Permalink
ci(examples): Skip npm install when setting up git for examples tests
Browse files Browse the repository at this point in the history
The extra npm install step creates a package-lock.json which causes
turborepo to detect the wrong package manager, which ends up changing
behavior.
  • Loading branch information
mehulkar committed Jun 8, 2023
1 parent a00ba87 commit 4bfd3c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion turborepo-tests/examples/run-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST_FILE="tests/$2-$1.t"

if [ -f "$TEST_FILE" ]; then
echo "Running $TEST_FILE"
.cram_env/bin/prysk --shell="$(which bash)" "$TEST_FILE"
.cram_env/bin/prysk --shell="$(which bash)" "$TEST_FILE" --keep-tmpdir
else
echo "Could not find $TEST_FILE"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion turborepo-tests/examples/tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ fi
# Delete .git directory if it's there, we'll set up a new git repo
[ ! -d .git ] || rm -rf .git

"$MONOREPO_ROOT_DIR/turborepo-tests/helpers/setup_git.sh" "${TARGET_DIR}"
"$MONOREPO_ROOT_DIR/turborepo-tests/helpers/setup_git.sh" "${TARGET_DIR}" "false"
8 changes: 7 additions & 1 deletion turborepo-tests/helpers/setup_git.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env bash

TARGET_DIR=$1
# If a second parameter isn't passed, default to true
SHOULD_INSTALL=${2:-true}

git init ${TARGET_DIR} --quiet --initial-branch=main
GIT_ARGS="--git-dir=${TARGET_DIR}/.git --work-tree=${TARGET_DIR}"
git ${GIT_ARGS} config user.email "turbo-test@example.com"
git ${GIT_ARGS} config user.name "Turbo Test"
echo "script-shell=$(which bash)" > ${TARGET_DIR}/.npmrc
npm --prefix=${TARGET_DIR} install --silent

if [ $SHOULD_INSTALL == "true" ]; then
npm --prefix=${TARGET_DIR} install --silent
fi
git ${GIT_ARGS} add .
git ${GIT_ARGS} commit -m "Initial" --quiet

0 comments on commit 4bfd3c4

Please sign in to comment.