channel = os.getenv("CONAN_CHANNEL", "testing") username = os.getenv("CONAN_USERNAME", "balashovartem") current_page = os.getenv("CONAN_CURRENT_PAGE", "1") total_pages = os.getenv("CONAN_TOTAL_PAGES", "1") gcc_versions = os.getenv("CONAN_GCC_VERSIONS", None) gcc_versions = gcc_versions.split(",") if gcc_versions else None use_docker = os.getenv("CONAN_USE_DOCKER", False) upload = os.getenv("CONAN_UPLOAD", False) reference = os.getenv("CONAN_REFERENCE") password = os.getenv("CONAN_PASSWORD") travis = os.getenv("TRAVIS", False) travis_branch = os.getenv("TRAVIS_BRANCH", None) appveyor = os.getenv("APPVEYOR", False) appveyor_branch = os.getenv("APPVEYOR_REPO_BRANCH", None) channel = "stable" if travis and travis_branch=="master" else channel channel = "stable" if appveyor and appveyor_branch=="master" and not os.getenv("APPVEYOR_PULL_REQUEST_NUMBER") else channel os.environ["CONAN_CHANNEL"] = channel # Override the environment value for test/conanfile.py file args = " ".join(sys.argv[1:]) builder = ConanMultiPackager(args, username, channel) builder.add_common_builds(shared_option_name="sqlite3:shared", visual_versions=[10, 12, 14]) print(builder.builds) if use_docker: builder.docker_pack(current_page, total_pages, gcc_versions) else: builder.pack(current_page, total_pages) if upload and reference and password: builder.upload_packages(reference, password)
class AppTest(unittest.TestCase): def setUp(self): self.runner = MockRunner() self.packager = ConanMultiPackager("--build missing -r conan.io", "lasote", "mychannel", runner=self.runner) def testSerialize(self): self.packager.add({"os": "Windows", "compiler": "Visual Studio"}, {"option1": "value1", "option2": "value2"}) serial = self.packager.serialize() self.assertEquals(serial, '{"username": "******", "conan_pip_package": null, "args": "--build missing -r conan.io", '\ '"builds": [[{"os": "Windows", "compiler": "Visual Studio"}, '\ '{"option2": "value2", "option1": "value1"}]], "channel": "mychannel"}') mp = ConanMultiPackager.deserialize(serial, username="******") self.assertEqual(mp.conan_pip_package, None) self.packager.conan_pip_package = "conan==0.0.1rc7" serial = self.packager.serialize() mp = ConanMultiPackager.deserialize(serial, username="******") self.assertEqual(mp.conan_pip_package, "conan==0.0.1rc7") def _add_build(self, number): self.packager.add({"os": "os%d" % number, "compiler": "os%d" % number}, {"option%d" % number: "value%d" % number, "option%d" % number: "value%d" % number}) def testPages(self): for number in xrange(10): self._add_build(number) # 10 pages, 1 per build self.packager.pack(1, 10) self.assertTrue(self.runner.tests_for([0])) # 2 pages, 5 per build self.runner.reset() self.packager.pack(1, 2) self.assertTrue(self.runner.tests_for([0, 2, 4, 6, 8])) self.runner.reset() self.packager.pack(2, 2) self.assertTrue(self.runner.tests_for([1, 3, 5, 7, 9])) # 3 pages, 4 builds in page 1 and 3 in the rest of pages self.runner.reset() self.packager.pack(1, 3) self.assertTrue(self.runner.tests_for([0, 3, 6, 9])) self.runner.reset() self.packager.pack(2, 3) self.assertTrue(self.runner.tests_for([1, 4, 7])) self.runner.reset() self.packager.pack(3, 3) self.assertTrue(self.runner.tests_for([2, 5, 8])) def testDocker(self): self.packager.docker_pack(1, 2, ["4.3", "5.2"]) self.assertIn("sudo docker pull lasote/conangcc43", self.runner.calls[0]) self.assertIn("-e CONAN_CURRENT_PAGE=1 -e CONAN_TOTAL_PAGES=2 ", self.runner.calls[1]) self.assertIn('-e CONAN_BUILDER_ENCODED=\'{"username": "******"', self.runner.calls[1]) self.assertIn('-e CONAN_USERNAME=lasote -e CONAN_CHANNEL=mychannel', self.runner.calls[1])
gcc_versions = gcc_versions.split(",") if gcc_versions else None use_docker = os.getenv("CONAN_USE_DOCKER", False) upload = os.getenv("CONAN_UPLOAD", False) reference = os.getenv("CONAN_REFERENCE") password = os.getenv("CONAN_PASSWORD") travis = os.getenv("TRAVIS", False) travis_branch = os.getenv("TRAVIS_BRANCH", None) appveyor = os.getenv("APPVEYOR", False) appveyor_branch = os.getenv("APPVEYOR_REPO_BRANCH", None) channel = "stable" if travis and travis_branch == "master" else channel channel = ( "stable" if appveyor and appveyor_branch == "master" and not os.getenv("APPVEYOR_PULL_REQUEST_NUMBER") else channel ) os.environ["CONAN_CHANNEL"] = channel # Override the environment value for test/conanfile.py file args = " ".join(sys.argv[1:]) builder = ConanMultiPackager(args, username, channel) builder.add_common_builds(visual_versions=[10, 12, 14]) print(builder.builds) if use_docker: builder.docker_pack(current_page, total_pages, gcc_versions) else: builder.pack(current_page, total_pages) if upload and reference and password: builder.upload_packages(reference, password)