在 github 操作中重试失败的作业

ang*_*ala 7 continuous-integration github-actions

我正在尝试使用GitHub Actions进行 CI 测试,到目前为止我的测试工作流程如下:

name: test

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm install
      - name: test
        run: |
          npm run lint
          npm test
        env:
          CI: true
Run Code Online (Sandbox Code Playgroud)

.github/workflows/test.yml

它工作正常,除非我想test在测试失败时重试该步骤(或整个工作)一次。

基本上,您获得的行为相同travis-retry

script:
  - npm run lint
  - travis_retry npm test
Run Code Online (Sandbox Code Playgroud)

或使用 Gitlab CI:

test:
  stage: test
  retry: 1
  script:
    - npm run lint
    - npm test
Run Code Online (Sandbox Code Playgroud)

不确定是否有解决此问题的方法或相当简单的解决方法

sma*_*c89 8

对于您的特定用例,只需执行以下操作:

npm test || npm test
Run Code Online (Sandbox Code Playgroud)