Skip to content

Instantly share code, notes, and snippets.

@jmsfwk
Created February 7, 2018 12:23
Show Gist options
  • Save jmsfwk/83ef28838290abcb784a6d0ec581e1bc to your computer and use it in GitHub Desktop.
Save jmsfwk/83ef28838290abcb784a6d0ec581e1bc to your computer and use it in GitHub Desktop.
Gitlab Ci configuration for simple PHP projects
before_script:
# Install dependencies
- sh docker_install.sh > /dev/null
cache:
paths:
- vendor/
php:7.1:
image: php:7.1-alpine
script:
- phpunit --configuration phpunit.xml
php:7.2:
image: php:7.2-alpine
script:
- phpunit --configuration phpunit.xml
#!/bin/sh
# We need to install dependencies only for Docker
[[ ! -e /.dockerenv ]] && exit 0
set -xe
# Install git (the php image doesn't have it) which is required by composer
apk update
apk add git
# Install phpunit, the tool that we will use for testing
curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
chmod +x /usr/local/bin/phpunit
# Install composer dependencies
apk add wget
wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php'); unlink('installer.sig');"
php composer.phar install -q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment