Skip to content

Instantly share code, notes, and snippets.

@RomainMarecat
Last active April 25, 2022 03:56
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save RomainMarecat/6477a8c5b1505913448be5d70958b319 to your computer and use it in GitHub Desktop.
Save RomainMarecat/6477a8c5b1505913448be5d70958b319 to your computer and use it in GitHub Desktop.
Simple gitlab-ci configuration symfony
#!/bin/bash
# Install dependencies only for Docker.
[[ ! -e /.dockerinit ]] && exit 0
set -xe
# Update packages and install composer and PHP dependencies.
apt-get update -yqq
apt-get install git 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 phpunit -yqq
# Compile PHP, include these extensions.
docker-php-ext-install mbstring mcrypt pdo pdo_mysql curl json intl gd xml zip bz2 opcache
# Select image from https://hub.docker.com/r/_/php/
image: php:7.0
# Services
services:
- mysql:latest
# Variables and root user used
variables:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: gitlab-ci
MYSQL_PASSWORD: secret
MYSQL_DATABASE: your_db_name
# Before Script
before_script:
- bash .gitlab-ci.sh > /dev/null
- cd /builds/zeedenis/ZeeApi
- php -v
- ping -c 3 mysql
- cp app/config/parameters.gitlab-ci.yml app/config/parameters.yml
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
- php app/console doctrine:database:create --env=test --if-not-exists
- php app/console doctrine:schema:create --env=test
test:app:
script:
- phpunit -c app --debug
parameters:
database_host: mysql
database_name: your_db_name
database_name_test: your_db_name
database_user: root
database_password: secret
@senorihl
Copy link

senorihl commented Sep 30, 2017

I always get this error when executing similar configuration, any idea why ?

$ php composer.phar install — prefer-dist
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 87 installs, 0 updates, 0 removals
 Failed to download symfony/polyfill-mbstring from dist: The zip extension and unzip command are both missing, skipping.
A php.ini file does not exist. You will have to create one.
 Now trying to download from source
 — Installing symfony/polyfill-mbstring (v1.4.0): Cloning f29dca382a
 
 [RuntimeException] 
 Failed to clone https://github.com/symfony/polyfill-mbstring.git, git was not found, check that it is installed and in your PATH env. 
 sh: 1: git: not found 
 
install [ — prefer-source] [ — prefer-dist] [ — dry-run] [ — dev] [ — no-dev] [ — no-custom-installers] [ — no-autoloader] [ — no-scripts] [ — no-progress] [ — no-suggest] [-v|vv|vvv| — verbose] [-o| — optimize-autoloader] [-a| — classmap-authoritative] [ — apcu-autoloader] [ — ignore-platform-reqs] [ — ] [<packages>]…
ERROR: Job failed: exit code 1

---- EDIT

Nevermind the changes made by @Querdos on .gitlab-ci.sh fixed the thing ;-)

@xenogew
Copy link

xenogew commented Aug 22, 2018

I got problem with these lines:

  • - cd /builds/zeedenis/ZeeApi -> path not found, I quite understand because my project doesn't contain those path.
  • - ping -c 3 mysql -> command not found, very weird, cause ping is the basic command of Linux base environment.
  • - cp app/config/parameters.gitlab-ci.yml app/config/parameters.yml -> cp: cannot create regular file 'app/config/parameters.yml': No such file or directory
  • - phpunit -c app --debug -> phpunit command not found: wonder is .gitlab-ci.sh do its job exactly?
  • - php app/console doctrine:database:create --env=test --if-not-exists -> connection refuse.

@PierluigiLampi
Copy link

ping: command not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment