-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.php
89 lines (78 loc) · 2.25 KB
/
tasks.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
<?
/**
* try:
* maki list
* maki git diff #view diff
* maki git #run all order tasks git (diff, add, commit and push)
* maki tasks
*/
set('SSH_USERNAME', 'usernamessh');
set('SSH_PASSWORD', 'passwordssh');
set('SSH_HOST', 'hostssh');
set('LOCAL_BASE_DIR', __DIR__);
set('REMOTE_BASE_DIR', '/home/remoteuser/application');
//maki git (run add, commit and push)
task('git', 'diff', function(){
local('cd '. get('LOCAL_BASE_DIR'));
$message = local('git diff');
message($message);
//if you like, send e-mail with diff
});
task('git', 'add', function(){
local('cd '. get('LOCAL_BASE_DIR'));
local('git add .', true);
});
task('git', 'commit', function(){
local('cd '. get('LOCAL_BASE_DIR'));
$messageCommit = prompt('Message Commit:', 'red', 'white');
local("git commit -m '".$messageCommit."'");
});
task('git', 'push', function(){
local('cd '. get('LOCAL_BASE_DIR'));
local('git push');
});
//tasks
task( 'tasks', function(){
//git
if(strtolower(prompt('Do you like run git task first?(y|N)'))=='y'){
maki('git');
}
//test
$firstResultTest=true;
if(strtolower(prompt('Do you like run test task first?(y|N)'))=='y'){
$firstResultTest = maki('test');
}
//tasks
if($firstResultTest){
if(strtolower(prompt('You are sure tasks app?(y|N)'))=='y'){
remote('cd '. get('REMOTE_BASE_DIR'));
remote('git pull');
}
}else{
message('You cannot tasks appp. Test fail!', 'red');
}
});
task('test', function(){
require_once 'tests/maki.php';
require_once 'PHPUnit.php';
$suite = new PHPUnit_TestSuite("Maki");
$result = PHPUnit::run($suite);
//include and run any test
message($result->toString(), 'white');//show result test
return ($result->failureCount()>0);
});
task('restart', 'production', function(){
remote('sudo service restart apache');
});
task('restart', 'stating', function(){
open_environment('staging');
remote('sudo service restart apache');
close_environment('staging');
});
task('restart', 'local', function(){
local('sudo service restart apache');
});
task('copy', 'db', function(){
message(get('LOCAL_BASE_DIR').'/examples.txt -> '.get('REMOTE_BASE_DIR').'/exxaample.txt', 'black', 'white');
local_remote(get('LOCAL_BASE_DIR').'/examples.txt', '/tmp/exxaample.txt');
});