Search code examples
pythongithubcode-coveragegithub-actionscodecov

GitHub Actions: which shell for codecov-bash on Windows?


What settings do we need to upload with GitHub Actions when running on Windows?

I've tried these.

With no shell:

    - name: Upload coverage
      if: success()
      run: |
        bash <(curl -s https://codecov.io/bash)
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        CODECOV_NAME: ${{ runner.os }} Python ${{ matrix.python-version }}

gives:

Run bash <(curl -s https://codecov.io/bash)
  bash <(curl -s https://codecov.io/bash)
  shell: C:\Program Files\PowerShell\6\pwsh.EXE -command ". '{0}'"
  env:
    pythonLocation: C:\hostedtoolcache\windows\Python\3.5.4\x86
    CODECOV_TOKEN: ***
    CODECOV_NAME: Windows Python 3.5
At D:\a\_temp\f9f81a44-97d3-4908-8e7c-7d8d676e9d93.ps1:2 char:6
+ bash <(curl -s https://codecov.io/bash)
+      ~
The '<' operator is reserved for future use.
+ CategoryInfo          : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : RedirectionNotSupported

##[error]Process completed with exit code 1.

These settings work for Ubuntu and macOS.

Adding shell: bash

    - name: Upload coverage
      if: success()
      run: |
        bash <(curl -s https://codecov.io/bash)
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        CODECOV_NAME: ${{ runner.os }} Python ${{ matrix.python-version }}
      shell: bash

gives:

Run bash <(curl -s https://codecov.io/bash)
  bash <(curl -s https://codecov.io/bash)
  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: C:\hostedtoolcache\windows\Python\3.5.4\x86
    CODECOV_TOKEN: ***
    CODECOV_NAME: Windows Python 3.5
bash: /dev/fd/63: No such file or directory
##[error]Process completed with exit code 127.

Changing to shell: cmd

    - name: Upload coverage
      if: success()
      run: |
        bash <(curl -s https://codecov.io/bash)
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        CODECOV_NAME: ${{ runner.os }} Python ${{ matrix.python-version }}
      shell: cmd

gives:

Run bash <(curl -s https://codecov.io/bash)
  bash <(curl -s https://codecov.io/bash)
  shell: C:\windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
  env:
    pythonLocation: C:\hostedtoolcache\windows\Python\3.5.4\x86
    CODECOV_TOKEN: ***
    CODECOV_NAME: Windows Python 3.5
The system cannot find the file specified.
##[error]Process completed with exit code 1.

Solution

  • You may have better luck using the already existing codecov action.

    In any case, you are running your action in a windows environment, so I would suggest not relying too much on unix-specific behaviour (i.e. process substitution <()) because this may require support from the underlying OS to work. Try this:

    - name: Upload coverage
      if: success()
      run: |
        curl -s https://codecov.io/bash -o codecov.bash
        ./codecov.bash
        # OR
        # curl -s https://codecov.io/bash | bash
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        CODECOV_NAME: ${{ runner.os }} Python ${{ matrix.python-version }}
      shell: bash
    

    You may also be getting the error as a result of the shell running in posix mode. See this question: process substitution not working in bash script