-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
92 lines (82 loc) · 3.05 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
stages:
- test
- deploy
cache:
key: one-key-to-roll-them-all-on-the-wall
paths:
- vendor/
# Template for test jobs
.job_template: &job_definition
stage: test
services:
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
# See http://docs.gitlab.com/ce/ci/services/README.html for examples.
- mariadb:10.2
variables:
# Configure mariadb service https://hub.docker.com/_/mariadb/
MYSQL_ROOT_PASSWORD: toor
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
before_script:
# Install git, the php image doesn't have installed
- export DEBIAN_FRONTEND=noninteractive
- apt-get update -yqq >/dev/null
- apt-get install -yqq git libicu-dev libcurl4-openssl-dev libmcrypt-dev zlib1g-dev zip unzip mysql-client libmysqlclient-dev >/dev/null
- pecl install xdebug-2.5.0
- docker-php-ext-enable xdebug >/dev/null
- docker-php-ext-install pdo_mysql mbstring intl zip >/dev/null
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# Set mysql connection parameters
- cp app/src/settings.php app/src/settings.local.php
- sed -i "s/__APP_URL__/localhost:8081/g;s/__DB_HOST__/mariadb/g;s/__DB_NAME__/"$MYSQL_DATABASE"/g;s/__DB_USER__/"$MYSQL_USER"/g;s/__DB_PASS__/"$MYSQL_PASSWORD"/g;s/__CORS_DOMAIN__/localhost:8080/g;s/__CACHE_TIME__/86400/g" app/src/settings.local.php
# load db data
- mysql -u $MYSQL_USER --password="$MYSQL_PASSWORD" -h mariadb $MYSQL_DATABASE < sql/struct.sql
- mysql -u $MYSQL_USER --password="$MYSQL_PASSWORD" -h mariadb $MYSQL_DATABASE < sql/sample_data.sql
# run php builtin -> TODO: nginx+php-fpm
- bash server-start-builtin.sh 8081 >/dev/null 2>&1 &
test:php7.1:
<<: *job_definition
stage: test
image: php:7.1.16
script:
- php vendor/bin/phpmd app/src text phpmd.xml
- php vendor/bin/phpmetrics --report-html=build/phpmetric-report app/src
- php vendor/bin/phpunit --configuration phpunit_ci.xml
artifacts:
paths:
- build/
only:
- master
- devel
# # If Xdebug was installed you can generate a coverage report and see code coverage metrics.
# test:php7.2:
# <<: *job_definition
# stage: test
# # Select image from https://hub.docker.com/_/php/
# image: php:7.2.4
# script:
# - php vendor/bin/phpmd app/src text phpmd.xml
# - php vendor/bin/phpmetrics --report-html=build/phpmetric-report app/src
# - php vendor/bin/phpunit --configuration phpunit_ci.xml --coverage-text --colors=never
# artifacts:
# paths:
# - build/
# allow_failure: true
deploy_demo:
stage: deploy
image: debian:9.4-slim
script:
- apt-get -qq update -y
- apt-get -qq install -y openssh-client git
- eval $(ssh-agent -s)
- ssh-add - <<<"$SSH_KEY_DEMO" > /dev/null
- ssh -o StrictHostKeyChecking=no -p $SSH_PORT_DEMO [email protected] bash deploy-api.sh &>/dev/null
- echo yay
environment:
name: demo
url: https://dash.cineboard.firegarden.co
# when: manual
only:
- master