2

在 Windows 上运行时,我们需要使用 GitHub Actions 上传哪些设置?

这些我都试过了。

没有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 }}

给出:

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.

这些设置适用于 Ubuntu 和 macOS。

添加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

给出:

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.

更改为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

给出:

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.
4

1 回答 1

3

使用已经存在的codecov 操作可能会更好。

在任何情况下,您都在 Windows 环境中运行您的操作,因此我建议不要过度依赖特定于 unix 的行为(即进程替换<()),因为这可能需要底层操作系统的支持才能工作。尝试这个:

- 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

由于 shell 在 posix 模式下运行,您也可能会收到错误消息。看到这个问题:进程替换在 bash 脚本中不起作用

于 2019-12-06T17:03:00.187 回答