-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoboFile.php
More file actions
181 lines (153 loc) · 5.91 KB
/
RoboFile.php
File metadata and controls
181 lines (153 loc) · 5.91 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
private function _sources() {
$sources = [
// Import API Docker file
"git@github.com:OpenDataStack/elasticsearch-import-api-docker.git" => "src/elasticsearch-import-api-docker",
// API server (Symfony app)
"git@github.com:OpenDataStack/elasticsearch-import-api-symfony.git" => "src/elasticsearch-import-api-docker/src/elasticsearch-import-api-symfony",
// API client
"git@github.com:OpenDataStack/elasticsearch-import-api-client.git" => "src/elasticsearch-import-api-client",
// DKAN Dockerfile / Image
"git@github.com:OpenDataStack/dkan-opendatastack-docker.git" => "src/dkan-opendatastack-docker",
// DKAN Open Data Stack Source
"git@github.com:OpenDataStack/dkan-opendatastack.git" => "src/dkan-opendatastack-docker/src/dkan-opendatastack"
];
return $sources;
}
public function setup()
{
$this->io()->section("Set up project for development");
$this->_mkdir('src');
foreach ($this->_sources() as $repo => $destination) {
if (!file_exists($destination . '/.git')) {
// Clone
$this->taskGitStack()
->stopOnFail()
->cloneRepo($repo, $destination)
->run();
}
}
// Run composer install for the symfony app
$this->taskComposerInstall()
->dir("src/elasticsearch-import-api-docker/src/elasticsearch-import-api-symfony")
->noInteraction()
->run();
$this->setupHosts();
}
/**
* Update the /etc/hosts file to include dkan service.
*/
public function setupHosts()
{
$this->io()->section("Update /etc/hosts to make sure the 'dkan-apache-php' entry is included.");
$this->_exec("sudo sed -i '/dkan\-apache\-php/d' /etc/hosts");
$this->_exec('echo "127.0.0.1 dkan-apache-php" | sudo tee -a /etc/hosts');
}
// Version Control Operations
public function gitPull()
{
$this->io()->section("Update all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
if (!file_exists($destination)) {
$this->io->error("Repo directory does not exist, have you ran `robo setup`?");
} else {
$this->taskGitStack()
->dir($destination)
->stopOnFail()
->pull()
->run();
}
}
}
public function gitPush()
{
$this->io()->section("Push all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
$this->taskGitStack()
->dir($destination)
->stopOnFail()
->push()
->run();
}
}
public function gitStatus()
{
$this->io()->section("Status of all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
$this->taskExec("git status")
->dir($destination)
->run();
}
}
// Docker Operations
public function dockerUpProd()
{
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec('docker-compose')->arg('up')->run();
}
public function dockerUpDev()
{
$dockerCompose = [
'docker-compose',
'-f docker-compose.yml',
];
// 'Darwin' or 'Linux'
if (PHP_OS == 'Darwin') {
$this->taskExec('docker-sync')->arg('stop')->run();
// TODO add fast start arg cutting out clean step
$this->taskExec('docker-sync')->arg('clean')->run();
$this->taskExec('docker-sync')->arg('start')->run();
}
// 'Darwin' or 'Linux' => darwin or linux
$dockerCompose[] = '-f docker-compose.dev.' . strtolower(PHP_OS) . '.yml';
// For dev setup add the additional order/healcheck directive.
$dockerCompose[] = '-f docker-compose.dev.healthcheck.yml';
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec(implode(' ', $dockerCompose))
->rawArg('up -d')
->run();
}
public function dockerRebuild()
{
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec('docker-compose')
->arg('build')
->run();
}
public function dockerPush()
{
print "TODO";
}
// PHPUnit Tests
public function test()
{
$this->taskPHPUnit()
->dir("src/elasticsearch-import-api-client")
->files('./src/tests/*')
->group('Integration')
->run();
}
public function dkanInstall()
{
$this->taskExecStack()
->stopOnFail()
->exec('time docker-compose exec --user=www-data dkan-apache-php /bin/bash -c "cd /var/www/html/docroot && drush si dkan --verbose --account-pass=\'admin\' --site-name=\'DKAN\' install_configure_form.update_status_module=\'array(FALSE,FALSE)\' --yes"')
->exec('time docker-compose exec --user=www-data dkan-apache-php /bin/bash -c "cd /var/www/html/docroot && drush -y en custom_config"')
->exec('time docker-compose exec --user=www-data dkan-apache-php /bin/bash -c "cd /var/www/html/docroot && drush fr -y --force custom_config"')
->exec('time docker-compose exec --user=www-data dkan-apache-php /bin/bash -c "cd /var/www/html/docroot && drush cc all"')
->run();
}
public function dkanDrush(array $args)
{
$this->taskExec('
docker-compose exec --user=www-data dkan-apache-php /bin/bash -c "cd /var/www/html/docroot && drush ' . implode(' ', $args) . '"
')->run();
}
}