-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoboFile.php
145 lines (130 loc) · 3.1 KB
/
RoboFile.php
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
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
use NGF\Robo\Tasks as NGFTasks;
/**
* Class RoboFile.
*/
class RoboFile extends NGFTasks {
private $defaultOp = "cs,unit";
private $defaultPaths = "web/modules/custom,web/themes/contrib/funkywave";
/**
* Build project.
*
* @command project:build
* @aliases pb
*/
public function build($branch) {
// Change Branch.
$this
->taskGitStack()
->stopOnFail()
->checkout($branch)
->pull()
->run();
// Checkout any local changes on settings.php
if ($this->taskExec("git checkout -- web/sites/default/settings.php")->run()->wasSuccessful()) {
$this->say("Cleared up settings.php changes.");
}
// Install website.
$this->projectInstallConfig();
}
/**
* Update project dependencies.
*
* @command project:update-dep
* @aliases pud
*/
public function updateSiteDependencies() {
// Run Composer update.
$this
->taskComposerUpdate()
->run();
}
/**
* Import config from filesystem to database.
*
* @command project:import-config
* @aliases imc
*/
public function importConfig() {
$this->taskDrushStack($this->config('bin.drush'))
->arg('-r', 'web/')
->exec('cache-clear drush')
->exec('updb')
->exec('csim -y')
->exec('cr')
->run();
}
/**
* Export config from database to filesystem.
*
* @command project:export-config
* @aliases exc
*/
public function exportConfig() {
$this->taskDrushStack($this->config('bin.drush'))
->arg('-r', 'web/')
->exec('cache-clear drush')
->exec('csex -y')
->exec('cr')
->run();
}
/**
* Run QA tasks.
*
* @command tools:qa
* @aliases qa
*
* Usage:
* qa -p web/modules/custom -z cs
* qa -p path1,path2 -z cs,unit
*/
public function qa(array $options = ['path|p' => "", 'op|z' => ""]) {
if (empty($options['path'])) {
$options['path'] = $this->defaultPaths;
}
if (empty($options['op'])) {
$options['op'] = $this->defaultOp;
}
$op = explode(',', $options['op']);
$paths = explode(',', $options['path']);
if (in_array('cs', $op)) {
$this->say("Running code sniffer...");
$this->cs($paths);
}
if (in_array('unit', $op)) {
$this->say("Running unit tests...");
$this->put($paths);
}
}
/**
* Run unit tests.
*
* @command tools:put
* @aliases put
*/
public function put(array $paths) {
$this
->taskExec('sudo php ./bin/run-tests.sh --color --keep-results --suppress-deprecations --types "Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional" --concurrency "36" --repeat "1" --directory ' . implode(' ', $paths))
->run();
}
/**
* Run QA tasks.
*
* @command tools:code-sniff
* @aliases cs
*/
public function cs(array $paths) {
if ($this
->taskExec("bin/phpcs --standard=phpcs-ruleset.xml " . implode(' ', $paths))
->run()
->wasSuccessful()
) {
$this->say("Code sniffer finished.");
};
}
}