nick-fields / retry

Retries a GitHub Action step on failure or timeout

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support multiline command

CAMOBAP opened this issue · comments

It looks like multiline command doesn't work

Is there any plan to support it

I think this is an issue on windows only... on linux and mac this works for me:

    - name: Foo
      uses: nick-invision/retry@v2
      with:
        timeout_minutes: 5
        max_attempts: 3
        command: |
          command_1 \
            command_1_continued
          command_2

Apparently on windows it is using cmd instead of powershell to execute the command (see also #28).
Perhaps the string containing the command might be using only \n and not \r\n, therefore it is recognised as a single command by cmd?

Probably not relevant, but inside the log, the commands are not aligned properly

Run nick-invision/retry@v2.2.0
  with:
    timeout_minutes: 10
    retry_wait_seconds: 1
    max_attempts: 3
    command: echo "test 1"
  echo "test 2"

I found a workaround! This works properly:

    - name: Foo
      if: runner.os == 'Windows'
      uses: nick-invision/retry@v2.2.0
      with:
        timeout_minutes: 10
        retry_wait_seconds: 1
        max_attempts: 3
        command: >-
          echo "this is command 1" &
          echo "this is command 2"

It is definitely something related to the end of lines, >- removes all the end of lines, and the commands are separated by &
This accepts the cmd syntax though, therefore comments using # are not accepted and using rem will eat the rest of the command. It's not pretty, but I changed the comments from # to echo #.

Also unfortunately empty lines are not accepted (i changed them to "echo &")

The result is ugly but it works.
I hope this helps...

Thanks @drdanz , BTW maybe you have some plan to allow configure she'll also?

P.S. this can be useful for *nix also because python she'll available there

@drdanz @CAMOBAP Could I get a few specific examples where multiline is not working as expected?

I'm testing this now using the following and not able to reproduce the issue:

      - name: Multiline, multi command
        uses: ./
        with:
          timeout_minutes: 1
          max_attempts: 1
          command: |
            echo "abc"
            echo "123"
      - name: Multiline single command
        uses: ./
        with:
          timeout_minutes: 1
          max_attempts: 1
          command: >-
            echo "abc 
            123"

Multiline, multi command outputs:

abc
123

Multiline single command outputs:

abc  123

I believe this to be correct because GitHub syntax for multiline commands begin with | and treat each newline as a separate command, and yaml syntax treats commands beginning with >- as a single string/command with newlines stripped and replaced by spaces.

@nick-invision thanks for the update, if it work now probably the issue wasn't related to this action. My example was as simple as yours, so I think we can close this one

P.S. Any plans to add support for different 'shell'?

Alternate shell support has been added to v2. 3.0. See Readme or related issue #28 comments for examples.

@nick-invision awesome, thanks for the comment

Can you add this as an example in the documentation? Thanks.