-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from PressLabs/paths_with_spaces
Paths with spaces fixes #70
- Loading branch information
Showing
13 changed files
with
268 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/vendor/ | ||
composer.lock | ||
.composer/cache | ||
.vimrc | ||
*.pyc | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: | ||
|
||
all: test | ||
|
||
clean: | ||
rm -rf /tmp/wordpress | ||
# rm /tmp/wordpress.tar.gz /tmp/wordpress-*.tar.gz | ||
rm -rf /tmp/wordpress-tests-lib | ||
mysqladmin drop wordpress_test --user root --force | ||
|
||
env_39: | ||
./composer.phar install | ||
bash ./bin/install-wp-tests.sh wordpress_test root '' localhost 3.9 | ||
|
||
env_latest: | ||
./composer.phar install | ||
bash ./bin/install-wp-tests.sh wordpress_test root '' localhost latest | ||
|
||
test: | ||
./vendor/bin/phpunit --tap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"require-dev": { | ||
"codeclimate/php-test-reporter": "dev-master", | ||
"phpmd/phpmd" : "@stable" | ||
"phpmd/phpmd" : "@stable", | ||
"phpunit/phpunit": "4.8.*" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ubuntu:latest | ||
MAINTAINER Presslabs Engineering [email protected] | ||
|
||
RUN apt-get -qq update | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install php5-cli php5-dev php5-curl php5-mysql git subversion wget mysql-client-5.5 mysql-server-5.5 | ||
ADD create_user.py /create_user.py | ||
CMD ["/usr/bin/python3", "/create_user.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from __future__ import print_function | ||
|
||
import subprocess | ||
import sys | ||
import os | ||
import grp | ||
|
||
|
||
def shell(cmd, die=True, encoding='utf8'): | ||
try: | ||
# print(cmd) | ||
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) | ||
# print(out) | ||
# print("") | ||
return str(out, encoding=encoding) | ||
except subprocess.CalledProcessError as err: | ||
# print(err.output) | ||
# print("") | ||
if die is True: | ||
raise | ||
else: | ||
return str(err.output, encoding=encoding) | ||
|
||
|
||
def get_bindmount_user_id(): | ||
out = shell('ls -lnd /code') | ||
uid, gid = out.split()[2:4] | ||
return uid, gid | ||
|
||
|
||
def create_user(): | ||
uid, gid = get_bindmount_user_id() | ||
username = 'developer' | ||
groupname = 'developer' | ||
try: | ||
groupname = grp.getgrgid(gid).gr_name | ||
print("group with id {} already exists: {}".format(gid, groupname)) | ||
except KeyError: | ||
shell('groupadd developer --gid {}'.format(gid)) | ||
out = shell('id -un {}'.format(uid), die=False) | ||
if out == 'id: {}: no such user\n'.format(uid): | ||
print('creating user "developer"') | ||
shell("useradd developer --home /code --uid {} --gid {} --shell=/bin/bash".format( | ||
uid, gid | ||
)) | ||
else: | ||
username = out | ||
print('user with id {} already exists: {}'.format(uid, username)) | ||
return username, groupname | ||
|
||
|
||
def exec_to_bash(): | ||
username, groupname = create_user() | ||
print("starting mysql") | ||
shell("/etc/init.d/mysql start") | ||
print("dropping you to an interactive shell as {}".format(username)) | ||
print("type CTRL+D to return to root shell") | ||
os.chdir('/code') | ||
sys.stdout.flush() | ||
cmd = ["/bin/bash", "bash", "-c", "sudo -iu {}; bash".format(username)] | ||
os.execl(*cmd) | ||
|
||
if __name__ == '__main__': | ||
exec_to_bash() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* Copyright 2014-2015 Presslabs SRL <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License, version 2, as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
/* A Read-Eval-Print-Loop - Poor man's interactive debugger. | ||
usage: repl(get_defined_vars()); | ||
repl(get_defined_vars(), $this); | ||
You can pass in multiple expressions separated by semicolons; | ||
The value of the last expression will be returned. | ||
*/ | ||
function repl($vars, $_this=null) { | ||
// inject the variables in the current scope | ||
// fwrite( STDOUT, "repl\n" ); | ||
if ($_this !== null) { | ||
$vars['_this'] = $_this; | ||
} | ||
foreach($vars as $__name => $__value) { | ||
fwrite( STDOUT, '$'.$__name.'=$vars["'.$__name.'"];' . "\n" ); | ||
if ($__name == 'this'){ | ||
continue; | ||
} | ||
eval('$'.$__name.'=$vars["'.$__name.'"];'); | ||
} | ||
$__ln = 1; | ||
while ( true ) { | ||
try { | ||
$__line = readline("repl $__ln> "); | ||
if ($__line === false) # user presed ^D | ||
break; | ||
$__exploded = explode(";", $__line); | ||
$__last = count($__exploded) - 1; | ||
if ( $__exploded[$__last] === "" ) { | ||
array_pop($__exploded); | ||
$__last--; | ||
} | ||
$__exploded[$__last] = "return " . $__exploded[$__last]; | ||
$__cmd = ""; | ||
foreach($__exploded as $__statement) { | ||
$__cmd = $__cmd . $__statement . ";" ; | ||
} | ||
fwrite( STDOUT, print_r( eval( $__cmd ), true ) . "\n" ); | ||
readline_add_history( $__line ); | ||
} catch (Exception $__err) { | ||
fwrite( STDOUT, 'Exception: ' . $__err->getMessage() . "\n"); | ||
fwrite( STDOUT, "Traceback: \n". $__err->getTraceAsString() . "\n"); | ||
} | ||
$__ln++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters