Skip to content

Commit

Permalink
ci: make every examples test a workspace
Browse files Browse the repository at this point in the history
This setup will allow turbo to parallelize and cache execution of these
tests. It also reduces the number of Github Workflow runs that are
triggered when an example changes, greatly reducing the amount of
computing power required to run the tests.

This commit does not change the fact that all examples tests are run
when any of the examples change. We may be able to wire up dependencies
more carefully in the future, but this is not feasible at the moment
because each example itself is not a workspace.
  • Loading branch information
mehulkar committed May 17, 2023
1 parent 0cfc760 commit 5fb11bc
Show file tree
Hide file tree
Showing 43 changed files with 590 additions and 154 deletions.
56 changes: 10 additions & 46 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:
with:
PATTERNS: |
examples/**
turborepo-tests/examples/**
examples-tests/**
!**.md
!**.mdx
Expand Down Expand Up @@ -298,8 +298,8 @@ jobs:
- name: E2E Tests
run: turbo run test --filter=turborepo-tests-e2e

go_examples:
name: Go Cli Examples
turborepo_examples:
name: Turborepo Examples
needs: determine_jobs
if: needs.determine_jobs.outputs.examples == 'true'
timeout-minutes: 30
Expand All @@ -312,43 +312,9 @@ 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
# Used by examples-tests/setup.sh
- name: Install Sponge
shell: bash
run: |
Expand All @@ -364,22 +330,20 @@ jobs:
- name: "Setup Node"
uses: ./.github/actions/setup-node
with:
enable-corepack: "false"
package-install: "false"
enable-pnpm-cache: "true"

- name: Install Turbo globally
shell: bash
run: npm i -g turbo@canary

- name: Check \"${{ matrix.example }}\" example with \"${{ matrix.manager }}\"
- name: Check examples
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 }}"
run: turbo run example-test --filter="@turborepo-examples-tests/*" --continue

js_packages:
name: JS Package Tests
Expand Down Expand Up @@ -1149,7 +1113,7 @@ jobs:
- determine_jobs
- go_lint
- go_unit
- go_examples
- turborepo_examples
- go_e2e
- go_integration
- js_packages
Expand Down Expand Up @@ -1186,7 +1150,7 @@ jobs:
subjob ${{needs.determine_jobs.result}} "Determining jobs"
subjob ${{needs.go_lint.result}} "Go lints"
subjob ${{needs.go_unit.result}} "Go unit tests"
subjob ${{needs.go_examples.result}} "Go examples"
subjob ${{needs.turborepo_examples.result}} "Turborepo examples"
subjob ${{needs.go_e2e.result}} "Go e2e tests"
subjob ${{needs.go_integration.result}} "Go integration tests"
subjob ${{needs.js_packages.result}} "JS Package tests"
Expand Down Expand Up @@ -1264,7 +1228,7 @@ jobs:
- determine_jobs
- go_lint
- go_unit
- go_examples
- turborepo_examples
- go_e2e
- go_integration
- rust_prepare
Expand Down Expand Up @@ -1304,7 +1268,7 @@ jobs:
subjob ${{needs.determine_jobs.result}} "Determining jobs"
subjob ${{needs.go_lint.result}} "Go lints"
subjob ${{needs.go_unit.result}} "Go unit tests"
subjob ${{needs.go_examples.result}} "Go examples"
subjob ${{needs.turborepo_examples.result}} "Turborepo examples"
subjob ${{needs.go_e2e.result}} "Go e2e tests"
subjob ${{needs.go_integration.result}} "Go integration tests"
subjob ${{needs.rust_prepare.result}} "Rust prepare"
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions examples-tests/helpers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@turborepo-examples-tests/helpers",
"scripts": {
"setup": "./setup_prysk.sh"
}
}
14 changes: 14 additions & 0 deletions examples-tests/helpers/setup_prysk.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions examples-tests/helpers/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["//"],
"pipeline": {
"setup": {
"cache": false
},
"topo": {}
}
}
11 changes: 11 additions & 0 deletions examples-tests/npm-non-monorepo/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
20 changes: 20 additions & 0 deletions examples-tests/npm-non-monorepo/test.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ . ${TESTDIR}/../setup.sh non-monorepo npm
8\.\d+\.\d (re)
# run twice and make sure it works
$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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)

$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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
11 changes: 11 additions & 0 deletions examples-tests/npm-with-npm/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
30 changes: 30 additions & 0 deletions examples-tests/npm-with-npm/test.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ . ${TESTDIR}/../setup.sh with-npm npm
8\.\d+\.\d (re)
# run twice and make sure it works
$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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)

$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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
11 changes: 11 additions & 0 deletions examples-tests/npm-with-yarn/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
30 changes: 30 additions & 0 deletions examples-tests/npm-with-yarn/test.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ . ${TESTDIR}/../setup.sh with-yarn npm
8\.\d+\.\d (re)
# run twice and make sure it works
$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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)

$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false 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
11 changes: 11 additions & 0 deletions examples-tests/pnpm-basic/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
30 changes: 30 additions & 0 deletions examples-tests/pnpm-basic/test.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ . ${TESTDIR}/../setup.sh basic pnpm
6.26.1
# run twice and make sure it works
$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false pnpm run build lint -- --output-logs=none

\> @ build (.*)/test.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)

$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false pnpm run build lint -- --output-logs=none

\> @ build (.*)/test.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
11 changes: 11 additions & 0 deletions examples-tests/pnpm-gatsby/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
30 changes: 30 additions & 0 deletions examples-tests/pnpm-gatsby/test.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ . ${TESTDIR}/../setup.sh with-gatsby pnpm
6.26.1
# run twice and make sure it works
$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false pnpm run build lint -- --output-logs=none

\> with-gatsby@0.0.0 build (.*)/test.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)

$ TURBO_TEAM="" TURBO_REMOTE_ONLY=false pnpm run build lint -- --output-logs=none

\> with-gatsby@0.0.0 build (.*)/test.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)

$ git diff
11 changes: 11 additions & 0 deletions examples-tests/pnpm-kitchen-sink/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
Loading

0 comments on commit 5fb11bc

Please sign in to comment.