Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 10

YAML folded multiline strings interpreted as multiple commands

Solved! Go to Solution.

When using YAML folded multiline strings (using '>' instead of '|'), each line is still interpreted as a separate command instead of the newlines just being replaced by spaces.

 

See https://yaml-multiline.info/ for more information on YAML folded multiline strings.

9 Replies
GitHub Staff
Message 2 of 10

Re: YAML folded multiline strings interpreted as multiple commands

Thanks for reporting this, we're taking a look.

GitHub Staff
Message 3 of 10

Re: YAML folded multiline strings interpreted as multiple commands

Could you give an example of where you are using the folding syntax?

Copilot Lvl 3
Message 4 of 10

Re: YAML folded multiline strings interpreted as multiple commands

I've made a branch in reproc that changes one of my CMake invocations to use a folded multiline string on Ubuntu and macOS:

 

https://github.com/DaanDeMeyer/reproc/runs/217390896

 

I want to use folding to avoid the platform specific command continuation character ('\' on Linux/macOS bash, '^' on Windows cmd). Using folding, all newlines get converted to spaces which removes the need for the platform specific continuation character.

 

Unfortunately, we can see that all Ubuntu and macOS builds fail in the Configure step due to folded multiline strings being interpreted as multiple commands (at least that seems to be what's going on).

GitHub Staff
Message 5 of 10

Re: YAML folded multiline strings interpreted as multiple commands

Currently the run step just takes the multi-line contents and writes that to a file that is then executed using the specified shell program.  The parser does not make any decisions based on the particular type of multi-line specifier in the YAML.  

 

Unfortunately I think we may have an issue where changing that behavior now will potentially cause workflow files that are currently working to break.

Copilot Lvl 3
Message 6 of 10

Re: YAML folded multiline strings interpreted as multiple commands

I realize that a Beta is not supposed to break stuff but it would be rather convenient if this could still be changed while Github Actions is still in Beta.

 

Of course, your team has a way better view on how much stuff is already depending on this behavior than me so I understand if it's not possible to change this anymore.

Solution
GitHub Staff
Message 7 of 10

Re: YAML folded multiline strings interpreted as multiple commands

@DaanDeMeyer could you try formatting your command like this and see if you still see the issue

 

- run: >-
    cmake
    -B build
    -S .
    -G Ninja
    -DCMAKE_BUILD_TYPE=Debug
    -DBUILD_SHARED_LIBS=ON
    -DREPROC++=ON
    -DREPROC_TEST=ON
    -DREPROC_EXAMPLES=ON
    -DREPROC_WARNINGS_AS_ERRORS=ON
    -DREPROC_TIDY=ON
    -DREPROC_SANITIZERS=ON

I think the extra level of indent is informing the YAML parser to add additional new line characters.

Copilot Lvl 3
Message 8 of 10

Re: YAML folded multiline strings interpreted as multiple commands

That fixes the issue. Thanks!

Copilot Lvl 2
Message 9 of 10

Re: YAML folded multiline strings interpreted as multiple commands

To elaborate on the syntax here a bit more, this is one of the odder parts of the YAML specification:

 

[scalar content] can be written with the folded style (denoted by “>”) where each line break is folded to a space unless it ends an empty or a more-indented line.

https://yaml.org/spec/1.2/spec.html#id2760844

 

It's on yaml-multiline.info, too, but to be honest I've never actually read the paragraph on that page where it happens to mention this 😂

Copilot Lvl 3
Message 10 of 10

Re: YAML folded multiline strings interpreted as multiple commands

I agree, this doesn't exactly seem intuitive for a config language. Hopefully this thread helps others that encounter the same issue.