Skip to content

Commit

Permalink
chore(integration): use offline install (#9599)
Browse files Browse the repository at this point in the history
### Description

This PR does 3 things:
- Switch to use `--offline` when performing `npm install` to ensure we
are only using internal packages in our fixtures. We only do it for
`npm` as it lacks a `workspace` protocol.
- Add a `util` package that we were referencing in our nested workspace
fixture
- Add `--no-install` flag for tests that don't need to install deps.
Currently only used for our framework inference test where the presence
of `next` in a `package.json` is all we need. We never actually need
`next`.

### Testing Instructions

Passes in CI
  • Loading branch information
chris-olszewski authored Dec 10, 2024
1 parent 11b6c37 commit f0cd0fd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion turborepo-tests/helpers/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ elif [[ $1 != "" ]]; then
fi

if [ "$PACKAGE_MANAGER" == "npm" ]; then
npm install > /dev/null 2>&1
npm install --offline > /dev/null 2>&1
if [[ "$OSTYPE" == "msys" ]]; then
dos2unix --quiet "package-lock.json"
fi
Expand Down
26 changes: 22 additions & 4 deletions turborepo-tests/helpers/setup_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@

set -eo pipefail

FIXTURE_NAME="${1-basic_monorepo}"
INSTALL_DEPS=true
ARGS=()

while [[ $# -gt 0 ]]; do
case "$1" in
--no-install)
INSTALL_DEPS=false
shift # past the option
;;
*)
ARGS+=("$1")
shift
esac
done


FIXTURE_NAME="${ARGS[0]-basic_monorepo}"

# Default to version of npm installed with Node 18.20.2
# If CI is failing, check that this version is the same as
# the CI runner's version of npm
PACKAGE_MANAGER="[email protected]"
if [[ $2 != "" ]]; then
PACKAGE_MANAGER="$2"
if [[ "${ARGS[1]}" != "" ]]; then
PACKAGE_MANAGER="${ARGS[1]}"
fi

THIS_DIR=$(dirname "${BASH_SOURCE[0]}")
Expand All @@ -28,7 +44,9 @@ fi
"${TURBOREPO_TESTS_DIR}/helpers/copy_fixture.sh" "${TARGET_DIR}" "${FIXTURE_NAME}" "${TURBOREPO_TESTS_DIR}/integration/fixtures"
"${TURBOREPO_TESTS_DIR}/helpers/setup_git.sh" "${TARGET_DIR}"
"${TURBOREPO_TESTS_DIR}/helpers/setup_package_manager.sh" "${TARGET_DIR}" "$PACKAGE_MANAGER"
"${TURBOREPO_TESTS_DIR}/helpers/install_deps.sh" "$PACKAGE_MANAGER"
if $INSTALL_DEPS; then
"${TURBOREPO_TESTS_DIR}/helpers/install_deps.sh" "$PACKAGE_MANAGER"
fi

# Set TURBO env var, it is used by tests to run the binary
if [[ "${OSTYPE}" == "msys" ]]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "util"
}
2 changes: 1 addition & 1 deletion turborepo-tests/integration/tests/framework-inference.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Setup
$ . ${TESTDIR}/../../helpers/setup_integration_test.sh framework_inference
$ . ${TESTDIR}/../../helpers/setup_integration_test.sh framework_inference --no-install

Prove that we start with no inferred variables
$ ${TURBO} run build --dry=json | jq -r '.tasks[].environmentVariables.inferred'
Expand Down
4 changes: 2 additions & 2 deletions turborepo-tests/integration/tests/run/unnamed-packages.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Setup
Run a build. In this test, the fixture is set up so that the nested package
which does not have a name should be ignored. We should process it but filter.
$ ${TURBO} build
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Packages in scope: my-app, util (esc)
\xe2\x80\xa2 Running build in 2 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache miss, executing [0-9a-f]+ (re)
my-app:build:
Expand Down

0 comments on commit f0cd0fd

Please sign in to comment.