[MediaWiki-commits] [Gerrit] Add script to create a composer.local.json based on a list o... - change (integration/jenkins)
Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/192177 Change subject: Add script to create a composer.local.json based on a list of extensions .. Add script to create a composer.local.json based on a list of extensions Change-Id: Id321bdb91e844d14275eac6a5f21a643ea283199 --- A bin/mw-create-composer-local.py A tests/test_mw-create-composer-local.py 2 files changed, 67 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins refs/changes/77/192177/1 diff --git a/bin/mw-create-composer-local.py b/bin/mw-create-composer-local.py new file mode 100755 index 000..b4d3958 --- /dev/null +++ b/bin/mw-create-composer-local.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +from __future__ import print_function +""" +Creates a composer.local.json file for the +composer-merge-plugin to read based on a list +of provided extensions. + +Usage: mw-create-composer-local.py extension_list.txt src/composer.local.json + +""" + +import json +import sys + + +def main(extlist_path, composerlocal_path): +with open(extlist_path) as f: +extensions = [ext.strip()[len('mediawiki/'):] + for ext in f.read().splitlines() + if ext.strip().startswith('mediawiki/extensions/')] + +out = { +'extra': { +'merge-plugin': { +'include': extensions +} +} +} + +with open(composerlocal_path, 'w') as f: +json.dump(out, f) + +print('Created composer.local.json.') + +if __name__ == '__main__': +if len(sys.argv) != 3: +print('Invalid number of arguments provided') +sys.exit(1) +main(sys.argv[1], sys.argv[2]) diff --git a/tests/test_mw-create-composer-local.py b/tests/test_mw-create-composer-local.py new file mode 100644 index 000..a3ab003 --- /dev/null +++ b/tests/test_mw-create-composer-local.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import imp +import os +import tempfile +import unittest +path = os.path.dirname(os.path.dirname(__file__)) \ + + '/bin/mw-create-composer-local.py' +mw_create_composer_local = imp.load_source('mw-create-composer-local', path) + + +class TestMwCreateComposerLocal(unittest.TestCase): +def test_main(self): +_, el_path = tempfile.mkstemp() +with open(el_path, 'w') as f: +f.write(""" +mediawiki/extensions/FooBar +mediawiki/extensions/BarFoo + +mediawiki/extensions/BazFoo +""".strip()) +_, clocal_path = tempfile.mkstemp() +mw_create_composer_local.main(el_path, clocal_path) +self.assertEqual( +open(clocal_path).read(), +'{"extra": {"merge-plugin": {"include": ["extensions/FooBar", ' +'"extensions/BarFoo", "extensions/BazFoo"]}}}' +) -- To view, visit https://gerrit.wikimedia.org/r/192177 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id321bdb91e844d14275eac6a5f21a643ea283199 Gerrit-PatchSet: 1 Gerrit-Project: integration/jenkins Gerrit-Branch: master Gerrit-Owner: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add script to create a composer.local.json based on a list o... - change (integration/jenkins)
jenkins-bot has submitted this change and it was merged. Change subject: Add script to create a composer.local.json based on a list of extensions .. Add script to create a composer.local.json based on a list of extensions Change-Id: Id321bdb91e844d14275eac6a5f21a643ea283199 --- A bin/mw-create-composer-local.py A tests/test_mw-create-composer-local.py 2 files changed, 69 insertions(+), 0 deletions(-) Approvals: JanZerebecki: Looks good to me, approved jenkins-bot: Verified diff --git a/bin/mw-create-composer-local.py b/bin/mw-create-composer-local.py new file mode 100755 index 000..fd63709 --- /dev/null +++ b/bin/mw-create-composer-local.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +from __future__ import print_function +""" +Creates a composer.local.json file for the +composer-merge-plugin to read based on a list +of provided extensions. + +Usage: mw-create-composer-local.py extension_list.txt src/composer.local.json + +""" + +import json +import sys + + +def main(extlist_path, composerlocal_path): +with open(extlist_path) as f: +extensions = [ext.strip()[len('mediawiki/'):] + '/composer.json' + for ext in f.read().splitlines() + if ext.strip().startswith('mediawiki/extensions/')] + +out = { +'extra': { +'merge-plugin': { +'include': extensions +} +} +} + +with open(composerlocal_path, 'w') as f: +json.dump(out, f) + +print('Created composer.local.json.') + +if __name__ == '__main__': +if len(sys.argv) != 3: +print('Invalid number of arguments provided') +sys.exit(1) +main(sys.argv[1], sys.argv[2]) diff --git a/tests/test_mw-create-composer-local.py b/tests/test_mw-create-composer-local.py new file mode 100644 index 000..dbce092 --- /dev/null +++ b/tests/test_mw-create-composer-local.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import imp +import os +import tempfile +import unittest +path = os.path.dirname(os.path.dirname(__file__)) \ ++ '/bin/mw-create-composer-local.py' +mw_create_composer_local = imp.load_source('mw-create-composer-local', path) + + +class TestMwCreateComposerLocal(unittest.TestCase): +def test_main(self): +_, el_path = tempfile.mkstemp() +with open(el_path, 'w') as f: +f.write(""" +mediawiki/extensions/FooBar +mediawiki/extensions/BarFoo + +mediawiki/extensions/BazFoo +""".strip()) +_, clocal_path = tempfile.mkstemp() +mw_create_composer_local.main(el_path, clocal_path) +self.assertEqual( +open(clocal_path).read(), +'{"extra": {"merge-plugin": {"include": ["extensions/FooBar/compos' +'er.json", "extensions/BarFoo/composer.json", "extensions/BazFoo/c' +'omposer.json"]}}}' +) +os.unlink(clocal_path) -- To view, visit https://gerrit.wikimedia.org/r/192177 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id321bdb91e844d14275eac6a5f21a643ea283199 Gerrit-PatchSet: 5 Gerrit-Project: integration/jenkins Gerrit-Branch: master Gerrit-Owner: Legoktm Gerrit-Reviewer: JanZerebecki Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits