mirror of
https://github.com/go-task/task.git
synced 2025-06-23 00:38:19 +02:00
fix(platforms): do not run dynamic vars for other platforms (#1377)
This commit is contained in:
@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- Fix bug where dynamic `vars:` and `env:` were being executed when they should
|
||||||
|
actually be skipped by `platforms:` (#1273, #1377 by @andreynering).
|
||||||
|
|
||||||
## v3.31.0 - 2023-10-07
|
## v3.31.0 - 2023-10-07
|
||||||
|
|
||||||
- Enabled the `--yes` flag for the
|
- Enabled the `--yes` flag for the
|
||||||
|
@ -32,6 +32,7 @@ var knownOS = map[string]struct{}{
|
|||||||
"solaris": {},
|
"solaris": {},
|
||||||
"windows": {},
|
"windows": {},
|
||||||
"zos": {},
|
"zos": {},
|
||||||
|
"__test__": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
var knownArch = map[string]struct{}{
|
var knownArch = map[string]struct{}{
|
||||||
|
16
task.go
16
task.go
@ -160,7 +160,16 @@ func (e *Executor) splitRegularAndWatchCalls(calls ...taskfile.Call) (regularCal
|
|||||||
|
|
||||||
// RunTask runs a task by its name
|
// RunTask runs a task by its name
|
||||||
func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error {
|
func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error {
|
||||||
t, err := e.CompiledTask(call)
|
t, err := e.FastCompiledTask(call)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !shouldRunOnCurrentPlatform(t.Platforms) {
|
||||||
|
e.Logger.VerboseOutf(logger.Yellow, `task: %q not for current platform - ignored\n`, call.Task)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
t, err = e.CompiledTask(call)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -185,11 +194,6 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return e.startExecution(ctx, t, func(ctx context.Context) error {
|
return e.startExecution(ctx, t, func(ctx context.Context) error {
|
||||||
if !shouldRunOnCurrentPlatform(t.Platforms) {
|
|
||||||
e.Logger.VerboseOutf(logger.Yellow, `task: %q not for current platform - ignored\n`, call.Task)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Logger.VerboseErrf(logger.Magenta, "task: %q started\n", call.Task)
|
e.Logger.VerboseErrf(logger.Magenta, "task: %q started\n", call.Task)
|
||||||
if err := e.runDeps(ctx, t); err != nil {
|
if err := e.runDeps(ctx, t); err != nil {
|
||||||
return err
|
return err
|
||||||
|
16
testdata/platforms/Taskfile.yml
vendored
16
testdata/platforms/Taskfile.yml
vendored
@ -2,31 +2,37 @@ version: '3'
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
build-windows:
|
build-windows:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [windows]
|
platforms: [windows]
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'Running task on windows'
|
- echo 'Running task on windows'
|
||||||
|
|
||||||
build-darwin:
|
build-darwin:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [darwin]
|
platforms: [darwin]
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'Running task on darwin'
|
- echo 'Running task on darwin'
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [linux]
|
platforms: [linux]
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'Running task on linux'
|
- echo 'Running task on linux'
|
||||||
|
|
||||||
build-freebsd:
|
build-freebsd:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [freebsd]
|
platforms: [freebsd]
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'Running task on freebsd'
|
- echo 'Running task on freebsd'
|
||||||
|
|
||||||
build-blank-os:
|
build-blank-os:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: []
|
platforms: []
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'Running command'
|
- echo 'Running command'
|
||||||
|
|
||||||
build-multiple:
|
build-multiple:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: []
|
platforms: []
|
||||||
cmds:
|
cmds:
|
||||||
- cmd: echo 'Running command'
|
- cmd: echo 'Running command'
|
||||||
@ -36,16 +42,19 @@ tasks:
|
|||||||
platforms: [darwin]
|
platforms: [darwin]
|
||||||
|
|
||||||
build-amd64:
|
build-amd64:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [amd64]
|
platforms: [amd64]
|
||||||
cmds:
|
cmds:
|
||||||
- echo "Running command on amd64"
|
- echo "Running command on amd64"
|
||||||
|
|
||||||
build-arm64:
|
build-arm64:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
platforms: [arm64]
|
platforms: [arm64]
|
||||||
cmds:
|
cmds:
|
||||||
- echo "Running command on arm64"
|
- echo "Running command on arm64"
|
||||||
|
|
||||||
build-mixed:
|
build-mixed:
|
||||||
|
deps: [failed-var-other-platform]
|
||||||
cmds:
|
cmds:
|
||||||
- cmd: echo 'building on windows/arm64'
|
- cmd: echo 'building on windows/arm64'
|
||||||
platforms: [windows/arm64]
|
platforms: [windows/arm64]
|
||||||
@ -53,3 +62,10 @@ tasks:
|
|||||||
platforms: [linux/amd64]
|
platforms: [linux/amd64]
|
||||||
- cmd: echo 'building on darwin'
|
- cmd: echo 'building on darwin'
|
||||||
platforms: [darwin]
|
platforms: [darwin]
|
||||||
|
|
||||||
|
failed-var-other-platform:
|
||||||
|
platforms: [__test__]
|
||||||
|
env:
|
||||||
|
EXAMPLE_VAR: {sh: exit 1}
|
||||||
|
vars:
|
||||||
|
EXAMPLE_VAR: {sh: exit 2}
|
||||||
|
Reference in New Issue
Block a user