Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Ubuntu 14.04 beta in travis #9

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
23 changes: 7 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
language: php
php:
# - 5.5
# - 5.4
- 5.3

#before_install:
# - sudo apt-get update
sudo: required
dist: trusty

env:
global:
Expand All @@ -15,14 +9,14 @@ env:
- secure: "XRsqGDqdu5uhdj2lF4SZ6qv6Y0PdcRPcvE13XvVGnIYRZaITelP3eJNSvLPO+Q5k4mBmKCz8t+ws/OVRRwSAXYaKe0Z8ZXgEcNyo1nEwGekC35mTuG1FFfB/pbuBp5/OWjw6bgz2tEHhKuFIbHytpT9zJQYy+D07rzOYeUsZjOY="

before_script:
- sudo chmod +x scripts/install.sh
- scripts/install.sh
- sudo chmod +x scripts/travis_install.sh
- scripts/travis_install.sh
- cd /opt/codebender/builder/Symfony
- sudo chmod -R 777 app/cache app/logs
- echo 'error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'error_reporting = E_ALL' >> /etc/php5/cli/conf.d/travis.ini
- cd /opt/codebender/builder
- sudo chmod +x scripts/apache_install.sh
- scripts/apache_install.sh
- sudo chmod +x scripts/travis_apache_install.sh
- scripts/travis_apache_install.sh
- cd /opt/codebender/builder/Symfony

script:
Expand All @@ -37,6 +31,3 @@ after_script:

notifications:
irc: "chat.freenode.net#codebender.cc"
# email:
# recipients:
# - [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function compile($contents)
{
$apiHandler = $this->get('codebender_builder.handler');

$contents = $this->checkForUserIdProjectId($contents);
$contents = $this->addUserIdProjectIdIfNotInRequest($contents);

$files = $contents["files"];

Expand Down Expand Up @@ -210,17 +210,10 @@ protected function returnProvidedAndFetchedLibraries($projectFiles, $userLibrari
* @param array $requestContents
* @return array
*/
protected function checkForUserIdProjectId($requestContents)
protected function addUserIdProjectIdIfNotInRequest($requestContents)
{
if (!array_key_exists('userId', $requestContents)) {
$requestContents['userId'] = 'null';
}

if (!array_key_exists('projectId', $requestContents)) {
$requestContents['projectId'] = 'null';
}

return $requestContents;
$nullDefaults = ['userId' => 'null', 'projectId' => 'null'];
return array_merge($nullDefaults, (array)$requestContents);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testCompileNonJsonCompilerResponse() {
// Override previous controller mock. More class member functions need to get mocked.
$controller = $this->getMockBuilder('Codebender\BuilderBundle\Controller\DefaultController')
->disableOriginalConstructor()
->setMethods(['get', 'getRequest', 'checkForUserIdProjectId', 'returnProvidedAndFetchedLibraries'])
->setMethods(['get', 'getRequest', 'addUserIdProjectIdIfNotInRequest', 'returnProvidedAndFetchedLibraries'])
->getMock();

$controller->setContainer($container);
Expand All @@ -170,7 +170,7 @@ public function testCompileNonJsonCompilerResponse() {

$controller->expects($this->at(0))->method('get')->with('codebender_builder.handler')
->willReturn($apiHandler);
$controller->expects($this->at(1))->method('checkForUserIdProjectId')->with(['files' => []])
$controller->expects($this->at(1))->method('addUserIdProjectIdIfNotInRequest')->with(['files' => []])
->willReturn(['files' => []]);
$controller->expects($this->at(2))->method('returnProvidedAndFetchedLibraries')->with([])
->willReturn(['libraries' => []]);
Expand All @@ -191,7 +191,7 @@ public function testCompileFalseCompilationWithoutStepIncluded() {
// Override previous controller mock. More class member functions need to get mocked.
$controller = $this->getMockBuilder('Codebender\BuilderBundle\Controller\DefaultController')
->disableOriginalConstructor()
->setMethods(['get', 'getRequest', 'checkForUserIdProjectId', 'returnProvidedAndFetchedLibraries'])
->setMethods(['get', 'getRequest', 'addUserIdProjectIdIfNotInRequest', 'returnProvidedAndFetchedLibraries'])
->getMock();

$controller->setContainer($container);
Expand All @@ -203,7 +203,7 @@ public function testCompileFalseCompilationWithoutStepIncluded() {

$controller->expects($this->at(0))->method('get')->with('codebender_builder.handler')
->willReturn($apiHandler);
$controller->expects($this->at(1))->method('checkForUserIdProjectId')->with(['files' => []])
$controller->expects($this->at(1))->method('addUserIdProjectIdIfNotInRequest')->with(['files' => []])
->willReturn(['files' => []]);
$controller->expects($this->at(2))->method('returnProvidedAndFetchedLibraries')->with([])
->willReturn(['libraries' => []]);
Expand All @@ -228,7 +228,7 @@ public function testCompileFalseCompilationWithStepIncluded() {
// Override previous controller mock. More class member functions need to get mocked.
$controller = $this->getMockBuilder('Codebender\BuilderBundle\Controller\DefaultController')
->disableOriginalConstructor()
->setMethods(['get', 'getRequest', 'checkForUserIdProjectId', 'returnProvidedAndFetchedLibraries'])
->setMethods(['get', 'getRequest', 'addUserIdProjectIdIfNotInRequest', 'returnProvidedAndFetchedLibraries'])
->getMock();

$controller->setContainer($container);
Expand All @@ -240,9 +240,10 @@ public function testCompileFalseCompilationWithStepIncluded() {

$controller->expects($this->at(0))->method('get')->with('codebender_builder.handler')
->willReturn($apiHandler);
$controller->expects($this->at(1))->method('checkForUserIdProjectId')->with(['files' => []])
->willReturn(['files' => []]);
$controller->expects($this->at(2))->method('returnProvidedAndFetchedLibraries')->with([])
$controller->expects($this->at(1))->method('addUserIdProjectIdIfNotInRequest')
->with(['files' => [], 'libraries' => []])
->willReturn(['files' => [], 'libraries' => []]);
$controller->expects($this->at(2))->method('returnProvidedAndFetchedLibraries')->with([], [])
->willReturn(['libraries' => []]);

$container->expects($this->once())->method('getParameter')->with('compiler')
Expand All @@ -251,7 +252,7 @@ public function testCompileFalseCompilationWithStepIncluded() {
->with('http://compiler/url', '{"files":[],"libraries":[]}')
->willReturn('{"success":false,"message":"someError","step":5}');

$functionResponse = $function->invoke($controller, ['files' => []]);
$functionResponse = $function->invoke($controller, ['files' => [], 'libraries' => []]);

$this->assertEquals('{"success":false,"message":"someError","step":5,"additionalCode":[]}', $functionResponse);
}
Expand Down Expand Up @@ -435,7 +436,7 @@ public function testcheckUserIdProjectIdHasNone() {
/*
* Use ReflectionMethod class to make compile protected function accessible from current context
*/
$function = $this->getMethod('checkForUserIdProjectId');
$function = $this->getMethod('addUserIdProjectIdIfNotInRequest');

$requestContent = ['files' => [['filename' => 'project.ino', 'content' =>'']]];

Expand All @@ -451,7 +452,7 @@ public function testcheckUserIdProjectIdHasOnlyUserId() {
/*
* Use ReflectionMethod class to make compile protected function accessible from current context
*/
$function = $this->getMethod('checkForUserIdProjectId');
$function = $this->getMethod('addUserIdProjectIdIfNotInRequest');

$requestContent = ['userId' => 1, 'files' => [['filename' => 'project.ino', 'content' =>'']]];

Expand All @@ -467,7 +468,7 @@ public function testcheckUserIdProjectIdHasOnlyProjectId() {
/*
* Use ReflectionMethod class to make compile protected function accessible from current context
*/
$function = $this->getMethod('checkForUserIdProjectId');
$function = $this->getMethod('addUserIdProjectIdIfNotInRequest');

$projectFiles = ['projectId' => 1, 'files' => [['filename' => 'project.ino', 'content' =>'']]];

Expand Down
9 changes: 9 additions & 0 deletions apache-config-2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<VirtualHost *:80>
DocumentRoot /var/www
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/apache_install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set -e

PACKAGENAME=builder

sudo cp /opt/codebender/$PACKAGENAME/apache-config /etc/apache2/sites-available/codebender-$PACKAGENAME
sudo ln -s /opt/codebender/$PACKAGENAME/Symfony/web /var/www/$PACKAGENAME
sudo cp /opt/codebender/$PACKAGENAME/apache-config-2.4 /etc/apache2/sites-available/codebender-$PACKAGENAME
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/codebender-$PACKAGENAME 00-codebender.conf
sudo service apache2 restart
60 changes: 25 additions & 35 deletions scripts/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ set -e

PACKAGENAME=builder

if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Configuring environment for Linux"
# Make sure we have up-to-date stuff
sudo apt-get update
if [[ ! $TRAVIS ]]; then
# Ubuntu Server (on AWS?) lacks UTF-8 for some reason. Give it that
sudo locale-gen en_US.UTF-8
sudo apt-get install -y php5-intl
fi
# Install dependencies
sudo apt-get install -y apache2 libapache2-mod-php5 php-pear php5-xdebug php5-curl php5-sqlite php5-mysql acl curl git
# Enable Apache configs
sudo a2enmod rewrite
sudo a2enmod alias
# Restart Apache
sudo service apache2 restart
elif [[ "$OSTYPE" == "darwin"* ]]; then
# is there something comparable to this on os x? perhaps Homebrew
echo "Configuring environment for OS X (to be added..)"
if [[ "$OSTYPE" != "linux-gnu" ]]; then
echo "Only Linux environment is supported"
fi
echo "Configuring environment for Linux"
# Make sure we have up-to-date stuff
sudo apt-get update
if [[ ! $TRAVIS ]]; then
# Ubuntu Server (on AWS?) lacks UTF-8 for some reason. Give it that
sudo locale-gen en_US.UTF-8
sudo apt-get install -y php5-intl
fi
# Install dependencies
sudo apt-get install -y apache2 libapache2-mod-php5 php-pear php5-curl php5-sqlite php5-mysql acl curl git
# Enable Apache configs
sudo a2enmod rewrite
sudo a2enmod alias
# Restart Apache
sudo service apache2 restart


if [[ ! $TRAVIS ]]; then

Expand All @@ -47,23 +46,14 @@ cd /opt/codebender/$PACKAGENAME
rm -rf Symfony/app/cache/*
rm -rf Symfony/app/logs/*

if [[ "$OSTYPE" == "linux-gnu" ]]; then

if [[ ! $TRAVIS ]]; then
# Need to create cache and logs directories, as they do not pre-exist in new deployments
mkdir -p `pwd`/Symfony/app/cache/
mkdir -p `pwd`/Symfony/app/logs/

# Set access control for both apache and current user on cache and logs directories
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX `pwd`/Symfony/app/cache `pwd`/Symfony/app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx `pwd`/Symfony/app/cache `pwd`/Symfony/app/logs
fi

elif [[ "$OSTYPE" == "darwin"* ]]; then
if [[ ! $TRAVIS ]]; then
# Need to create cache and logs directories, as they do not pre-exist in new deployments
mkdir -p `pwd`/Symfony/app/cache/
mkdir -p `pwd`/Symfony/app/logs/

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" Symfony/app/cache Symfony/app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" Symfony/app/cache Symfony/app/logs
# Set access control for both apache and current user on cache and logs directories
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX `pwd`/Symfony/app/cache `pwd`/Symfony/app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx `pwd`/Symfony/app/cache `pwd`/Symfony/app/logs
fi

cd Symfony
Expand Down
11 changes: 11 additions & 0 deletions scripts/travis_apache_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -x
set -e

PACKAGENAME=builder

sudo ln -s /opt/codebender/$PACKAGENAME/Symfony/web /var/www/$PACKAGENAME
sudo cp /opt/codebender/$PACKAGENAME/apache-config-2.2 /etc/apache2/sites-available/codebender-$PACKAGENAME
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/codebender-$PACKAGENAME 00-codebender.conf
sudo service apache2 restart
47 changes: 47 additions & 0 deletions scripts/travis_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -x
set -e

PACKAGENAME=builder

echo "Configuring environment for Linux (Ubuntu 12.04)"

# Make sure we have up-to-date stuff
sudo apt-get update

# Install dependencies
sudo apt-get install -y apache2 libapache2-mod-php5 php-pear php5-curl php5-sqlite php5-mysql acl curl git
# Enable Apache configs
sudo a2enmod rewrite
sudo a2enmod alias
# Restart Apache
sudo service apache2 restart

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`

sudo mkdir -p /opt/codebender
sudo cp -r . /opt/codebender/$PACKAGENAME
sudo chown -R `whoami`:$HTTPDUSER /opt/codebender/$PACKAGENAME
cd /opt/codebender/$PACKAGENAME

#Set permissions for app/cache and app/logs

rm -rf Symfony/app/cache/*
rm -rf Symfony/app/logs/*

# Need to create cache and logs directories, as they do not pre-exist in new deployments
mkdir -p `pwd`/Symfony/app/cache/
mkdir -p `pwd`/Symfony/app/logs/

cd Symfony

set +x
cat app/config/parameters.yml.dist | grep -iv "compiler:" | grep -iv "library:" > app/config/parameters.yml
echo " compiler: '$COMPILER_URL'" >> app/config/parameters.yml

echo " library: '$LIBRARY_URL'" >> app/config/parameters.yml
set -x


curl -s http://getcomposer.org/installer | php
php composer.phar install