From: Tom Hughes Date: Wed, 28 Aug 2019 17:36:23 +0000 (+0100) Subject: Use composer to install libraries for mediawiki X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/3535055f669970b9991c63487c27b9fe382a8c60 Use composer to install libraries for mediawiki --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 07772bacd..3002b6a10 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,7 +13,7 @@ Metrics/AbcSize: # Offense count: 27 # Configuration parameters: CountComments. Metrics/BlockLength: - Max: 369 + Max: 372 Metrics/BlockNesting: Max: 4 diff --git a/cookbooks/mediawiki/resources/extension.rb b/cookbooks/mediawiki/resources/extension.rb index 1803c04f0..ad1472c12 100644 --- a/cookbooks/mediawiki/resources/extension.rb +++ b/cookbooks/mediawiki/resources/extension.rb @@ -29,7 +29,6 @@ property :version, :kind_of => String property :repository, :kind_of => String property :tag, :kind_of => String property :reference, :kind_of => String -property :compose, :kind_of => [TrueClass, FalseClass], :default => false property :update_site, :kind_of => [TrueClass, FalseClass], :default => true action :create do @@ -83,15 +82,14 @@ action :create do end end - if new_resource.compose # ~FC023 - execute "composer-#{new_resource.extension}" do - action :nothing - command "composer install --no-dev" - cwd extension_directory - user node[:mediawiki][:user] - group node[:mediawiki][:group] - subscribes :run, "git[#{extension_directory}]" - end + execute "#{extension_directory}/composer.json" do + action :nothing + command "composer update --no-dev" + cwd mediawiki_directory + user node[:mediawiki][:user] + group node[:mediawiki][:group] + only_if { ::File.exist?("#{extension_directory}/composer.json") } + subscribes :run, "git[#{extension_directory}]" end end diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index a3a7bc741..e24d25353 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -105,25 +105,33 @@ action :create do mediawiki_reference = "REL#{new_resource.version}".tr(".", "_") - git "#{mediawiki_directory}/vendor" do - action :nothing - repository "https://gerrit.wikimedia.org/r/p/mediawiki/vendor.git" - revision mediawiki_reference - user node[:mediawiki][:user] - group node[:mediawiki][:group] - end - git mediawiki_directory do action :sync repository "https://gerrit.wikimedia.org/r/p/mediawiki/core.git" revision mediawiki_reference user node[:mediawiki][:user] group node[:mediawiki][:group] - notifies :sync, "git[#{mediawiki_directory}/vendor]", :immediately + notifies :run, "execute[#{mediawiki_directory}/composer.json]", :immediately notifies :run, "execute[#{mediawiki_directory}/maintenance/install.php]", :immediately notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]" end + execute "#{mediawiki_directory}/composer.json" do + action :nothing + command "composer update --no-dev" + cwd mediawiki_directory + user node[:mediawiki][:user] + group node[:mediawiki][:group] + end + + template "#{mediawiki_directory}/composer.local.json" do + cookbook "mediawiki" + source "composer.local.json.erb" + owner node[:mediawiki][:user] + group node[:mediawiki][:group] + mode 0o664 + end + # Safety catch if git doesn't update but install.php hasn't run ruby_block "catch-installer-localsettings-run" do action :run @@ -376,14 +384,12 @@ action :create do mediawiki_extension "AntiSpoof" do site new_resource.site template "mw-ext-AntiSpoof.inc.php.erb" - compose true update_site false end mediawiki_extension "AbuseFilter" do site new_resource.site template "mw-ext-AbuseFilter.inc.php.erb" - compose true update_site false end @@ -400,13 +406,11 @@ action :create do mediawiki_extension "Elastica" do site new_resource.site - compose true update_site false end mediawiki_extension "CirrusSearch" do site new_resource.site - compose true template "mw-ext-CirrusSearch.inc.php.erb" update_site false end diff --git a/cookbooks/mediawiki/templates/default/composer.local.json.erb b/cookbooks/mediawiki/templates/default/composer.local.json.erb new file mode 100644 index 000000000..c4b7a053f --- /dev/null +++ b/cookbooks/mediawiki/templates/default/composer.local.json.erb @@ -0,0 +1,10 @@ +{ + "extra": { + "merge-plugin": { + "include": [ + "extensions/*/composer.json", + "skins/*/composer.json" + ] + } + } +} diff --git a/cookbooks/wiki/recipes/default.rb b/cookbooks/wiki/recipes/default.rb index c657bb706..3d8da434d 100644 --- a/cookbooks/wiki/recipes/default.rb +++ b/cookbooks/wiki/recipes/default.rb @@ -72,7 +72,6 @@ end mediawiki_extension "Wikibase" do site "wiki.openstreetmap.org" - compose true template "mw-ext-Wikibase.inc.php.erb" template_cookbook "wiki" end