【问题标题】:Github Action Cypress Run silently fails on test errorsGithub Action Cypress Run 在测试错误时静默失败
【发布时间】:2021-05-03 08:31:42
【问题描述】:

使用 Github 操作运行 Cypress e2e 测试,但当测试失败时,作业仍然通过。

name: E2E
on:
  push:
    branches: [ master ]
    paths-ignore: [ '**.md' ]
  schedule:
    - cron: '0 8-20 * * *'

jobs:
  cypress-run:
    runs-on: ubuntu-16.04
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Cypress run
        uses: cypress-io/github-action@v2
        continue-on-error: false
        with:
          record: true
        env:
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

我希望工作失败的原因是通过 Github 工作失败或类似这样的松弛通知来获得通知

  - uses: 8398a7/action-slack@v3
    if: job.status == 'failure'
    with:
      status: ${{ job.status }}
      fields: repo
      channel: '#dev'
      mention: here
      text: "E2E tests failed"
    env:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

【问题讨论】:

    标签: cypress github-actions


    【解决方案1】:

    您是否尝试在末尾添加if: ${{ failure() }}

    我最终创建了自己的 curl 请求,该请求会在特定作业出现任何故障时通知 Slack。将它添加到最后对我有用。

    name: E2E
    on:
      push:
        branches: [ master ]
        paths-ignore: [ '**.md' ]
      schedule:
        - cron: '0 8-20 * * *'
    
    jobs:
      cypress-run:
        runs-on: ubuntu-16.04
        steps:
          - name: Checkout
            uses: actions/checkout@v1
    
          - name: Cypress run
            uses: cypress-io/github-action@v2
            continue-on-error: false
            with:
              record: true
            env:
              CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    +
    +      - name: Notify Test Failed
    +        if: ${{ failure() }}
    +        run: |
    +         curl -X POST -H "Content-type:application/json" --data "{\"type\":\"mrkdwn\",\"text\":\".\n❌ *Cypress Run Failed*:\n*Branch:* $GITHUB_REF\n*Repo:* $GITHUB_REPOSITORY\n*SHA1:* $GITHUB_SHA\n*User:* $GITHUB_ACTOR\n.\n\"}" ${{ secrets.SLACK_WEBHOOK }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-26
      • 2019-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-18
      相关资源
      最近更新 更多