Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent variable expansion #393

Closed
thomews opened this issue Oct 29, 2020 · 2 comments
Closed

Inconsistent variable expansion #393

thomews opened this issue Oct 29, 2020 · 2 comments
Labels
area: variables Changes related to variables. type: bug Something not working as intended.

Comments

@thomews
Copy link

thomews commented Oct 29, 2020

  • Task version: 3.0.0
  • OS: Windows 10 AMD64

I have a set of included task files which represent a composition of different variables. I also have one included generic task file and one main Taskfile which contains all includes. Task abcd in generic-tasks.yml is expected to always print A_B_C_D=A_B_C_D. With Task v2 this has been working as expected. However, with Task v3.0.0 the result is random and not always consistent:

$ cd main/
$ task generic:abcd
A_B_C_D=__C_D
$ task generic:abcd
A_B_C_D=___D
$ task generic:abcd
A_B_C_D=A_B_C_D
$ task generic:abcd
A_B_C_D=A_B_C_D
$ task generic:abcd
A_B_C_D=___D
$ task generic:abcd
A_B_C_D=A_B_C_D
$ task generic:abcd
A_B_C_D=_B_C_D
$ task generic:abcd
A_B_C_D=A_B_C_D
$ task generic:abcd
A_B_C_D=__C_D

taskfiles.zip

Overview of files and structure:

|-vars-a.yml
|-vars-b.yml
|-vars-c.yml
|-vars-abcd.yml
|-generic-tasks.yml
|-main/
     |-Taskfile.yml

File: main/Taskfile.yml

version: '3'
includes:
  a: ../vars-a.yml
  b: ../vars-b.yml
  c: ../vars-c.yml
  abcd: ../vars-abcd.yml
  generic: ../generic-tasks.yml
vars:
  D: D

File: vars-a.yml

version: '3'
vars:
  A: A

File: vars-b.yml

version: '3'
vars:
  B: B

File: vars-c.yml

version: '3'
vars:
  C: C

File: vars-abdc.yml

version: '3'
vars:
  A_B_C_D: "{{.A}}_{{.B}}_{{.C}}_{{.D}}"

File: generic-tasks.yml

version: '3'
tasks:
  abcd:
    desc: print A_B_C_D
    cmds:
      - echo A_B_C_D={{.A_B_C_D}}
    silent: true
@thomews
Copy link
Author

thomews commented Oct 29, 2020

Please also see the working example with v2 in taskfiles-v2.zip

@andreynering andreynering added type: bug Something not working as intended. area: variables Changes related to variables. labels Jan 1, 2021
@andreynering
Copy link
Member

Hi @thomews, thanks a lot for reporting this bug (and for the reproducible examples)!

I just fixed this in master by making Task respect the order of declaration of included Taskfiles. This worked for your example.

Keep in mind that you have to keep the include that references a var after the include that defines it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables. type: bug Something not working as intended.
Projects
None yet
Development

No branches or pull requests

2 participants