【问题标题】:Multiple Cypress run --record commands on Github Actions within the same workflow is only recording the first execution on Cypress Dashboard同一工作流中的多个 Cypress 在 Github 上运行 --record 命令仅记录 Cypress Dashboard 上的第一次执行
【发布时间】:2021-10-15 18:35:10
【问题描述】:

我正在构建一个持续部署管道,当主分支发生更改时触发(基于主干),执行通用测试、构建和部署阶段直至生产。

为了实现这一点,我尝试在同一工作流程中在 Github Actions 中执行多个 cypress run 命令,并在 Cypress 仪表板上记录执行情况,这是一个尝试在多个环境中测试应用程序。但是,只有第一次执行被执行和记录。

这是 YAML 的工作流程,删除了不相关的语句:

name: trunk-release
on:
  push:
    branches: [main]
jobs:
  test-local:
    name: test-local
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm ci
      - run: npm start & npx wait-on http://localhost:3000
      - run: npm run cy-test:local
  deploy-dev:
    needs: test-local
    name: deploy-dev
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm run cy-test:dev
  deploy-prod:
    needs: deploy-dev
    name: deploy-prod
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm run cy-test:prod

这是我正在运行的脚本:

  "scripts": {
    "cy-test:local": "./node_modules/.bin/cypress run --record --parallel --tag 'local'",
    "cy-test:dev": "CYPRESS_BASE_URL=https://dev.mywebapp.com ./node_modules/.bin/cypress run --record --parallel --tag 'develop'",
    "cy-test:prod": "CYPRESS_BASE_URL=https://mywebapp.com ./node_modules/.bin/cypress run --record --parallel --tag 'production'",
  }

默认的 CYPRESS_BASE_URL 是 localhost。

npm run cy-test:local 成功运行并记录,但是,其他执行不会运行测试或记录到仪表板。

第二次和第三次执行的 Github Action 日志在这里,显示没有运行测试:

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    7.3.0                                                                              │
  │ Browser:    Electron 89 (headless)                                                             │
  │ Specs:      6 found (listed tests)                                            │
  │ Params:     Tag: develop, Group: false, Parallel: true                                         │
  │ Run URL:    same URL as first run                             │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


tput: No value for $TERM and no -T specified
====================================================================================================

  (Run Finished)

感谢任何帮助, 马特

【问题讨论】:

    标签: cypress github-actions


    【解决方案1】:

    这已通过增加 运行完成延迟 值得到解决。

    运行完成延迟

    在并行化模式或分组运行期间,赛普拉斯将等待指定的时间,然后再完成测试运行,以防还有更多相关工作。这是为了补偿 CI 机器可以在队列中备份的各种场景。 这个等待期称为运行完成延迟,它在最后一个已知 CI 机器完成后开始 此延迟默认为 60 秒,但可在 仪表板项目设置页面。

    更多信息可here

    【讨论】:

      猜你喜欢
      • 2020-08-05
      • 1970-01-01
      • 2022-01-18
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 2021-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多