Skip to content

Commit

Permalink
Adds probo.ci settings. (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius authored and grasmash committed Jun 26, 2017
1 parent 091ab0a commit 2b73d5e
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 1 deletion.
4 changes: 4 additions & 0 deletions drush/drushrc.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
* affects the loading of Drush configuration files.
*/

if (getenv('PROBO_ENVIRONMENT') && getenv('BUILD_DOMAIN')) {
$options['uri'] = $_ENV['BUILD_DOMAIN'];
}

if (getenv('TUGBOAT_URL')) {
$options['uri'] = $_ENV['TUGBOAT_URL'];
}
Expand Down
46 changes: 46 additions & 0 deletions scripts/probo/.probo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
assets:
- deploy_key
- db.sql.gz
insecureStashDownload: true

steps:
- name: Install deploy key
plugin: Script
script: |
mkdir -p ~/.ssh
cp $ASSET_DIR/deploy_key ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: 'Before install'
plugin: Script
script:
- cd $SRC_DIR
- "$SRC_DIR/blt/files/probo/setup_environment"
- composer self-update
- composer validate --no-check-all --ansi
- composer install
- composer run-script blt-alias

- name: 'Import Drupal assets'
plugin: Drupal
drupalVersion: 8
subDirectory: docroot
database: db.sql.gz
databaseGzipped: true
configSyncDirectory: '../config/default'

- name: 'Setup project'
plugin: Script
script:
- "$SRC_DIR/blt/files/probo/setup_project"

- name: 'Run tests'
plugin: Script
script:
- "$SRC_DIR/blt/files/probo/run_tests"

- name: 'Deploy'
plugin: Script
script:
- "$SRC_DIR/blt/files/probo/deploy_branch"
10 changes: 10 additions & 0 deletions scripts/probo/deploy_branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -ev

# Add the git remote to known hosts
$SRC_DIR/vendor/bin/yaml-cli get:value blt/project.yml git.remotes | cut -d@ -f2 | cut -d: -f1 >> ~/.ssh/known_hosts

$SRC_DIR/vendor/bin/blt deploy --commit-msg "Automated commit by Probo CI for Build ${BUILD_ID}" --branch "${BRANCH_NAME}-build" --ignore-dirty --no-interaction -v

set +v
8 changes: 8 additions & 0 deletions scripts/probo/deploy_tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -ev

# @TODO find a way of identifying if this is a tag build
#blt deploy --commit-msg "Automated commit by Probo CI for Build ${BUILD_ID}" --tag "${BRANCH_NAME}-build" --ignore-dirty -v

set +v
6 changes: 6 additions & 0 deletions scripts/probo/probo.drushrc.aliases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$aliases['${project.machine_name}.ci'] = array(
'uri' => $_ENV['PROBO_ENVIRONMENT'],
'root' => $_ENV['SRC_DIR'] . '/docroot',
);
12 changes: 12 additions & 0 deletions scripts/probo/run_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -ev

# The local.hostname must be set to 127.0.0.1:8888 because we are using drush runserver to test the site.
$SRC_DIR/vendor/bin/yaml-cli update:value $SRC_DIR/blt/project.yml project.local.hostname '127.0.0.1:8888'

$SRC_DIR/vendor/bin/blt validate:all
$SRC_DIR/vendor/bin/blt setup -D drush.alias='${drush.aliases.ci}' --no-interaction
$SRC_DIR/vendor/bin/blt tests:all -D drush.alias='${drush.aliases.ci}' --define tests.run-server=true --yes -v

set +v
36 changes: 36 additions & 0 deletions scripts/probo/setup_environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -ev

# Allow MySQL to finish starting.
sleep 3

export PATH="${SRC_DIR}/vendor/bin":$PATH

# Install PHP 7
echo 'exit 0' > /usr/sbin/policy-rc.d
apt-get update
apt-get install -y software-properties-common language-pack-en-base
LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-gd php7.0-curl php7.0-json php7.0-mbstring php7.0-mysql php7.0-mcrypt php7.0-imagick php7.0-dev php7.0-gmp php7.0-xml php7.0-bcmath php7.0-redis php7.0-uploadprogress php7.0-soap php7.0-pgsql php7.0-bz2

# Create fake mailer.
ln -s /bin/true /usr/sbin/sendmail
echo 'max_execution_time = 120' >> /etc/php/7.0/cli/conf.d/probo.ini
echo 'sendmail_path = /bin/true' >> /etc/php/7.0/cli/conf.d/probo.ini

# Enable $_ENV variables in PHP.
echo 'variables_order = "EGPCS"' >> /etc/php/7.0/cli/conf.d/probo.ini
# Ensure that always_populate_raw_post_data PHP setting: Not set to -1 does not happen.
echo "always_populate_raw_post_data = -1" >> /etc/php/7.0/cli/conf.d/probo.ini
# Set PHP memory limit to something more realistic.
echo "memory_limit=512M" >> /etc/php/7.0/cli/conf.d/probo.ini

# Set git info.
git config --global user.name "ProboCI"
git config --global user.email "noreply@probo.ci"

export DISPLAY=:99.0

set +v
5 changes: 5 additions & 0 deletions scripts/probo/setup_project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -ev

set +v
4 changes: 4 additions & 0 deletions settings/blt.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@
elseif (getenv('TUGBOAT_URL') && file_exists(__DIR__ . '/tugboat.settings.php')) {
require __DIR__ . '/tugboat.settings.php';
}
// Load Probo settings.
elseif (getenv('PROBO_ENVIRONMENT') && file_exists(__DIR__ . '/probo.settings.php')) {
require __DIR__ . '/probo.settings.php';
}
}
2 changes: 1 addition & 1 deletion settings/config.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Non-acquia envs.
if ($is_local_env) {
$split = 'local';
if (getenv('TRAVIS') || getenv('PIPELINE_ENV')) {
if (getenv('TRAVIS') || getenv('PIPELINE_ENV') || getenv('PROBO_ENVIRONMENT')) {
$split = 'ci';
}
}
Expand Down
16 changes: 16 additions & 0 deletions settings/probo.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$databases = array(
'default' => array(
'default' => array(
'database' => 'drupal',
'username' => 'root',
'password' => 'strongpassword',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
'prefix' => '',
),
),
);
19 changes: 19 additions & 0 deletions src/Robo/Commands/Ci/CiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,23 @@ public function travisInit() {
$this->say("<info>A pre-configured .travis.yml file was copied to your repository root.</info>");
}

/**
* Initializes default Travis CI configuration for this project.
*
* @command ci:probo:init
*/
public function proboInit() {
$result = $this->taskFilesystemStack()
->copy($this->getConfigValue('blt.root') . '/scripts/probo/.probo.yml', $this->getConfigValue('repo.root') . '/.probo.yml', TRUE)
->stopOnFail()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

if (!$result->wasSuccessful()) {
throw new BltException("Could not initialize Probo CI configuration.");
}

$this->say("<info>A pre-configured .probo.yml file was copied to your repository root.</info>");
}

}

0 comments on commit 2b73d5e

Please sign in to comment.