question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail-fast/pipefail behaviour for default shell inconsistent with documentation

See original GitHub issue

Describe the bug The documentation states that

Fail-fast behavior using set -eo pipefail: Default for bash and built-in shell. It is also the default when you don’t provide an option on non-Windows platforms. (my emphasis)

The last statement does not appear to be true, as false | true passes on ubuntu-latest when not explicitly setting the shell option.

To Reproduce Steps to reproduce the behavior:

  1. Run workflow file:
name: Test pipefail

on:
  push

jobs:
  test-pipefail:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: Run command false first
        if: always()
        run: false | true
      
      - name: Run command false last
        if: always()
        run: true | false
  1. Observe that only second step fails

Expected behavior I expect that the behaviour of the runner to be consistent with the documentation, ie. that both steps in the above example fails, or that the documentation is updated to reflect the actual behaviour.

Runner Version and Platform

Built in runner using ubuntu-latest

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
eric-wiesercommented, Jul 19, 2022

I think there’s still a bug here; this page says that bash is the default shell, and that it is invoked with bash --noprofile --norc -eo pipefail {0}:

jobs.<job_id>.steps[*].shell

You can override the default shell settings in the runner’s operating system using the shell keyword. You can use built-in shell keywords, or you can define a custom set of shell options. The shell command that is run internally executes a temporary file that contains the commands specified in the run keyword.

Supported platform shell parameter Description Command run internally
All bash The default shell on non-Windows platforms with a fallback to sh. When specifying a bash shell on Windows, the bash shell included with Git for Windows is used. bash --noprofile --norc -eo pipefail {0}

I think that table should have an extra row called “(default)”, which is specified as bash -e {0}.

2reactions
MayCXCcommented, Oct 31, 2022

Hi, another thing that affects this, because the default/unspecified shell is bash -e with the errexit flag, this does result in fail fast behavior by default, which is not mentioned here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference . Perhaps mentioning both would be clearest?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found