diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f86eb3ae0a67c..1ec21813e4a9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -167,7 +167,7 @@ jobs: with: PATTERNS: | examples/** - turborepo-tests/examples/** + examples-tests/** !**.md !**.mdx @@ -322,40 +322,6 @@ jobs: runner: ubuntu-latest - name: macos runner: macos-latest - manager: [yarn, npm] - example: [with-yarn, with-npm, non-monorepo] - include: - - os: - name: ubuntu - runner: ubuntu-latest - manager: pnpm - example: basic - - os: - name: macos - runner: macos-latest - manager: pnpm - example: basic - - os: - name: ubuntu - runner: ubuntu-latest - manager: pnpm - example: kitchen-sink - - os: - name: macos - runner: macos-latest - manager: pnpm - example: kitchen-sink - - os: - name: ubuntu - runner: ubuntu-latest - manager: pnpm - example: with-svelte - - os: - name: macos - runner: macos-latest - manager: pnpm - example: with-svelte - runs-on: ${{ matrix.os.runner }} steps: # Used by scripts/check-examples.sh @@ -397,14 +363,14 @@ jobs: cache: ${{ matrix.manager }} cache-dependency-path: package.json - - name: Check \"${{ matrix.example }}\" example with \"${{ matrix.manager }}\" + - name: Test examples shell: bash env: FORCE_COLOR: true TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} TURBO_REMOTE_ONLY: true - run: turbo run test --filter="turborepo-tests-examples" -- "${{ matrix.example }}" "${{ matrix.manager }}" + run: turbo run example-test --filter="@turborepo-examples-tests/*" rust_prepare: name: Check rust crates diff --git a/turborepo-tests/examples/README.md b/examples-tests/README.md similarity index 100% rename from turborepo-tests/examples/README.md rename to examples-tests/README.md diff --git a/examples-tests/helpers/package.json b/examples-tests/helpers/package.json new file mode 100644 index 0000000000000..2d2a49ec53ab5 --- /dev/null +++ b/examples-tests/helpers/package.json @@ -0,0 +1,6 @@ +{ + "name": "@turborepo-examples-tests/helpers", + "scripts": { + "setup": "./setup_prysk.sh" + } +} diff --git a/examples-tests/helpers/setup_prysk.sh b/examples-tests/helpers/setup_prysk.sh new file mode 100755 index 0000000000000..54a2d04437a1a --- /dev/null +++ b/examples-tests/helpers/setup_prysk.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +BASE_DIR="$PWD/.." + +echo "basedir: $BASE_DIR" + +if [ -f "$BASE_DIR/.cram_env/bin/prysk" ]; then + echo "Skipping prysk setup, prysk and venv already exists" +else + python3 -m venv "$BASE_DIR/.cram_env" + "$BASE_DIR/.cram_env/bin/python3" -m pip install --quiet --upgrade pip + "$BASE_DIR/.cram_env/bin/pip" install "prysk==0.15.0" +fi diff --git a/examples-tests/helpers/turbo.json b/examples-tests/helpers/turbo.json new file mode 100644 index 0000000000000..c01e9235056cf --- /dev/null +++ b/examples-tests/helpers/turbo.json @@ -0,0 +1,7 @@ +{ + "extends": ["//"], + "pipeline": { + "setup": {}, + "topo": {} + } +} diff --git a/examples-tests/npm-non-monorepo/package.json b/examples-tests/npm-non-monorepo/package.json new file mode 100644 index 0000000000000..157b12e1cf251 --- /dev/null +++ b/examples-tests/npm-non-monorepo/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/npm-non-monorepo", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/yarn-non-monorepo.t b/examples-tests/npm-non-monorepo/test.t similarity index 74% rename from turborepo-tests/examples/tests/yarn-non-monorepo.t rename to examples-tests/npm-non-monorepo/test.t index bf568c053eda8..deb525783417e 100644 --- a/turborepo-tests/examples/tests/yarn-non-monorepo.t +++ b/examples-tests/npm-non-monorepo/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh non-monorepo yarn + $ . ${TESTDIR}/../setup.sh non-monorepo npm # run twice and make sure it works $ npx turbo build lint > /dev/null 2>&1 $ npx turbo build lint > /dev/null 2>&1 diff --git a/examples-tests/npm-with-npm/package.json b/examples-tests/npm-with-npm/package.json new file mode 100644 index 0000000000000..aa032f82ad3c0 --- /dev/null +++ b/examples-tests/npm-with-npm/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/npm-with-npm", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/npm-with-yarn.t b/examples-tests/npm-with-npm/test.t similarity index 75% rename from turborepo-tests/examples/tests/npm-with-yarn.t rename to examples-tests/npm-with-npm/test.t index 0959af72cc882..0fcdcd21ec521 100644 --- a/turborepo-tests/examples/tests/npm-with-yarn.t +++ b/examples-tests/npm-with-npm/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh with-yarn npm + $ . ${TESTDIR}/../setup.sh with-npm npm # run twice and make sure it works $ npm run build lint > /dev/null 2>&1 $ npm run build lint > /dev/null 2>&1 diff --git a/examples-tests/npm-with-yarn/package.json b/examples-tests/npm-with-yarn/package.json new file mode 100644 index 0000000000000..5d50a51b64b38 --- /dev/null +++ b/examples-tests/npm-with-yarn/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/npm-with-yarn", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/npm-with-npm.t b/examples-tests/npm-with-yarn/test.t similarity index 74% rename from turborepo-tests/examples/tests/npm-with-npm.t rename to examples-tests/npm-with-yarn/test.t index ad598fc92f70e..b9202d32106f2 100644 --- a/turborepo-tests/examples/tests/npm-with-npm.t +++ b/examples-tests/npm-with-yarn/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh with-npm npm + $ . ${TESTDIR}/../setup.sh with-yarn npm # run twice and make sure it works $ npm run build lint > /dev/null 2>&1 $ npm run build lint > /dev/null 2>&1 diff --git a/examples-tests/pnpm-basic/package.json b/examples-tests/pnpm-basic/package.json new file mode 100644 index 0000000000000..6001e0978e76f --- /dev/null +++ b/examples-tests/pnpm-basic/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/pnpm-basic", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/pnpm-basic.t b/examples-tests/pnpm-basic/test.t similarity index 76% rename from turborepo-tests/examples/tests/pnpm-basic.t rename to examples-tests/pnpm-basic/test.t index 860204f6634df..efd2df3bb7dd0 100644 --- a/turborepo-tests/examples/tests/pnpm-basic.t +++ b/examples-tests/pnpm-basic/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh basic pnpm + $ . ${TESTDIR}/../setup.sh basic pnpm # run twice and make sure it works $ pnpm run build lint > /dev/null 2>&1 $ pnpm run build lint > /dev/null 2>&1 diff --git a/examples-tests/pnpm-gatsby/package.json b/examples-tests/pnpm-gatsby/package.json new file mode 100644 index 0000000000000..02402b7344805 --- /dev/null +++ b/examples-tests/pnpm-gatsby/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/pnpm-gatsby", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/pnpm-gatsby.t b/examples-tests/pnpm-gatsby/test.t similarity index 73% rename from turborepo-tests/examples/tests/pnpm-gatsby.t rename to examples-tests/pnpm-gatsby/test.t index 2a7c7e3df73e9..39e0f42852de4 100644 --- a/turborepo-tests/examples/tests/pnpm-gatsby.t +++ b/examples-tests/pnpm-gatsby/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh with-gatsby pnpm + $ . ${TESTDIR}/../setup.sh with-gatsby pnpm # run twice and make sure it works $ pnpm run build lint > /dev/null 2>&1 $ pnpm run build lint > /dev/null 2>&1 diff --git a/examples-tests/pnpm-kitchen-sink/package.json b/examples-tests/pnpm-kitchen-sink/package.json new file mode 100644 index 0000000000000..56938119ce3e2 --- /dev/null +++ b/examples-tests/pnpm-kitchen-sink/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/pnpm-kitchen-sink", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/pnpm-with-svelte.t b/examples-tests/pnpm-kitchen-sink/test.t similarity index 73% rename from turborepo-tests/examples/tests/pnpm-with-svelte.t rename to examples-tests/pnpm-kitchen-sink/test.t index de8059c6068d0..a1996eb3d1d3e 100644 --- a/turborepo-tests/examples/tests/pnpm-with-svelte.t +++ b/examples-tests/pnpm-kitchen-sink/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh with-svelte pnpm + $ . ${TESTDIR}/../setup.sh kitchen-sink pnpm # run twice and make sure it works $ pnpm run build lint > /dev/null 2>&1 $ pnpm run build lint > /dev/null 2>&1 diff --git a/examples-tests/pnpm-with-svelte/package.json b/examples-tests/pnpm-with-svelte/package.json new file mode 100644 index 0000000000000..76c1152da5508 --- /dev/null +++ b/examples-tests/pnpm-with-svelte/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/pnpm-with-svelte", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/turborepo-tests/examples/tests/pnpm-kitchen-sink.t b/examples-tests/pnpm-with-svelte/test.t similarity index 73% rename from turborepo-tests/examples/tests/pnpm-kitchen-sink.t rename to examples-tests/pnpm-with-svelte/test.t index 8ad910e223a69..0ecf7737ea91d 100644 --- a/turborepo-tests/examples/tests/pnpm-kitchen-sink.t +++ b/examples-tests/pnpm-with-svelte/test.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/setup.sh kitchen-sink pnpm + $ . ${TESTDIR}/../setup.sh with-svelte pnpm # run twice and make sure it works $ pnpm run build lint > /dev/null 2>&1 $ pnpm run build lint > /dev/null 2>&1 diff --git a/turborepo-tests/examples/tests/setup.sh b/examples-tests/setup.sh similarity index 78% rename from turborepo-tests/examples/tests/setup.sh rename to examples-tests/setup.sh index f5c1a31c979e0..b9f54f6cbe7c4 100644 --- a/turborepo-tests/examples/tests/setup.sh +++ b/examples-tests/setup.sh @@ -1,12 +1,12 @@ #!/bin/bash -set -e +set -eo pipefail exampleName=$1 pkgManager=$2 # Copy the example dir over to the test dir that prysk puts you in SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") -MONOREPO_ROOT_DIR="$SCRIPT_DIR/../../.." +MONOREPO_ROOT_DIR="$SCRIPT_DIR/.." EXAMPLE_DIR="$MONOREPO_ROOT_DIR/examples/$exampleName" TARGET_DIR="$(pwd)" @@ -28,6 +28,7 @@ fi function set_package_manager() { cat package.json | jq ".packageManager=\"$1\"" | sponge package.json + corepack enable } # Set the packageManger version @@ -36,16 +37,19 @@ PNPM_PACKAGE_MANAGER_VALUE="pnpm@6.26.1" YARN_PACKAGE_MANAGER_VALUE="yarn@1.22.17" if [ "$pkgManager" == "npm" ]; then set_package_manager "$NPM_PACKAGE_MANAGER_VALUE" - npm install > /dev/null + npm install > /dev/null 2>&1 elif [ "$pkgManager" == "pnpm" ]; then set_package_manager "$PNPM_PACKAGE_MANAGER_VALUE" - pnpm install > /dev/null + pnpm install > /dev/null 2>&1 elif [ "$pkgManager" == "yarn" ]; then set_package_manager "$YARN_PACKAGE_MANAGER_VALUE" - yarn install > /dev/null + # Pass a --cache-folder here because yarn seems to have trouble + # running multiple yarn installs at the same time and we are running + # examples tests in parallel. https://github.com/yarnpkg/yarn/issues/1275 + yarn install --cache-folder="$PWD/.yarn-cache" 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" diff --git a/examples-tests/yarn-non-monorepo/package.json b/examples-tests/yarn-non-monorepo/package.json new file mode 100644 index 0000000000000..cbc34ab4ee5ee --- /dev/null +++ b/examples-tests/yarn-non-monorepo/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/yarn-non-monorepo", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/examples-tests/yarn-non-monorepo/test.t b/examples-tests/yarn-non-monorepo/test.t new file mode 100644 index 0000000000000..3682e18a3b5b9 --- /dev/null +++ b/examples-tests/yarn-non-monorepo/test.t @@ -0,0 +1,39 @@ + $ . ${TESTDIR}/../setup.sh non-monorepo yarn + yarn cache v1.22.17 + success Cleared cache. + Done in [\.0-9]+m?s\. (re) + yarn install v1.22.17 + info No lockfile found. + [1/4] Resolving packages... + [2/4] Fetching packages... + [3/4] Linking dependencies... + [4/4] Building fresh packages... + success Saved lockfile. + Done in [\.0-9]+m?s\. (re) + +# run twice and make sure it works + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Running build, lint + • Remote caching disabled + + Tasks: 2 successful, 2 total + Cached: 0 cached, 2 total + Time:\s*[\.0-9]+m?s (re) + + Done in [\.0-9]+m?s\. (re) + + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Running build, lint + • Remote caching disabled + + Tasks: 2 successful, 2 total + Cached: 2 cached, 2 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + + Done in [\.0-9]+m?s\. (re) + + $ git diff diff --git a/examples-tests/yarn-with-npm/package.json b/examples-tests/yarn-with-npm/package.json new file mode 100644 index 0000000000000..79bb6a8b26953 --- /dev/null +++ b/examples-tests/yarn-with-npm/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-examples-tests/yarn-with-npm", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/examples-tests/yarn-with-npm/test.t b/examples-tests/yarn-with-npm/test.t new file mode 100644 index 0000000000000..5152f7e5c8f94 --- /dev/null +++ b/examples-tests/yarn-with-npm/test.t @@ -0,0 +1,41 @@ + $ . ${TESTDIR}/../setup.sh with-npm yarn + yarn cache v1.22.17 + success Cleared cache. + Done in [\.0-9]+m?s\. (re) + yarn install v1.22.17 + info No lockfile found. + [1/4] Resolving packages... + [2/4] Fetching packages... + [3/4] Linking dependencies... + [4/4] Building fresh packages... + success Saved lockfile. + Done in [\.0-9]+m?s\. (re) + +# run twice and make sure it works + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Packages in scope: docs, eslint-config-custom, tsconfig, ui, web + • Running build, lint in 5 packages + • Remote caching disabled + + Tasks: 5 successful, 5 total + Cached: 0 cached, 5 total + Time:\s*[\.0-9]+m?s (re) + + Done in [\.0-9]+m?s\. (re) + + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Packages in scope: docs, eslint-config-custom, tsconfig, ui, web + • Running build, lint in 5 packages + • Remote caching disabled + + Tasks: 5 successful, 5 total + Cached: 5 cached, 5 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + + Done in [\.0-9]+m?s\. (re) + + $ git diff diff --git a/examples-tests/yarn-with-yarn/package.json b/examples-tests/yarn-with-yarn/package.json new file mode 100644 index 0000000000000..cf9bfb5e19bfd --- /dev/null +++ b/examples-tests/yarn-with-yarn/package.json @@ -0,0 +1,11 @@ +{ + "name": "@turborepo-tests-examples/yarn-with-yarn", + "scripts": { + "example-test": "../.cram_env/bin/prysk --shell=`which bash` test.t" + }, + "dependencies": { + "turborepo-tests-helpers": "workspace:*", + "@turborepo-examples-tests/helpers": "workspace:*", + "turborepo-examples": "workspace:*" + } +} diff --git a/examples-tests/yarn-with-yarn/test.t b/examples-tests/yarn-with-yarn/test.t new file mode 100644 index 0000000000000..9ddfdfaa37c06 --- /dev/null +++ b/examples-tests/yarn-with-yarn/test.t @@ -0,0 +1,41 @@ + $ . ${TESTDIR}/../setup.sh with-yarn yarn + yarn cache v1.22.17 + success Cleared cache. + Done in [\.0-9]+m?s\. (re) + yarn install v1.22.17 + info No lockfile found. + [1/4] Resolving packages... + [2/4] Fetching packages... + [3/4] Linking dependencies... + [4/4] Building fresh packages... + success Saved lockfile. + Done in [\.0-9]+m?s\. (re) + +# run twice and make sure it works + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Packages in scope: docs, eslint-config-custom, tsconfig, ui, web + • Running build, lint in 5 packages + • Remote caching disabled + + Tasks: 5 successful, 5 total + Cached: 0 cached, 5 total + Time:\s*[\.0-9]+m?s (re) + + Done in [\.0-9]+m?s\. (re) + + $ yarn turbo build lint --output-logs=none + yarn run v1.22.17 + \$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re) + • Packages in scope: docs, eslint-config-custom, tsconfig, ui, web + • Running build, lint in 5 packages + • Remote caching disabled + + Tasks: 5 successful, 5 total + Cached: 5 cached, 5 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + + Done in [\.0-9]+m?s\. (re) + + $ git diff diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa05b97dd27ad..c79137ff27b77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -218,6 +218,109 @@ importers: examples: specifiers: {} + examples-tests/helpers: + specifiers: {} + + examples-tests/npm-non-monorepo: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/npm-with-npm: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/npm-with-yarn: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/pnpm-basic: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/pnpm-gatsby: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/pnpm-kitchen-sink: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/pnpm-with-svelte: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/yarn-non-monorepo: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/yarn-with-npm: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + + examples-tests/yarn-with-yarn: + specifiers: + '@turborepo-examples-tests/helpers': workspace:* + turborepo-examples: workspace:* + turborepo-tests-helpers: workspace:* + dependencies: + '@turborepo-examples-tests/helpers': link:../helpers + turborepo-examples: link:../../examples + turborepo-tests-helpers: link:../../turborepo-tests/helpers + packages/create-turbo: specifiers: '@turbo/test-utils': workspace:* @@ -691,14 +794,6 @@ importers: uvu: 0.5.6 zstd-codec: 0.1.4 - turborepo-tests/examples: - specifiers: - turborepo-examples: workspace:* - turborepo-tests-helpers: workspace:* - dependencies: - turborepo-examples: link:../../examples - turborepo-tests-helpers: link:../helpers - turborepo-tests/helpers: specifiers: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 1a0aa0941d4da..0d28384e803d9 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -5,6 +5,7 @@ packages: - "packages/*" - "benchmark" - "turborepo-tests/*" + - "examples-tests/*" # Intentionally exclude the `npm` `turbo` package from the workspaces. - "!packages/turbo" - "packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose" diff --git a/turbo.json b/turbo.json index 5deea18681032..f7d2d44151080 100644 --- a/turbo.json +++ b/turbo.json @@ -24,6 +24,19 @@ "build": { "outputs": ["dist/**/*", ".next/**/*"], "dependsOn": ["^build"] + }, + // This is a synthetic tasks that lets us pull in other workspaces as dependencies + // So changes in internal workspaces that we depend on, will trigger this task. + "topo": { + "dependsOn": ["^topo"] + }, + + // example-tesst is in the root turbo.json so we don't have to redefine in each workspace + // Since they also has a unique set of dependencies, we don't model example tests with the + // test task, or we'd have to override the dependenies in each workspace. + "example-test": { + "dependsOn": ["topo", "@turborepo-examples-tests/helpers#setup"], + "inputs": ["test.t", "../run-example.sh"] } }, "experimentalSpaces": { diff --git a/turborepo-tests/examples/package.json b/turborepo-tests/examples/package.json deleted file mode 100644 index c8a245da4b756..0000000000000 --- a/turborepo-tests/examples/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "turborepo-tests-examples", - "scripts": { - "test": "./run-example.sh" - }, - "dependencies": { - "turborepo-tests-helpers": "workspace:*", - "turborepo-examples": "workspace:*" - } -} diff --git a/turborepo-tests/examples/run-example.sh b/turborepo-tests/examples/run-example.sh deleted file mode 100755 index 9bbcd99cf2c90..0000000000000 --- a/turborepo-tests/examples/run-example.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -python3 -m venv .cram_env -.cram_env/bin/pip install prysk - -export folder=$1 -export pkgManager=$2 - -TEST_FILE="tests/$2-$1.t" - -if [ -f "$TEST_FILE" ]; then - echo "Running $TEST_FILE" - .cram_env/bin/prysk --shell="$(which bash)" "$TEST_FILE" -else - echo "Could not find $TEST_FILE" - exit 1 -fi diff --git a/turborepo-tests/examples/tests/npm-non-monorepo.t b/turborepo-tests/examples/tests/npm-non-monorepo.t deleted file mode 100644 index f7aff1aa10461..0000000000000 --- a/turborepo-tests/examples/tests/npm-non-monorepo.t +++ /dev/null @@ -1,5 +0,0 @@ - $ . ${TESTDIR}/setup.sh non-monorepo npm -# run twice and make sure it works - $ npx turbo build lint > /dev/null 2>&1 - $ npx turbo build lint > /dev/null 2>&1 - $ git diff diff --git a/turborepo-tests/examples/tests/yarn-with-npm.t b/turborepo-tests/examples/tests/yarn-with-npm.t deleted file mode 100644 index ccaa44edde1c9..0000000000000 --- a/turborepo-tests/examples/tests/yarn-with-npm.t +++ /dev/null @@ -1,5 +0,0 @@ - $ . ${TESTDIR}/setup.sh with-npm yarn -# run twice and make sure it works - $ yarn build lint > /dev/null 2>&1 - $ yarn build lint > /dev/null 2>&1 - $ git diff diff --git a/turborepo-tests/examples/tests/yarn-with-yarn.t b/turborepo-tests/examples/tests/yarn-with-yarn.t deleted file mode 100644 index 5dc81aead1140..0000000000000 --- a/turborepo-tests/examples/tests/yarn-with-yarn.t +++ /dev/null @@ -1,5 +0,0 @@ - $ . ${TESTDIR}/setup.sh with-yarn yarn -# run twice and make sure it works - $ yarn turbo build lint > /dev/null 2>&1 - $ yarn turbo build lint > /dev/null 2>&1 - $ git diff diff --git a/turborepo-tests/examples/turbo.json b/turborepo-tests/examples/turbo.json deleted file mode 100644 index 3a4ed3341b43f..0000000000000 --- a/turborepo-tests/examples/turbo.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": ["//"], - "pipeline": { - // This is a synthetic tasks that lets us pull in other workspaces as dependencies - // So changes in internal workspaces that we depend on, will trigger this task. - "topo": { - "dependsOn": ["^topo"] - }, - "test": { - "dependsOn": ["topo"], - "outputs": [] - } - } -} diff --git a/turborepo-tests/helpers/setup_git.sh b/turborepo-tests/helpers/setup_git.sh index b38301162863c..2ca53d926e5a6 100755 --- a/turborepo-tests/helpers/setup_git.sh +++ b/turborepo-tests/helpers/setup_git.sh @@ -1,11 +1,19 @@ #!/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