首页 > 解决方案 > 如何 Codeception 和 Gitlab CI(持续集成)

问题描述

我目前正在通过 codeception 手动运行我的验收测试。现在是时候进行下一步了。

我想在 Gitlab 中创建一个管道来自动运行我的验收测试。

第一个问题是.gitlab-ci.yml,我真的不知道如何实现它。

我按照本文档中的描述进行操作:https ://codeception.com/docs/12-ContinuousIntegration

但我总是遇到错误。

最新的错误如下: *error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located*

我已经尝试了来自 docker hub 的多个图像,但没有一个成功。

这是我当前的 .gitlab-ci.yml:


# Select what we should cache
cache:
  paths:
  - vendor/

services:
    - selenium/standalone-chrome:latest

before_script:

# Install git and unzip (composer will need them)
- apt-get update && apt-get install -qqy git unzip

#zip
- apt-get install -y zlib1g-dev
- apt-get update && apt-get install -y libzip-dev
- docker-php-ext-install zip

# Install composer
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install all project dependencies
- composer install

#install node
- apt-get update && curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y build-essential nodejs
- npm init -y 
- npm install -g eslint --unsafe-perm=true --alow-root
- npm config set prefix ~/.local  
- PATH=~/.local/bin/:$PATH
- apt-get update -q -y
- apt-get --yes install libnss3
- apt-get --yes install libgconf-2-4

#install wget
- apt-get --yes install wget

#install gnupg2
- apt-get update && apt-get install -y gnupg2


# Install chrome
# Add key
- curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
# Add repo
- echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- apt-get update -q -y
- apt-get install -y google-chrome-stable

- npm install chromedriver -g
- npm install https://gitlab.com/gitlab-org/gitlab-selenium-server.git -g
# The `&` at the end causes it to run in the background and not block the following commands

- nohup chromedriver --port=4444 --url-base=wd/hub &
- nohup gitlab-selenium-server &


# Test
test:
  script:
  - vendor/bin/codecept run --env chrome


标签: dockerpipelinegitlab-cicodeception

解决方案


您是否也尝试过安装 zlib1g-dev ?此评论可能会有所帮助 - https://github.com/docker-library/php/issues/61#issuecomment-468874705但我建议apt install -y zlib1g-dev在安装 php 扩展之前先添加,看看是否能解决问题。


推荐阅读