【问题标题】:How to Codeception and Gitlab CI (Continuous Integration)如何 Codeception 和 Gitlab CI(持续集成)
【发布时间】:2019-10-31 00:05:05
【问题描述】:

我目前正在通过 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


【问题讨论】:

    标签: docker pipeline gitlab-ci codeception


    【解决方案1】:

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

    【讨论】:

    • 另一个问题,如何使用npm install,因为如果我想使用npm install,它说npm command not found。我可以添加第二个图像(节点)来使用它吗?
    • 你可以简单地运行apt-get install -y nodejs,你应该有可用的npm
    • 我个人更喜欢使用安装了 docker 和 docker-compose 的 shell Gitlab-CI 运行器,因此我可以完全控制我正在执行此操作的实际实例,但同时我可以简单地使用只需将我的项目安装在容器中并运行必要的命令,即可安装 composer 或 npm 的任何 docker 映像。但是,它有时会引起权限问题,因此您需要正确配置实例。但在你的情况下,你应该能够简单地安装 nodejs 并运行 npm i 就好了
    • 我使用了apt-get update && apt-get install -y nodejs,但仍然收到错误:未找到 npm 命令
    • 你能用你所做的更改更新 gitlab-ci.yml 文件吗?
    猜你喜欢
    • 2019-11-28
    • 2020-01-29
    • 1970-01-01
    • 2023-03-24
    • 2022-01-19
    • 1970-01-01
    • 2021-04-17
    • 2021-01-15
    • 1970-01-01
    相关资源
    最近更新 更多