Skip to content

Commit afb164d

Browse files
authored
fat: rename all batch strategy as single (#347)
1 parent 848a941 commit afb164d

31 files changed

+173
-193
lines changed

src/Terrabuild.Configuration.Tests/TestFiles/Success_WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target dist {
1919
depends_on = [ target.build ]
2020
build = ~auto
2121
artifacts = ~none
22-
batch = ~all
22+
batch = ~single
2323
}
2424

2525
target dummy { }

src/Terrabuild.Configuration.Tests/Workspace.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let parseWorkspace() =
2121
{ TargetBlock.DependsOn = Set [ "build" ] |> Some
2222
TargetBlock.Build = "auto" |> Expr.Enum |> Some
2323
TargetBlock.Cache = "none" |> Expr.Enum |> Some
24-
TargetBlock.Batch = "all" |> Expr.Enum |> Some
24+
TargetBlock.Batch = "single" |> Expr.Enum |> Some
2525
TargetBlock.Outputs = None }
2626
let targetDummy =
2727
{ TargetBlock.DependsOn = None

src/Terrabuild.Tests/Core/GraphPipeline/Batch.fs

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,42 @@ open NUnit.Framework
44
open GraphDef
55
open GraphPipeline.Batch
66

7+
let buildNode id clusterHash action deps group req =
8+
{ Node.Id = id
9+
Node.ProjectId = id
10+
Node.ProjectName = None
11+
Node.ProjectDir = $"/src/project{id}"
12+
Node.Target = "build"
13+
Node.Dependencies = deps
14+
Node.Outputs = Set.empty
15+
Node.ProjectHash = ""
16+
Node.TargetHash = ""
17+
Node.ClusterHash = clusterHash
18+
Node.Operations = []
19+
Node.Artifacts = ArtifactMode.Workspace
20+
Node.Action = action
21+
Node.Build = BuildMode.Auto
22+
Node.Batch = group
23+
Node.Required = req }
24+
25+
let addNode (node: Node) nodes = nodes |> Map.add node.Id node
26+
727
[<Test>]
828
let ``check partition computation``() =
9-
let buildNode id clusterHash action deps =
10-
{ Node.Id = id
11-
Node.ProjectId = id
12-
Node.ProjectName = None
13-
Node.ProjectDir = $"/src/project{id}"
14-
Node.Target = "build"
15-
Node.Dependencies = deps
16-
Node.Outputs = Set.empty
17-
Node.ProjectHash = ""
18-
Node.TargetHash = ""
19-
Node.ClusterHash = clusterHash
20-
Node.Operations = []
21-
Node.Artifacts = ArtifactMode.Workspace
22-
Node.Action = action
23-
Node.Build = BuildMode.Auto
24-
Node.Batch = BatchMode.Partition
25-
Node.Required = true }
26-
27-
let addNode (node: Node) nodes = nodes |> Map.add node.Id node
28-
2929
// Bucket hash-A: connected via A1 -> A2 (in-bucket edge)
30-
let nodeA1 = buildNode "A1" (Some "hash-A") RunAction.Exec (Set ["A2"; "B1"])
31-
let nodeA2 = buildNode "A2" (Some "hash-A") RunAction.Restore Set.empty
30+
let nodeA1 = buildNode "A1" (Some "hash-A") RunAction.Exec (Set ["A2"; "B1"]) BatchMode.Partition true
31+
let nodeA2 = buildNode "A2" (Some "hash-A") RunAction.Restore Set.empty BatchMode.Partition true
3232

3333
// Bucket hash-B: connected via B1 -> B2 (in-bucket edge)
34-
let nodeB1 = buildNode "B1" (Some "hash-B") RunAction.Exec (Set ["B2"])
35-
let nodeB2 = buildNode "B2" (Some "hash-B") RunAction.Exec Set.empty
34+
let nodeB1 = buildNode "B1" (Some "hash-B") RunAction.Exec (Set ["B2"]) BatchMode.Partition true
35+
let nodeB2 = buildNode "B2" (Some "hash-B") RunAction.Exec Set.empty BatchMode.Partition true
3636

3737
// Bucket hash-C: connected but inactive (no Build) => no batch
38-
let nodeC1 = buildNode "C1" (Some "hash-C") RunAction.Restore (Set ["C2"])
39-
let nodeC2 = buildNode "C2" (Some "hash-C") RunAction.Restore Set.empty
38+
let nodeC1 = buildNode "C1" (Some "hash-C") RunAction.Restore (Set ["C2"]) BatchMode.Partition true
39+
let nodeC2 = buildNode "C2" (Some "hash-C") RunAction.Restore Set.empty BatchMode.Partition true
4040

4141
// Not batchable
42-
let nodeD1 = buildNode "D1" None RunAction.Exec Set.empty
42+
let nodeD1 = buildNode "D1" None RunAction.Exec Set.empty BatchMode.Partition true
4343

4444
let nodes =
4545
Map.empty
@@ -78,38 +78,18 @@ let ``check partition computation``() =
7878

7979
[<Test>]
8080
let ``check partition/all computation``() =
81-
let buildNode id clusterHash action deps group =
82-
{ Node.Id = id
83-
Node.ProjectId = id
84-
Node.ProjectName = None
85-
Node.ProjectDir = $"/src/project{id}"
86-
Node.Target = "build"
87-
Node.Dependencies = deps
88-
Node.Outputs = Set.empty
89-
Node.ProjectHash = ""
90-
Node.TargetHash = ""
91-
Node.ClusterHash = clusterHash
92-
Node.Operations = []
93-
Node.Artifacts = ArtifactMode.Workspace
94-
Node.Action = action
95-
Node.Build = BuildMode.Auto
96-
Node.Batch = group
97-
Node.Required = true }
98-
99-
let addNode (node: Node) nodes = nodes |> Map.add node.Id node
100-
10181
// Bucket hash-A: connected via A1 -> A2 (in-bucket edge)
102-
let nodeA1 = buildNode "A1" (Some "hash-A") RunAction.Restore (Set ["A2"; "B1"]) BatchMode.Partition
103-
let nodeA2 = buildNode "A2" (Some "hash-A") RunAction.Restore Set.empty BatchMode.Partition
82+
let nodeA1 = buildNode "A1" (Some "hash-A") RunAction.Restore (Set ["A2"; "B1"]) BatchMode.Partition true
83+
let nodeA2 = buildNode "A2" (Some "hash-A") RunAction.Restore Set.empty BatchMode.Partition true
10484

10585
// Bucket hash-B: connected via B1 -> B2 (in-bucket edge)
106-
let nodeB1 = buildNode "B1" (Some "hash-B") RunAction.Exec (Set ["B2"]) BatchMode.All
107-
let nodeB2 = buildNode "B2" (Some "hash-B") RunAction.Exec Set.empty BatchMode.All
108-
let nodeC1 = buildNode "C1" (Some "hash-B") RunAction.Exec (Set ["C2"]) BatchMode.All
109-
let nodeC2 = buildNode "C2" (Some "hash-B") RunAction.Exec Set.empty BatchMode.All
86+
let nodeB1 = buildNode "B1" (Some "hash-B") RunAction.Exec (Set ["B2"]) BatchMode.Single true
87+
let nodeB2 = buildNode "B2" (Some "hash-B") RunAction.Exec Set.empty BatchMode.Single true
88+
let nodeC1 = buildNode "C1" (Some "hash-B") RunAction.Exec (Set ["C2"]) BatchMode.Single true
89+
let nodeC2 = buildNode "C2" (Some "hash-B") RunAction.Exec Set.empty BatchMode.Single true
11090

11191
// Not batchable
112-
let nodeD1 = buildNode "D1" None RunAction.Exec Set.empty BatchMode.Partition
92+
let nodeD1 = buildNode "D1" None RunAction.Exec Set.empty BatchMode.Partition true
11393

11494
let nodes =
11595
Map.empty

src/Terrabuild/Core/Configuration.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,10 @@ let private finalizeProject workspaceDir projectDir evaluationContext (projectDe
639639
match group with
640640
| Ok "never" -> BatchMode.Never
641641
| Ok "partition" -> BatchMode.Partition
642-
| Ok "all" -> BatchMode.All
642+
| Ok "single" -> BatchMode.Single
643643
| Ok x -> raiseParseError $"Invalid group value '{x}'"
644644
| Error error -> raiseParseError error
645-
| _ -> BatchMode.All
645+
| _ -> BatchMode.Single
646646

647647
let target =
648648
{ Target.Hash = targetHash

src/Terrabuild/Core/GraphDef.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type ContaineredShellOperation = {
1818
type BatchMode =
1919
| Never
2020
| Partition
21-
| All
21+
| Single
2222

2323
[<RequireQualifiedAccess>]
2424
type ArtifactMode =

src/Terrabuild/Core/GraphPipeline/Batch.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ let computeBatches (graph: Graph) =
100100
|> Map.ofSeq
101101

102102
let partitionGroups = batchModes |> Map.tryFind BatchMode.Partition |> Option.defaultValue []
103-
let allGroup = batchModes |> Map.tryFind BatchMode.All |> Option.defaultValue []
103+
let allGroup = batchModes |> Map.tryFind BatchMode.Single |> Option.defaultValue []
104104

105105
partitionGroups
106106
|> partitionByDependencies

tests/basic/results/terrabuild-debug.action.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"artifacts": "none",
2626
"build": "always",
27-
"batch": "all",
27+
"batch": "single",
2828
"action": "exec",
2929
"required": true
3030
}

tests/basic/results/terrabuild-debug.batch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"artifacts": "none",
2626
"build": "always",
27-
"batch": "all",
27+
"batch": "single",
2828
"action": "exec",
2929
"required": true
3030
}

tests/basic/results/terrabuild-debug.cascade.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"artifacts": "none",
2626
"build": "always",
27-
"batch": "all",
27+
"batch": "single",
2828
"action": "exec",
2929
"required": true
3030
}

tests/basic/results/terrabuild-debug.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"targets": {
3636
"build": {
3737
"hash": "8B56DAA76BB451252D58A9AFF5D2E5A77D0568D8681204549E53A422C9FBDBF0",
38-
"batch": "all",
38+
"batch": "single",
3939
"dependsOn": [
4040
"^build"
4141
],

0 commit comments

Comments
 (0)