Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .qa.zen.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
deploy:
branch:
server: REPLACE_WITH_SERVER
username: REPLACE_WITH_USER
dir: '{home}/github/{repo_owner}/{repo_name}/branch/{branch}'
env_vars:
docroot: 'REPLACE_WITH_DOCROOT'
domain: 'REPLACE_WITH_DOMAIN'
database_name: REPLACE_WITH_DATABASE_NAAME
database_user: REPLACE_WITH_DTABASE_USER
database_pass: REPLACE_WITH_DATABASE_PASSWORD
account_user: REPLACE_WITH_ADMIN_USER
account_mail: REPLACE_WITH_ADMIN_EMAIL
account_pass: REPLACE_WITH_ADMIN_PASSWORD
site_mail: REPLACE_WITH_SITE_EMAIL
site_name: REPLACE_WITH_SITE_NAME
default_theme: "REPLACE_WITH_THEME"
enable_devel: "LEAVE_EMPTY_OR_PUT_YES_TO_ENABLE"
scripts:
init: '{deploy_dir}/scripts/deploy_init.sh'
after: '{deploy_dir}/scripts/deploy_update.sh'
remove: '{deploy_dir}/scripts/deploy_remove.sh'
pull_request:
server: REPLACE_WITH_SERVER
username: REPLACE_WITH_USER
dir: '{home}/github/{repo_owner}/{repo_name}/pr/{pr_number}'
env_vars:
docroot: 'REPLACE_WITH_DOCROOT'
domain: 'REPLACE_WITH_DOMAIN'
database_name: REPLACE_WITH_DATABASE_NAAME
database_user: REPLACE_WITH_DTABASE_USER
database_pass: REPLACE_WITH_DATABASE_PASSWORD
account_user: REPLACE_WITH_ADMIN_USER
account_mail: REPLACE_WITH_ADMIN_EMAIL
account_pass: REPLACE_WITH_ADMIN_PASSWORD
site_mail: REPLACE_WITH_SITE_EMAIL
site_name: REPLACE_WITH_SITE_NAME
default_theme: "REPLACE_WITH_THEME"
enable_devel: "LEAVE_EMPTY_OR_PUT_YES_TO_ENABLE"
scripts:
init: '{deploy_dir}/scripts/deploy_init.sh'
after: '{deploy_dir}/scripts/deploy_update.sh'
remove: '{deploy_dir}/scripts/deploy_remove.sh'

40 changes: 40 additions & 0 deletions .testing.zenci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
test:
REPLACE_WITH_TAG:
branch:
box: REPLACE_WITH_BOX_NAME
dir: '{home}/github'
env_vars:
docroot: '{home}/www'
domain: 'localhost'
database_name: 'test'
database_user: 'test'
database_pass: ''
account_user: REPLACE_WITH_ADMIN_USER
account_mail: REPLACE_WITH_ADMIN_EMAIL
account_pass: REPLACE_WITH_ADMIN_PASSWORD
site_mail: REPLACE_WITH_SITE_EMAIL
site_name: REPLACE_WITH_SITE_NAME
tests: '--all'
scripts:
init: '{deploy_dir}/scripts/test_deploy_init.sh'
tests:
- '{deploy_dir}/scripts/drupal_tests.php'
pull_request:
box: REPLACE_WITH_BOX_NAME
dir: '{home}/github'
env_vars:
docroot: '{home}/www'
domain: 'localhost'
database_name: 'test'
database_user: 'test'
database_pass: ''
account_user: REPLACE_WITH_ADMIN_USER
account_mail: REPLACE_WITH_ADMIN_EMAIL
account_pass: REPLACE_WITH_ADMIN_PASSWORD
site_mail: REPLACE_WITH_SITE_EMAIL
site_name: REPLACE_WITH_SITE_NAME
tests: '--all'
scripts:
init: '{deploy_dir}/scripts/test_deploy_init.sh'
tests:
- '{deploy_dir}/scripts/drupal_tests.php'
1 change: 1 addition & 0 deletions .zenci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ deploy:
scripts:
init: '{deploy_dir}/scripts/deploy_init.sh'
after: '{deploy_dir}/scripts/deploy_update.sh'

36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ Repository contain integration scripts to start using deploy via ZenCI for Drupa
It has next structure
-------
```yaml
modules #put your own custom modules here
libraries #put your own custom libraries here
scripts #deploy related scripts
deploy_init.sh #init script. It will be executed only if {deploy_dir} is empty
deploy_update.sh #after script. It will be executed after each push to repository
drupal_install.sh #download via drush Drupal and install it
settings #meta data for deploy
update #place to put your scripts to run once when created
example.sh #example script
enable.enable #list of projects to enable
themes #put your own custom themes here
modules # put your own custom modules here
libraries # put your own custom libraries here
scripts # deploy related scripts
deploy_init.sh # init script. It will be executed only if {deploy_dir} is empty
drupal_install.sh # download via drush Drupal and install it
qa_deploy_init.sh # QA init script. It will be executed only if {deploy_dir} is empty
run-tests.sh # ZenCI copy of scripts/ru-tests.sh
test_drupal_install.sh # download via drush Drupal 7.x git version and install it
deploy_update.sh # after script. It will be executed after each push to repository
drupal_tests.php # ZenCI wrapper for run-tests.sh. Report back to ZenCI tests status.
qa_deploy_remove.sh # Clean QA server when branch or PR removed.
test_deploy_init.sh # Tests init script. It will be executed to prepare Drupal for test.
settings # meta data for deploy
update # place to put your scripts to run once when created
example.sh # example script
enable.enable # list of projects to enable
themes # put your own custom themes here
```
## Directory structure after deploy.

Expand All @@ -23,10 +29,10 @@ themes #put your own custom themes here
```yaml
github:
YOURNAME:
drupal-starter-kit: #your repository get cloned here
modules: # your own modules
themes: # your own themes
libraries: # your own libraries
drupal-starter-kit: # your repository get cloned here
modules: # your own modules
themes: # your own themes
libraries: # your own libraries
```

Your **DOCROOT** will have full drupal code structure with next extra:
Expand Down
108 changes: 108 additions & 0 deletions scripts/drupal_tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php
/**
* @file
* This script file is executed on the Zen.ci platform for running tests.
*
* This essentially just wraps around the run-tests.sh script and uses the
* result to post the response back to Zen.ci.
*/

$home = getenv('DOCROOT');
$deploy_dir = getenv('ZENCI_DEPLOY_DIR');
chdir($home);

/*
* TableSortTests are failing if theme_registry get called by l() function in
* modules/simpletest/tests/tablesort.test:60
*
* $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE)))));
*
* To fix false failure, disable theme for links for this test.
*/
exec('drush vset theme_link 0');

$data = array(
'state' => 'pending',
'message' => 'Processing Tests',
);

zenci_put_request($data);

$tests = getenv('TESTS');

if(empty($tests)) {
$tests = '--all';
}

$cmd = 'php ' . $deploy_dir . '/scripts/run-tests.sh --url http://localhost --verbose --concurrency 10 --color --summary /tmp/summary ' .$tests;

$proc = popen($cmd, 'r');

while (!feof($proc)) {
echo fread($proc, 4096);
@flush();
}

$status = pclose($proc);

$content = file_get_contents('/tmp/summary');

if ($status) {
$content = explode("\n", $content);

$message = $content[0];
unset($content[0]);
$summary = implode("\n", $content);
// Test failed.
$data = array(
'state' => 'error',
'message' => $message,
'summary' => $summary,
);
zenci_put_request($data);
exit(1);
}
else {
// Success.
$data = array(
'state' => 'success',
'message' => $content,
);
zenci_put_request($data);
exit(0);
}


/**
* Submit a POST request to Zen.ci updating its current status.
*
* @param array $data
* An array of data to push to Zen.ci. Should include the following:
* - state: One of "error", "success", or "pending".
* - message: A string summary of the state.
* - summary: Optional. A longer description of the state.
*/
function zenci_put_request($data) {
$token = getenv('ZENCI_API_TOKEN');
$status_url = getenv('ZENCI_STATUS_URL');

$data = json_encode($data);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $status_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); // Note the PUT here.

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Token: ' . $token,
'Content-Length: ' . strlen($data)
));
curl_exec($ch);
curl_close($ch);
}
Loading