Skip to content

Commit

Permalink
ci(examples): update examples tests to diff full output (#5242)
Browse files Browse the repository at this point in the history
This will help debug examples tests when they fail.

- Switch env vars to CLI flags so they don't leak through
  to the turbo invocations in the actual test and change the output that
  we are not asserting against.
- Enable corepack inside the test and then disable it again at the ened
  of the test.
  • Loading branch information
mehulkar committed Jun 8, 2023
1 parent f2d4cd2 commit 6e60a03
Show file tree
Hide file tree
Showing 13 changed files with 314 additions and 28 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ jobs:
run: |
mkdir -p `pnpm store path`
# Disable corepack, actions/setup-node invokes other package managers and
# that causes corepack to throw an error, so we disable it first.
- name: Disable corepack
shell: bash
run: corepack disable
Expand All @@ -404,12 +406,17 @@ jobs:

- name: Check \"${{ matrix.example }}\" example with \"${{ matrix.manager }}\"
shell: bash
env:
FORCE_COLOR: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
run: turbo run test --filter="turborepo-tests-examples" -- "${{ matrix.example }}" "${{ matrix.manager }}"
# Note: using CLI flags instead of env vars because
# envs var would apply to the actual tests that exercise turbo also,
# making test output non-deterministic.
run: turbo run test --color --remote-only --token=${{ secrets.TURBO_TOKEN }} --team=${{ vars.TURBO_TEAM }} --filter="turborepo-tests-examples" -- "${{ matrix.example }}" "${{ matrix.manager }}"

# Re-enable corepack, actions/setup-node invokes other package managers and
# that causes corepack to throw an error, so we disable it here. The "Post" step
# for actions/setup-node will run at the end of this job, so we need to prep for it.
- name: Disable corepack again
shell: bash
run: corepack disable

js_packages:
name: JS Package Tests
Expand Down
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" --keep-tmpdir
.cram_env/bin/prysk --shell="$(which bash)" "$TEST_FILE"
else
echo "Could not find $TEST_FILE"
exit 1
Expand Down
22 changes: 20 additions & 2 deletions turborepo-tests/examples/tests/npm-non-monorepo.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
$ . ${TESTDIR}/setup.sh non-monorepo npm
\d+\.\d+\.\d+ (re)

# run twice and make sure it works
$ npx turbo build lint > /dev/null 2>&1
$ npx turbo build lint > /dev/null 2>&1
$ npx turbo build lint --output-logs=none
\xe2\x80\xa2 Running build, lint (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 2 successful, 2 total
Cached: 0 cached, 2 total
Time:\s*[\.0-9ms]+ (re)


$ npx turbo build lint --output-logs=none
\xe2\x80\xa2 Running build, lint (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 2 successful, 2 total
Cached: 2 cached, 2 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)


$ git diff
36 changes: 34 additions & 2 deletions turborepo-tests/examples/tests/npm-with-npm.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
$ . ${TESTDIR}/setup.sh with-npm npm
\d+\.\d+\.\d+ (re)

# run twice and make sure it works
$ npm run build lint > /dev/null 2>&1
$ npm run build lint > /dev/null 2>&1
$ npm run build lint -- --output-logs=none

\> build (re)
\> turbo run build lint --output-logs=none (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)




$ npm run build lint -- --output-logs=none

\> build (re)
\> turbo run build lint --output-logs=none (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 5 cached, 5 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)




$ git diff
36 changes: 34 additions & 2 deletions turborepo-tests/examples/tests/npm-with-yarn.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
$ . ${TESTDIR}/setup.sh with-yarn npm
\d+\.\d+\.\d+ (re)

# run twice and make sure it works
$ npm run build lint > /dev/null 2>&1
$ npm run build lint > /dev/null 2>&1
$ npm run build lint -- --output-logs=none

\> build (re)
\> turbo build lint --output-logs=none (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)




$ npm run build lint -- --output-logs=none

\> build (re)
\> turbo build lint --output-logs=none (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 5 cached, 5 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)




$ git diff
35 changes: 33 additions & 2 deletions turborepo-tests/examples/tests/pnpm-basic.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
$ . ${TESTDIR}/setup.sh basic pnpm
6.26.1
# run twice and make sure it works
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-basic.t (re)
\> turbo run build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)




$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-basic.t (re)
\> turbo run build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 5 cached, 5 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)




$ git diff
31 changes: 28 additions & 3 deletions turborepo-tests/examples/tests/pnpm-gatsby.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
$ . ${TESTDIR}/setup.sh with-gatsby pnpm
6.26.1
# run twice and make sure it works
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint > /dev/null 2>&1
$ git diff
$ pnpm run build lint -- --output-logs=none

\> with-gatsby@0.0.0 build (.*)/pnpm-gatsby.t (re)
\> turbo build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)


$ pnpm run build lint -- --output-logs=none

\> with-gatsby@0.0.0 build (.*)/pnpm-gatsby.t (re)
\> turbo build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 3 cached, 5 total
Time:\s*[\.0-9ms]+ (re)

35 changes: 33 additions & 2 deletions turborepo-tests/examples/tests/pnpm-kitchen-sink.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
$ . ${TESTDIR}/setup.sh kitchen-sink pnpm
6.26.1
# run twice and make sure it works
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-kitchen-sink.t (re)
\> turbo build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: admin, api, blog, eslint-config-custom, eslint-config-custom-server, jest-presets, logger, storefront, tsconfig, ui (esc)
\xe2\x80\xa2 Running build, lint in 10 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 11 successful, 11 total
Cached: 0 cached, 11 total
Time:\s*[\.0-9ms]+ (re)




$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-kitchen-sink.t (re)
\> turbo build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: admin, api, blog, eslint-config-custom, eslint-config-custom-server, jest-presets, logger, storefront, tsconfig, ui (esc)
\xe2\x80\xa2 Running build, lint in 10 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 11 successful, 11 total
Cached: 11 cached, 11 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)




$ git diff
35 changes: 33 additions & 2 deletions turborepo-tests/examples/tests/pnpm-with-svelte.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
$ . ${TESTDIR}/setup.sh with-svelte pnpm
6.26.1
# run twice and make sure it works
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint > /dev/null 2>&1
$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-with-svelte.t (re)
\> turbo run build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 4 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)




$ pnpm run build lint -- --output-logs=none

\> @ build (.*)/pnpm-with-svelte.t (re)
\> turbo run build "lint" "--output-logs=none" (re)

\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 4 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 5 cached, 5 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)




$ git diff
6 changes: 6 additions & 0 deletions turborepo-tests/examples/tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ function set_package_manager() {
cat package.json | jq ".packageManager=\"$1\"" | sponge package.json
}

# Enable corepack so that when we set the packageManager in package.json it actually makes a diference.
corepack enable

# Set the packageManger version
NPM_PACKAGE_MANAGER_VALUE="npm@8.1.2"
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 --version
npm install > /dev/null
elif [ "$pkgManager" == "pnpm" ]; then
set_package_manager "$PNPM_PACKAGE_MANAGER_VALUE"
pnpm --version
pnpm install > /dev/null
elif [ "$pkgManager" == "yarn" ]; then
set_package_manager "$YARN_PACKAGE_MANAGER_VALUE"
yarn --version
yarn install > /dev/null
fi

Expand Down
27 changes: 25 additions & 2 deletions turborepo-tests/examples/tests/yarn-non-monorepo.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
$ . ${TESTDIR}/setup.sh non-monorepo yarn
\d+\.\d+\.\d+ (re)

# run twice and make sure it works
$ npx turbo build lint > /dev/null 2>&1
$ npx turbo build lint > /dev/null 2>&1
$ yarn turbo build lint --output-logs=none
yarn run v\d+\.\d+\.\d+ (re)
\$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re)
\xe2\x80\xa2 Running build, lint (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 2 successful, 2 total
Cached: 0 cached, 2 total
Time:\s*[\.0-9ms]+ (re)

Done in [\.0-9]+m?s\. (re)

$ yarn turbo build lint --output-logs=none
yarn run v\d+\.\d+\.\d+ (re)
\$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re)
\xe2\x80\xa2 Running build, lint (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 2 successful, 2 total
Cached: 2 cached, 2 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)

Done in [\.0-9]+m?s\. (re)
$ git diff
29 changes: 27 additions & 2 deletions turborepo-tests/examples/tests/yarn-with-npm.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
$ . ${TESTDIR}/setup.sh with-npm yarn
\d+\.\d+\.\d+ (re)

# run twice and make sure it works
$ yarn build lint > /dev/null 2>&1
$ yarn build lint > /dev/null 2>&1
$ yarn turbo build lint --output-logs=none
yarn run v\d+\.\d+\.\d+ (re)
\$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re)
\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time:\s*[\.0-9ms]+ (re)

Done in [\.0-9]+m?s\. (re)

$ yarn turbo build lint --output-logs=none
yarn run v\d+\.\d+\.\d+ (re)
\$ (.*)node_modules/.bin/turbo build lint --output-logs=none (re)
\xe2\x80\xa2 Packages in scope: docs, eslint-config-custom, tsconfig, ui, web (esc)
\xe2\x80\xa2 Running build, lint in 5 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 5 successful, 5 total
Cached: 5 cached, 5 total
Time:\s*[\.0-9ms]+ >>> FULL TURBO (re)

Done in [\.0-9]+m?s\. (re)
$ git diff
Loading

0 comments on commit 6e60a03

Please sign in to comment.