Skip to content

Commit

Permalink
Merge branch 'main' into sokra/web-492-handle-if-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra authored Feb 2, 2023
2 parents 25d5d7a + 028d6f9 commit 4ce3efc
Show file tree
Hide file tree
Showing 38 changed files with 706 additions and 811 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,25 @@ jobs:
.github/actions/**
.github/workflows/test.yml
- name: Root cargo related changes
id: cargo
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
Cargo.*
rust-toolchain
- name: Rust related changes
id: rust
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
pnpm-lock.yaml
package.json
Cargo.**
crates/**
shim/**
xtask/**
Cargo.*
.cargo/**
rust-toolchain
!**.md
Expand All @@ -83,7 +91,6 @@ jobs:
package.json
crates/**
xtask/**
Cargo.*
.cargo/**
rust-toolchain
!crates/turborepo/**
Expand All @@ -102,7 +109,6 @@ jobs:
crates/turborepo/**
crates/turborepo-lib/**
crates/turbo-updater/**
Cargo.*
.cargo/**
rust-toolchain
!**.md
Expand Down Expand Up @@ -154,6 +160,8 @@ jobs:
outputs:
rust: ${{ steps.ci.outputs.diff != '' || steps.rust.outputs.diff != '' }}
# We only test workspace dependency changes on main, not on PRs to speed up CI
cargo_on_main: ${{ steps.ci.outputs.diff != '' || (steps.cargo.outputs.diff != '' && github.event_name == 'push' && github.ref == 'refs/heads/main') }}
turbopack: ${{ steps.ci.outputs.diff != '' || steps.turbopack.outputs.diff != '' }}
turborepo: ${{ steps.ci.outputs.diff != '' || steps.turborepo.outputs.diff != '' }}
rust_bench: ${{ steps.ci.outputs.diff != '' || steps.rust_bench.outputs.diff != '' }}
Expand Down Expand Up @@ -517,7 +525,8 @@ jobs:
turborepo_rust_test:
needs: [determine_jobs, rust_prepare]
if: needs.determine_jobs.outputs.turborepo == 'true'
# We test dependency changes only on main
if: needs.determine_jobs.outputs.turborepo == 'true' || needs.determine_jobs.outputs.cargo_on_main == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -556,7 +565,7 @@ jobs:
turbopack_rust_test:
needs: [determine_jobs, rust_prepare]
if: needs.determine_jobs.outputs.turbopack == 'true'
if: needs.determine_jobs.outputs.turbopack == 'true' || needs.determine_jobs.outputs.cargo_on_main == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -621,7 +630,7 @@ jobs:
turbopack_rust_test_bench:
needs: [determine_jobs, rust_prepare]
if: needs.determine_jobs.outputs.turbopack == 'true'
if: needs.determine_jobs.outputs.turbopack == 'true' || needs.determine_jobs.outputs.cargo_on_main == 'true'
strategy:
fail-fast: false
matrix:
Expand Down
109 changes: 109 additions & 0 deletions cli/integration_tests/task-dependencies/complex.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd) complex

# Workspace Graph:
# app-a -> lib-a
# \
# -> lib-b -> lib-d
# /
# app-b ->
# \ ->lib-c
# app-a depends on lib-a
# app-b depends on lib-b, lib-c
# lib-a depends on lib-b
# lib-b depends on lib-d

We can scope the run to specific packages
$ ${TURBO} run build1 --filter=app-b --graph

digraph {
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] ___ROOT___#build1" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-b#build1" -> "[root] lib-b#build1" (esc)
\t\t"[root] app-b#build1" -> "[root] lib-c#build1" (esc)
\t\t"[root] lib-b#build1" -> "[root] lib-d#build1" (esc)
\t\t"[root] lib-c#build1" -> "[root] ___ROOT___#build1" (esc)
\t\t"[root] lib-d#build1" -> "[root] ___ROOT___#build1" (esc)
\t} (esc)
}

Can't depend on unknown tasks
$ ${TURBO} run build2
ERROR run failed: error preparing engine: Could not find task "workspace-a#custom" in pipeline
Turbo error: error preparing engine: Could not find task "workspace-a#custom" in pipeline
[1]

Can't depend on tasks from unknown packages
$ ${TURBO} run build3
ERROR run failed: error preparing engine: Could not find task "unknown#custom" in pipeline
Turbo error: error preparing engine: Could not find task "unknown#custom" in pipeline
[1]


Complex dependency chain
$ ${TURBO} run test --graph

digraph {
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] ___ROOT___#build0" -> "[root] ___ROOT___#prepare" (esc)
\t\t"[root] ___ROOT___#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-a#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-a#test" -> "[root] app-a#prepare" (esc)
\t\t"[root] app-a#test" -> "[root] lib-a#build0" (esc)
\t\t"[root] app-b#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-b#test" -> "[root] app-b#prepare" (esc)
\t\t"[root] app-b#test" -> "[root] lib-b#build0" (esc)
\t\t"[root] app-b#test" -> "[root] lib-c#build0" (esc)
\t\t"[root] lib-a#build0" -> "[root] lib-a#prepare" (esc)
\t\t"[root] lib-a#build0" -> "[root] lib-b#build0" (esc)
\t\t"[root] lib-a#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-a#test" -> "[root] lib-a#prepare" (esc)
\t\t"[root] lib-a#test" -> "[root] lib-b#build0" (esc)
\t\t"[root] lib-b#build0" -> "[root] lib-b#prepare" (esc)
\t\t"[root] lib-b#build0" -> "[root] lib-d#build0" (esc)
\t\t"[root] lib-b#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-b#test" -> "[root] lib-b#prepare" (esc)
\t\t"[root] lib-b#test" -> "[root] lib-d#build0" (esc)
\t\t"[root] lib-c#build0" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-c#build0" -> "[root] lib-c#prepare" (esc)
\t\t"[root] lib-c#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-c#test" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-c#test" -> "[root] lib-c#prepare" (esc)
\t\t"[root] lib-d#build0" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-d#build0" -> "[root] lib-d#prepare" (esc)
\t\t"[root] lib-d#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-d#test" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-d#test" -> "[root] lib-d#prepare" (esc)
\t} (esc)
}


Check that --only only runs leaf tasks
$ ${TURBO} run test --only --graph

digraph {
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] app-a#test" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-b#test" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-a#test" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-b#test" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-c#test" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-d#test" -> "[root] ___ROOT___" (esc)
\t} (esc)
}

Can't depend on itself
$ ${TURBO} run build4
ERROR run failed: error preparing engine: Invalid task dependency graph:
.*#build4 depends on itself (re)
Turbo error: error preparing engine: Invalid task dependency graph:
.*#build4 depends on itself (re)
[1]
10 changes: 10 additions & 0 deletions cli/integration_tests/task-dependencies/complex/app-a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "app-a",
"scripts": {
"build": "echo 'build app-a'",
"test": "echo 'test app-a'"
},
"dependencies": {
"lib-a": "*"
}
}
11 changes: 11 additions & 0 deletions cli/integration_tests/task-dependencies/complex/app-b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "app-b",
"scripts": {
"build": "echo 'build app-b'",
"test": "echo 'test app-b'"
},
"dependencies": {
"lib-b": "*",
"lib-c": "*"
}
}
10 changes: 10 additions & 0 deletions cli/integration_tests/task-dependencies/complex/lib-a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "lib-a",
"scripts": {
"build": "echo 'build lib-a'",
"test": "echo 'test lib-a'"
},
"dependencies": {
"lib-b": "*"
}
}
10 changes: 10 additions & 0 deletions cli/integration_tests/task-dependencies/complex/lib-b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "lib-b",
"scripts": {
"build": "echo 'build lib-b'",
"test": "echo 'test lib-b'"
},
"dependencies": {
"lib-d": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "lib-c",
"scripts": {
"build": "echo 'build lib-c'"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lib-d",
"scripts": {
"build": "echo 'build lib-d'",
"test": "echo 'test lib-d'"
}
}
11 changes: 11 additions & 0 deletions cli/integration_tests/task-dependencies/complex/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "unknown-dependency",
"workspaces": [
"app-a",
"app-b",
"lib-a",
"lib-b",
"lib-c",
"lib-d"
]
}
30 changes: 30 additions & 0 deletions cli/integration_tests/task-dependencies/complex/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"pipeline": {
"build0": {
"dependsOn": ["^build0", "prepare"]
},
"test": {
"dependsOn": ["^build0", "prepare"]
},
"prepare": {},
"side-quest": {
"dependsOn": ["prepare"]
},

"build1": {
"dependsOn": ["^build1"]
},

"build2": {
"dependsOn": ["workspace-a#custom"]
},

"build3": {
"dependsOn": ["unknown#custom"]
},

"build4": {
"dependsOn": ["build4"]
}
}
}
41 changes: 41 additions & 0 deletions cli/integration_tests/task-dependencies/overwriting.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd) overwriting

Test
$ ${TURBO} run build > tmp.log
$ cat tmp.log | grep "Packages in scope" -A2
\xe2\x80\xa2 Packages in scope: workspace-a, workspace-b (esc)
\xe2\x80\xa2 Running build in 2 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

# workspace-a#generate ran
$ cat tmp.log | grep "workspace-a:generate"
workspace-a:generate: cache miss, executing 38a94e8f72e48200
workspace-a:generate:
workspace-a:generate: > generate
workspace-a:generate: > echo 'generate workspace-a'
workspace-a:generate:
workspace-a:generate: generate workspace-a
workspace-a#build ran
$ cat tmp.log | grep "workspace-a:build"
workspace-a:build: cache miss, executing cdf4f35b3e5ff342
workspace-a:build:
workspace-a:build: > build
workspace-a:build: > echo 'build workspace-a'
workspace-a:build:
workspace-a:build: build workspace-a

workspace-b#generate DID NOT run
$ cat tmp.log | grep "workspace-b:generate"
[1]

workspace-b#build ran
$ cat tmp.log | grep "workspace-b:build"
workspace-b:build: cache miss, executing 35d38d74bf7b33db
workspace-b:build:
workspace-b:build: > build
workspace-b:build: > echo 'build workspace-b'
workspace-b:build:
workspace-b:build: build workspace-b
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "overwriting",
"workspaces": [
"workspace-a",
"workspace-b"
]
}
11 changes: 11 additions & 0 deletions cli/integration_tests/task-dependencies/overwriting/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pipeline": {
"build": {
"dependsOn": ["generate"]
},
"generate": {},
"workspace-b#build": {
"dependsOn": []
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "workspace-a",
"scripts": {
"build": "echo 'build workspace-a'",
"generate": "echo 'generate workspace-a'"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "workspace-b",
"scripts": {
"build": "echo 'build workspace-b'",
"generate": "echo 'generate workspace-b'"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
TARGET_DIR=$1
cp -a ${SCRIPT_DIR}/monorepo/. ${TARGET_DIR}/
MONOREPO_DIR=$2
cp -a ${SCRIPT_DIR}/${MONOREPO_DIR}/. ${TARGET_DIR}/
${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}
Loading

0 comments on commit 4ce3efc

Please sign in to comment.