在 GitLab CI 中启动 Quasar 开发服务器锁定

Starting Quasar development server in GitLab CI locks up

我在 GitLab CI 管道中遇到了一些问题 运行 赛普拉斯测试。当我用 yarn quasar dev 启动 Quasar 开发服务器时,它看起来好像真的在启动,但随后它似乎有点被锁定了。

在 GitLab 终止作业之前,这种状态持续了大约一个小时。

这是管道定义。请注意,这是针对此问题的简化版本。

.gitlab-ci.yml

---
variables:
  FF_USE_FASTZIP: "true"
  YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/yarn"
  CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/Cypress"

.cache_configuration:
  cache:
    key:
      files:
        - yarn.lock
    paths:
      - package.json
      - yarn.lock
      - .cache/
      - node_modules/
      - dist/spa/

stages:
  - test

# Install dependencies and start Quasar dev server
ui-chrome:
  stage: test
  image: cypress/browsers:node16.14.0-chrome99-ff97
  extends: .cache_configuration
  cache:
    policy: pull
  script:
    - yarn install --frozen-lockfile # this works
    - yarn quasar dev # this seems to work but causes the lock up
    - yarn cypress run # this does not work
  rules:
    - if: '$CI_COMMIT_TAG =~ /^\d+.\d+.\d+$/'
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_MERGE_REQUEST_IID && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"

quasar dev 是一个 non-ending 进程。在正常情况下,您不希望开发服务器自行关闭。在这种情况下,您希望开发服务器在 Cypress 测试 运行ning 时 运行,然后在测试完成后关闭。

Quasar Cypress App Extension(AE) adds a few package scripts you can use. It uses start-server-and-test under the hood. So, you can either directly use the scripts the AE provides, update them, or read start-server-and-test 并创建您自己的。

这是 yarn test:e2e:ci 包脚本的命令:

cross-env NODE_ENV=test start-test "quasar dev" http-get://localhost:8080 "cypress run"

因此,您可以在代码中替换以下内容:

  script:
    - yarn install --frozen-lockfile # this works
    - yarn quasar dev # this seems to work but causes the lock up
    - yarn cypress run # this does not work

  script:
    - yarn install --frozen-lockfile
    - yarn test:e2e:ci