Skip to content

Commit a219956

Browse files
committed
Merge remote-tracking branch 'origin/main' into test-improvements
2 parents 96ba0a9 + d108eea commit a219956

File tree

8 files changed

+54
-10
lines changed

8 files changed

+54
-10
lines changed

.execs/test.flow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@ executables:
4545
name: unit
4646
description: Run unit tests with coverage
4747
serial:
48+
dir: //
4849
execs:
4950
- cmd: |
5051
pwd
5152
ls
5253
echo "Running Go unit tests with coverage..."
5354
go test -race -coverprofile=unit-coverage.out -covermode=atomic -tags=unit ./...
5455
echo "Unit tests completed"
55-
dir: //
5656
retries: 3
5757

5858

5959
- verb: test
6060
name: e2e
6161
description: Run E2E tests with instrumented binary and coverage
6262
serial:
63+
dir: //
6364
execs:
6465
- cmd: |
6566
pwd
6667
ls
6768
echo "Running Go E2E tests..."
6869
go test -race -coverprofile=unit-coverage.out -covermode=atomic -coverpkg=./... -tags=e2e ./tests/...
6970
echo "E2E tests completed"
70-
dir: //
7171
retries: 1
7272

7373
- verb: test

.execs/validate.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ executables:
3636
tags: [go]
3737
description: Run linters and formatters
3838
parallel:
39+
dir: //
3940
execs:
4041
- cmd: go fmt ./...
4142
dir: //
@@ -49,7 +50,6 @@ executables:
4950
fi
5051

5152
golangci-lint run ./... --fix --output.sarif.path lint.sarif
52-
dir: //
5353

5454
- verb: lint
5555
name: ts

docs/schemas/flowfile_schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
"args": {
213213
"$ref": "#/definitions/ExecutableArgumentList"
214214
},
215+
"dir": {
216+
"$ref": "#/definitions/ExecutableDirectory",
217+
"default": ""
218+
},
215219
"execs": {
216220
"$ref": "#/definitions/ExecutableParallelRefConfigList",
217221
"description": "A list of executables to run in parallel.\nEach executable can be a command or a reference to another executable.\n"
@@ -450,6 +454,10 @@
450454
"args": {
451455
"$ref": "#/definitions/ExecutableArgumentList"
452456
},
457+
"dir": {
458+
"$ref": "#/definitions/ExecutableDirectory",
459+
"default": ""
460+
},
453461
"execs": {
454462
"$ref": "#/definitions/ExecutableSerialRefConfigList",
455463
"description": "A list of executables to run in serial.\nEach executable can be a command or a reference to another executable.\n"

docs/types/flowfile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Launches an application or opens a URI.
187187
| Field | Description | Type | Default | Required |
188188
| ----- | ----------- | ---- | ------- | :--------: |
189189
| `args` | | [ExecutableArgumentList](#ExecutableArgumentList) | <no value> | |
190+
| `dir` | | [ExecutableDirectory](#ExecutableDirectory) | | |
190191
| `execs` | A list of executables to run in parallel. Each executable can be a command or a reference to another executable. | [ExecutableParallelRefConfigList](#ExecutableParallelRefConfigList) | <no value> ||
191192
| `failFast` | End the parallel execution as soon as an exec exits with a non-zero status. This is the default behavior. When set to false, all execs will be run regardless of the exit status of parallel execs. | `boolean` | <no value> | |
192193
| `maxThreads` | The maximum number of threads to use when executing the parallel executables. | `integer` | 5 | |
@@ -335,6 +336,7 @@ Executes a list of executables in serial.
335336
| Field | Description | Type | Default | Required |
336337
| ----- | ----------- | ---- | ------- | :--------: |
337338
| `args` | | [ExecutableArgumentList](#ExecutableArgumentList) | <no value> | |
339+
| `dir` | | [ExecutableDirectory](#ExecutableDirectory) | | |
338340
| `execs` | A list of executables to run in serial. Each executable can be a command or a reference to another executable. | [ExecutableSerialRefConfigList](#ExecutableSerialRefConfigList) | <no value> ||
339341
| `failFast` | End the serial execution as soon as an exec exits with a non-zero status. This is the default behavior. When set to false, all execs will be run regardless of the exit status of the previous exec. | `boolean` | <no value> | |
340342
| `params` | | [ExecutableParameterList](#ExecutableParameterList) | <no value> | |

internal/runner/parallel/parallel.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (r *parallelRunner) Exec(
6161
return fmt.Errorf("no parallel executables to run")
6262
}
6363

64+
//nolint:funlen
6465
func handleExec(
6566
ctx *context.Context, parent *executable.Executable,
6667
eng engine.Engine,
@@ -116,13 +117,21 @@ func handleExec(
116117
maps.Copy(execPromptedEnv, a)
117118
}
118119

119-
fields := map[string]interface{}{
120-
"step": exec.ID(),
121-
}
122-
if exec.Exec != nil {
120+
var dir executable.Directory
121+
switch {
122+
case exec.Exec != nil:
123+
fields := map[string]interface{}{"step": exec.ID()}
123124
exec.Exec.SetLogFields(fields)
125+
dir = exec.Exec.Dir
126+
case parent.Parallel != nil:
127+
dir = exec.Parallel.Dir
128+
case parent.Serial != nil:
129+
dir = exec.Serial.Dir
124130
}
125-
131+
if dir == "" {
132+
dir = parent.Parallel.Dir
133+
}
134+
exec.Exec.Dir = dir
126135
runExec := func() error {
127136
err := runner.Exec(ctx, exec, eng, execPromptedEnv)
128137
if err != nil {

internal/runner/serial/serial.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (r *serialRunner) Exec(
6060
return fmt.Errorf("no serial executables to run")
6161
}
6262

63+
//nolint:funlen
6364
func handleExec(
6465
ctx *context.Context,
6566
parent *executable.Executable,
@@ -111,10 +112,22 @@ func handleExec(
111112
}
112113
maps.Copy(execPromptedEnv, a)
113114
}
114-
fields := map[string]interface{}{"step": exec.ID()}
115-
if exec.Exec != nil {
115+
116+
var dir executable.Directory
117+
switch {
118+
case exec.Exec != nil:
119+
fields := map[string]interface{}{"step": exec.ID()}
116120
exec.Exec.SetLogFields(fields)
121+
dir = exec.Exec.Dir
122+
case parent.Parallel != nil:
123+
dir = exec.Parallel.Dir
124+
case parent.Serial != nil:
125+
dir = exec.Serial.Dir
126+
}
127+
if dir == "" {
128+
dir = parent.Serial.Dir
117129
}
130+
exec.Exec.Dir = dir
118131

119132
runExec := func() error {
120133
return runSerialExecFunc(ctx, i, refConfig, exec, eng, execPromptedEnv, serialSpec)

types/executable/executable.gen.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/executable/executable_schema.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ definitions:
385385
type: object
386386
required: [execs]
387387
properties:
388+
dir:
389+
$ref: '#/definitions/Directory'
390+
default: ""
388391
params:
389392
$ref: '#/definitions/ParameterList'
390393
args:
@@ -565,6 +568,9 @@ definitions:
565568
required: [execs]
566569
description: Executes a list of executables in serial.
567570
properties:
571+
dir:
572+
$ref: '#/definitions/Directory'
573+
default: ""
568574
params:
569575
$ref: '#/definitions/ParameterList'
570576
args:

0 commit comments

Comments
 (0)