GitHub Actions中Cypress测试录制视频10-11秒冻结问题求助
解决GitHub Actions中Cypress 12.17.2录制视频10-11秒冻结问题
问题背景
在GitHub Actions中运行Cypress 12.17.2时,测试录制的视频会在开始后10-11秒处冻结,但测试和录制进程仍正常运行。已尝试关闭Cypress的videoCompression配置,问题未得到解决。工作流配置如下:
name: CI on: push: branches: - main - cypress jobs: build: name: Test Apollo runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Use Node.js 18.x uses: actions/setup-node@v3 with: node-version: 18 cache: yarn - name: Install run: yarn --immutable - name: Get latest JBrowse working-directory: packages/jbrowse-plugin-apollo run: yarn run jbrowse create --nightly .jbrowse - name: Start MongoDB uses: supercharge/mongodb-github-action@1.10.0 with: mongodb-version: 7 mongodb-replica-set: test-rs - name: Setup config run: sed -i 's|http://localhost:[0-9]\+/|http://localhost:8999/|' packages/jbrowse-plugin-apollo/cypress/fixtures/config.json - name: Test plugin working-directory: packages/jbrowse-plugin-apollo env: GUEST_USER_ROLE: admin MONGODB_URI: mongodb://localhost:27017/apolloTestDb run: yarn run test:e2e - name: Archive test results if: '!cancelled()' uses: actions/upload-artifact@v3 with: name: cypress_results path: packages/jbrowse-plugin-apollo/cypress
可行解决方案
调整视频录制帧率
在Cypress配置文件(如cypress.config.js)中设置更低的videoFrameRate,减少资源占用:module.exports = defineConfig({ e2e: { videoFrameRate: 15, // 其他原有配置 } })更换GitHub Actions运行环境
将工作流中的runs-on: ubuntu-latest替换为ubuntu-22.04或ubuntu-20.04,不同系统版本的底层依赖可能解决视频编码兼容性问题。禁用浏览器硬件加速
在Cypress配置中添加Chrome启动参数,禁用硬件加速避免资源竞争:module.exports = defineConfig({ e2e: { launchOptions: { args: ['--disable-gpu', '--disable-software-rasterizer'] }, // 其他原有配置 } })升级Cypress版本
尝试升级到最新稳定版Cypress(如13.x系列),后续版本可能修复了该视频录制冻结的bug。改用外部录制工具
放弃Cypress自带的视频录制,在GitHub Actions中用ffmpeg配合xvfb手动录制:- 在工作流中安装ffmpeg:
sudo apt-get update && sudo apt-get install -y ffmpeg - 启动测试前启动录制:
ffmpeg -f x11grab -r 15 -s 1920x1080 -i $DISPLAY -c:v libx264 -preset ultrafast cypress_test.mp4 & - 测试结束后停止ffmpeg进程,并将录制文件作为artifact上传。
- 在工作流中安装ffmpeg:
内容的提问来源于stack exchange,提问作者dariober
相关产品推荐
相关产品推荐

