Deployment 将gitlab中的Puppeter与gitlab-ci.yml集成

Deployment 将gitlab中的Puppeter与gitlab-ci.yml集成,deployment,gitlab,gitlab-ci,end-to-end,puppeteer,Deployment,Gitlab,Gitlab Ci,End To End,Puppeteer,我目前正在从事铬木偶的e2e测试。我正处于将测试集成到开发过程中的理想阶段 我想要完成的是:在每次部署到生产环境之前,我的测试都会自动运行。如果他们成功,部署将通过,如果他们失败,部署将被取消 我使用gitlab上的管道来自动化部署过程。 所以我的主要问题是如何将我的木偶测试集成到gitlab-ci.yml文件中 我们也遇到了同样的问题,您需要在docker图像上运行舞台,以提供木偶演员: # run performance monitor performanceMonitoring: st

我目前正在从事铬木偶的e2e测试。我正处于将测试集成到开发过程中的理想阶段

我想要完成的是:在每次部署到生产环境之前,我的测试都会自动运行。如果他们成功,部署将通过,如果他们失败,部署将被取消

我使用gitlab上的管道来自动化部署过程。
所以我的主要问题是如何将我的木偶测试集成到gitlab-ci.yml文件中

我们也遇到了同样的问题,您需要在docker图像上运行舞台,以提供木偶演员:

# run performance monitor
performanceMonitoring:
  stage: performanceMonitoring
  image: alekzonder/puppeteer
  script:
    - yarn run performanceMonitoring

这可能有点像黑客,但我的是这样运行的:

test:
image: node:latest
stage: run
script:
- apt-get update
- apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
- yarn
- yarn test
这个超长的库列表是木偶演员启动chrome所需要的。理想情况下,你会有一个现成的码头工人形象,但所有的预制我发现不适合我


准备生产时,您应该构建自己的映像,从节点获取并安装依赖项本身。

实现这一点的最简单方法是使用预装了Puppeter的docker映像

这就是您的.gitlab ci.yml`的外观:

stages:
  - test

cache:
  paths:
    - node_modules/

.node_template:
  image: buildkite/puppeteer

tests:
  extends: .node_template
  stage: test
  variables:
    CI: "true"
  before_script:
    - echo "checking node version"
    - node -v
    - echo "installing dependencies..."
    - npm install
  script:
    - npm run test
我建议使用
buildkite/puppeter
而不是
alekzonder/puppeter
,因为它附带了node的最新LTS版本,而
alekzonder/puppeter
没有。

试试这个

variables:
  IMG_BUILD: node:latest
  IMG_TEST: trion/ng-cli-karma
  IMG_TESTING: alekzonder/puppeteer:latest
  IMG_TESTING_FINAL: node:8.9.1
  IMG_GITLAB_CI: juristr/angular-ci-build:1.0.0
  IMG_TESTING_GITLAB: alekzonder/puppeteer:latest
  IMG_TESTING_GITLAB2: buildkite/puppeteer

deploy_test:
  stage: test
  image: ${IMG_TESTING_GITLAB2}
  environment: Production
  cache:
    policy: pull
  artifacts:
    paths:
      - node_modules/
  only:
    - master
  script:
    - npm install
    - npm run test-ci
使用包配置

"test-ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox",

有点棘手,但这解决了我的问题;我遇到:
ERROR[launcher]:无法使用
karma
启动Chrome
。我已经安装了每个libs,但遇到了这个错误:
ERROR:nacl\u helper\u linux.cc(310)]nacl helper进程在没有沙箱的情况下运行!您很可能需要正确配置SUID沙箱
。我发布Chrome时使用了
——无沙盒
。您是否可以看看我的问题?我在创建工作gitlab.ci-yml文件时遇到类似问题。