EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/315608
Change subject: Add role for etsy/phan static analyzer ...................................................................... Add role for etsy/phan static analyzer Phan is a static analyzer for PHP. Assuming code is appropriately annotated it can detect common problems in php, such as referencing a class/function/variable that does not exist. This has shown to be useful in the CirrusSearch codebase, so adding a role for it to make it more widely available. I'm not sure the method for adding php7 is quite the right way...suggestions accepted. Change-Id: I51dd02c134a9bf6cdf04f2ba20ce428e72d3a2d6 --- M puppet/hieradata/common.yaml M puppet/modules/php/manifests/composer/install.pp A puppet/modules/role/manifests/phan.pp A puppet/modules/role/manifests/php7.pp M puppet/modules/service/manifests/gitupdate.pp 5 files changed, 66 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant refs/changes/08/315608/1 diff --git a/puppet/hieradata/common.yaml b/puppet/hieradata/common.yaml index 30d756f..7aab94b 100644 --- a/puppet/hieradata/common.yaml +++ b/puppet/hieradata/common.yaml @@ -308,6 +308,8 @@ role::oauthauthentication::consumer_secret: 143a7e53fe1e0fe7f42a2aed77b8e6fc9f38112a role::oauthauthentication::callback_url: "http://dev.wiki.local.wmftest.net%{::port_fragment}/wiki/Special:OAuthLogin/finish" +role::phan::install_dir: "%{hiera('mwv::services_dir')}/phan" + role::phragile::debug: true role::phragile::install_dir: "%{hiera('mwv::services_dir')}/phragile" role::phragile::vhost_name: "phragile%{hiera('mwv::tld')}" diff --git a/puppet/modules/php/manifests/composer/install.pp b/puppet/modules/php/manifests/composer/install.pp index e63d1cc..85eed3d 100644 --- a/puppet/modules/php/manifests/composer/install.pp +++ b/puppet/modules/php/manifests/composer/install.pp @@ -25,6 +25,7 @@ $directory = $title, $vendor_dir = undef, $prefer = 'dist', + $php = '/usr/bin/php5', ) { require ::php::composer @@ -39,7 +40,7 @@ } exec { "composer-install-${safe_dir}": - command => "/usr/local/bin/composer install --optimize-autoloader --prefer-${prefer}", + command => "${php} /usr/local/bin/composer install --optimize-autoloader --prefer-${prefer}", cwd => $directory, environment => [ "COMPOSER_HOME=${::php::composer::home}", diff --git a/puppet/modules/role/manifests/phan.pp b/puppet/modules/role/manifests/phan.pp new file mode 100644 index 0000000..628ebe6 --- /dev/null +++ b/puppet/modules/role/manifests/phan.pp @@ -0,0 +1,32 @@ +# == Class role::phan +# Install etsy/phan static analyzer for php +class role::phan( + $install_dir +) { + require ::role::php7 + + package { 'php-ast': + require => Apt::Ppa['ondrej/php'] + } + + git::clone { 'etsy/phan': + directory => $install_dir, + remote => 'https://github.com/etsy/phan.git', + } + + service::gitupdate { 'etsy/phan': + dir => $install_dir, + type => 'php', + update => true, + } + + php::composer::install { 'etsy/phan': + directory => $install_dir, + php => '/usr/bin/php7.0', + require => [ + Git::Clone['etsy/phan'], + Package['php7.0-cli'], + Package['php-ast'], + ], + } +} diff --git a/puppet/modules/role/manifests/php7.pp b/puppet/modules/role/manifests/php7.pp new file mode 100644 index 0000000..c6956a9 --- /dev/null +++ b/puppet/modules/role/manifests/php7.pp @@ -0,0 +1,25 @@ +# == Class role::php7 +# Install php7 alongside php5 +class role::php7 { + apt::ppa { 'ondrej/php': } + package { [ + 'php7.0', + 'php-apcu-bc', + 'php7.0-cli', + 'php7.0-curl', + 'php7.0-dom', + 'php7.0-dev', + 'php7.0-gd', + 'php7.0-intl', + 'php7.0-json', + 'php7.0-mcrypt', + 'php7.0-mysql', + 'php7.0-readline', + 'php7.0-sqlite3', + 'php7.0-tidy', + 'php-xdebug', + ]: + ensure => present, + require => Apt::Ppa['ondrej/php'] + } +} diff --git a/puppet/modules/service/manifests/gitupdate.pp b/puppet/modules/service/manifests/gitupdate.pp index 485d68e..f6179f4 100644 --- a/puppet/modules/service/manifests/gitupdate.pp +++ b/puppet/modules/service/manifests/gitupdate.pp @@ -94,8 +94,11 @@ fail("Invalid service type ${type} given, valid values are php, nodejs, python") } + # make title safe to use as a filename + $safe_title = regsubst($title, '/' ,'_', 'G') + $srv_dir = $dir ? { - undef => "${::service::root_dir}/${title}", + undef => "${::service::root_dir}/${safe_title}", default => $dir } @@ -119,7 +122,7 @@ default => $service_name, } - file { "${::service::conf_dir}/${title}.conf": + file { "${::service::conf_dir}/${safe_title}.conf": ensure => present, content => template('service/gitupdate.conf.erb'), owner => 'root', -- To view, visit https://gerrit.wikimedia.org/r/315608 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I51dd02c134a9bf6cdf04f2ba20ce428e72d3a2d6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vagrant Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits