珀耳塞福建 发表于 2018-1-11 15:53:14

搭建自己的GitLab CI Runner 运行Laravel测试

# This file is a template, and might need editing before it works on your project 这个文件是一个模板,在您的项目工作之前可能需要进行编辑。  
#
Official framework image. Look for the different tagged>
#https://hub.docker.com/r/library/php  
image: php:latest
  

  
# Pick zero or more services to be used on all builds 选择在所有构建中使用的0或更多的服务。
  
# Only needed when using a docker container to run your tests in 只有在使用docker容器来运行测试时才需要。
  
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
  
services:
  
- mysql:latest
  

  
variables:
  
MYSQL_DATABASE: project_name
  
MYSQL_ROOT_PASSWORD: secret
  

  
# This folder is cached between builds 此文件夹在构建之间进行缓存
  
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
  
cache:
  
paths:
  
- vendor/
  
- node_modules/
  

  
# This is a basic example for a gem or script which doesn't use 这是一个没有使用的gem或脚本的基本示例
  
# services such as redis or postgres 诸如redis或postgres之类的服务
  
before_script:
  
# Update packages 更新包
  
- apt-get update -yqq
  

  
# Upgrade to Node 7 更新node 7
  
- curl -sL https://deb.nodesource.com/setup_7.x | bash -
  

  
# Install dependencies 安装依赖
  
- apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
  

  
# Install php extensions 安装php扩展
  
- docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache
  

  
# Install Composer and project dependencies安装composer和项目依赖
  
- curl -sS https://getcomposer.org/installer | php
  
- php composer.phar install
  

  
# Install Node dependencies 安装node的依赖
  
# comment this out if you don't have a node dependency 如果没有节点依赖,请注释掉
  
- npm install
  

  
# Copy over testing configuration 复制测试配置。
  
# Don't forget to set the database config in .env.testing correctly 不要忘记在.env中设置数据库配置。测试正确
  
# DB_HOST=mysql
  
# DB_DATABASE=project_name
  
# DB_USERNAME=root
  
# DB_PASSWORD=secret
  
- cp .env.testing .env
  

  
# Run npm build
  
# comment this out if you don't have a frontend build 若果没有前端build,请注释掉
  
# you can change this to to your frontend building script like 你可以把它修改为你的前端构建脚本
  
# npm run build
  
- npm run dev
  

  
# Generate an application key. Re-cache. 生成一个应用程序
  
- php artisan key:generate
  
- php artisan config:cache
  

  
# Run database migrations. 执行数据库迁移
  
- php artisan migrate
  

  
# Run database seed 执行数据填充
  
- php artisan db:seed
  

  
test:
  
script:
  
# run laravel tests 执行测试
  
- php vendor/bin/phpunit --coverage-text --colors=never
  

  
# run frontend tests 执行前端测试
  
# if you have any task for testing frontend 如果你有测试前端的任务
  
# set it in your package.json script
  
# comment this out if you don't have a frontend test 如果你没有前端测试,请注释掉
  
- npm test
页: [1]
查看完整版本: 搭建自己的GitLab CI Runner 运行Laravel测试