Skip to content

Commit bec0504

Browse files
ci: split examples tests (#9729)
### Description Currently, our examples testing loop is too slow. Changing just one of the examples causes all of them to miss cache. This PR instead runs tests only for changed examples. This is going to end up being an even larger improvement given that I've additionally set up a test for each package manager for each core-maintained example, effectively tripling the amount of testing needed. ### Notes This probably isn't the most elegant way to write this - but it was the easiest to understand. GitHub Actions is just...really hard to work with and my patience has run out. Maybe I'll clean this up later, or maybe some kind soul will review me and give me a quick way to DRY it up. - The additions in `.github/workflows` are all duplicates of each other, but one for each example. - The additions in `turborepo-tests/example-*` are creating tests for all of our supported package managers where we used to only test one package manager per example. ### Testing Instructions CI --------- Co-authored-by: Chris Olszewski <[email protected]>
1 parent 5a5acff commit bec0504

File tree

51 files changed

+8780
-5919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+8780
-5919
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Run Turbo Tests"
2+
description: "Setup the environment and run Turbo tests"
3+
inputs:
4+
github-token:
5+
description: "GitHub token for GitHub"
6+
required: true
7+
turbo-token:
8+
description: "Turbo token for authentication"
9+
required: true
10+
turbo-team:
11+
description: "Turbo team for authentication"
12+
required: true
13+
test-filter:
14+
description: "Filter for the turbo run command"
15+
required: true
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Disable corepack
20+
shell: bash
21+
run: corepack disable
22+
23+
- name: Setup Turborepo Environment
24+
uses: ./.github/actions/setup-turborepo-environment
25+
with:
26+
github-token: "${{ inputs.github-token }}"
27+
node-version: "22"
28+
29+
- name: Install Global Turbo
30+
uses: ./.github/actions/install-global-turbo
31+
32+
- name: Run Turbo Tests
33+
shell: bash
34+
run: |
35+
turbo run test \
36+
--filter="${{ inputs.test-filter }}" \
37+
--continue \
38+
--token=${{ inputs.turbo-token }} \
39+
--team=${{ inputs.turbo-team }} \
40+
--env-mode=strict \
41+
--concurrency=1
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Examples tests - basic
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
paths:
7+
- examples/basic/**
8+
- turborepo-tests/example-basic-*/**
9+
- turborepo-tests/helpers/**
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
basic-example:
17+
name: basic
18+
timeout-minutes: 40
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: "Run `basic` example tests"
25+
uses: ./.github/actions/examples-tests
26+
with:
27+
node-version: "22"
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
turbo-token: "${{ secrets.TURBO_TOKEN }}"
30+
turbo-team: "${{ vars.TURBO_TEAM }}"
31+
test-filter: "@turborepo-examples-tests/kitchen-sink-*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Example tests - kitchen-sink
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
paths:
7+
- examples/kitchen-sink/**
8+
- turborepo-tests/example-kitchen-sink-*/**
9+
- turborepo-tests/helpers/**
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
kitchen-sink:
17+
name: kitchen-sink
18+
timeout-minutes: 40
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: "Run `kitchen-sink` example tests"
25+
uses: ./.github/actions/examples-tests
26+
with:
27+
node-version: "22"
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
turbo-token: "${{ secrets.TURBO_TOKEN }}"
30+
turbo-team: "${{ vars.TURBO_TEAM }}"
31+
test-filter: "@turborepo-examples-tests/kitchen-sink-*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Example tests - non-monorepo
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
paths:
7+
- examples/non-monorepo/**
8+
- turborepo-tests/example-non-monorepo-*/**
9+
- turborepo-tests/helpers/**
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
non-monorepo-example:
17+
name: non-monorepo
18+
timeout-minutes: 40
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: "Run `non-monorepo` example tests"
25+
uses: ./.github/actions/examples-tests
26+
with:
27+
node-version: "22"
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
turbo-token: "${{ secrets.TURBO_TOKEN }}"
30+
turbo-team: "${{ vars.TURBO_TEAM }}"
31+
test-filter: "@turborepo-examples-tests/non-monorepo-*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Example tests - with-svelte
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
paths:
7+
- examples/with-svelte/**
8+
- turborepo-tests/example-with-svelte-*/**
9+
- turborepo-tests/helpers/**
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
with-svelte-example:
17+
name: with-svelte
18+
timeout-minutes: 40
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: "Run `with-svelte` example tests"
25+
uses: ./.github/actions/examples-tests
26+
with:
27+
node-version: "22"
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
turbo-token: "${{ secrets.TURBO_TOKEN }}"
30+
turbo-team: "${{ vars.TURBO_TEAM }}"
31+
test-filter: "@turborepo-examples-tests/with-svelte-*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Examples tests - with-tailwind
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
paths:
7+
- examples/with-tailwind/**
8+
- turborepo-tests/example-with-tailwind-*/**
9+
- turborepo-tests/helpers/**
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
with-tailwind-example:
17+
name: with-tailwind
18+
timeout-minutes: 40
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: "Run `with-tailwind` example tests"
25+
uses: ./.github/actions/examples-tests
26+
with:
27+
node-version: "22"
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
turbo-token: "${{ secrets.TURBO_TOKEN }}"
30+
turbo-team: "${{ vars.TURBO_TEAM }}"
31+
test-filter: "@turborepo-examples-tests/with-tailwind-*"

.github/workflows/turborepo-test.yml

-40
Original file line numberDiff line numberDiff line change
@@ -80,44 +80,6 @@ jobs:
8080
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
8181
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8282

83-
examples:
84-
name: Turborepo Examples
85-
timeout-minutes: 40
86-
87-
runs-on: ubuntu-latest
88-
steps:
89-
- name: Checkout
90-
uses: actions/checkout@v4
91-
92-
# Disable corepack. actions/setup-node invokes other package managers and
93-
# that causes corepack to throw an error, so we disable it first.
94-
- name: Disable corepack
95-
shell: bash
96-
run: corepack disable
97-
98-
- name: Setup Turborepo Environment
99-
uses: ./.github/actions/setup-turborepo-environment
100-
with:
101-
github-token: "${{ secrets.GITHUB_TOKEN }}"
102-
node-version: "18.20.2"
103-
104-
- name: Install Global Turbo
105-
uses: ./.github/actions/install-global-turbo
106-
107-
- name: Check examples
108-
shell: bash
109-
# Concurrency being 1 is a big hammer here.
110-
# It's a quick fix for non-deterministic behaviors we're seeing around package resolution.
111-
# We could likely do some hacking to reparallelize this, but it's not worth it right now.
112-
run: turbo run test --filter="@turborepo-examples-tests/*" --continue --token=${{ secrets.TURBO_TOKEN }} --team=${{ vars.TURBO_TEAM }} --env-mode=strict --concurrency=1
113-
114-
# Disable corepack again. actions/setup-node's "Post" step runs at the end of
115-
# this job invokes other package managers, and corepack throws an error.
116-
# (corepack was enabled from inside the tests above).
117-
- name: Disable corepack again
118-
shell: bash
119-
run: corepack disable
120-
12183
rust_lint:
12284
name: Rust lints
12385
runs-on:
@@ -239,7 +201,6 @@ jobs:
239201
if: always()
240202
needs:
241203
- integration
242-
- examples
243204
- rust_lint
244205
- rust_check
245206
- rust_test
@@ -261,7 +222,6 @@ jobs:
261222
}
262223
263224
subjob ${{needs.integration.result}}
264-
subjob ${{needs.examples.result}}
265225
subjob ${{needs.rust_lint.result}}
266226
subjob ${{needs.rust_check.result}}
267227
subjob ${{needs.rust_test.result}}

examples/kitchen-sink/apps/blog/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "blog",
3+
"version": "0.0.0",
34
"private": true,
45
"sideEffects": false,
56
"type": "module",

examples/kitchen-sink/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "kitchen-sink",
23
"private": true,
34
"scripts": {
45
"build": "turbo run build",
@@ -16,6 +17,5 @@
1617
"packageManager": "[email protected]",
1718
"engines": {
1819
"node": ">=18"
19-
},
20-
"name": "kitchen-sink"
20+
}
2121
}

examples/kitchen-sink/packages/logger/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@repo/jest-presets": "workspace:*",
2424
"@repo/typescript-config": "workspace:*",
2525
"@types/node": "^20.11.24",
26+
"eslint": "^8.38.0",
2627
"jest": "^29.7.0",
2728
"tsup": "^8.0.2",
2829
"typescript": "5.5.4"

0 commit comments

Comments
 (0)