From d1528d7dc6e5edaed1c8fde897eed330e01c5ca8 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 28 Mar 2019 10:49:01 -0300 Subject: [PATCH 1/2] #361 Upload package with revisions - Package reference passed to be created is not the same retrieved from package id when the package is built. "foo/0.1@bar/testing" != "foo/0.1@bar/testing#" Signed-off-by: Uilian Ries --- cpt/runner.py | 2 +- cpt/test/test_client/upload_checks_test.py | 27 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cpt/runner.py b/cpt/runner.py index e8ef1c95..2036f682 100644 --- a/cpt/runner.py +++ b/cpt/runner.py @@ -113,7 +113,7 @@ def run(self): return for installed in r['installed']: reference = installed["recipe"]["id"] - if ((reference == str(self._reference)) or \ + if ((str(self._reference) in reference) or \ (reference in self._upload_dependencies) or \ ("all" in self._upload_dependencies)) and \ installed['packages']: diff --git a/cpt/test/test_client/upload_checks_test.py b/cpt/test/test_client/upload_checks_test.py index 9d354485..e1faa05b 100644 --- a/cpt/test/test_client/upload_checks_test.py +++ b/cpt/test/test_client/upload_checks_test.py @@ -110,7 +110,7 @@ def test_upload_only_recipe_env_var(self): # Upload only the recipe with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user", "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user", - "CONAN_UPLOAD_ONLY_RECIPE": "TRUE"}): + "CONAN_UPLOAD_ONLY_RECIPE": "TRUE", "CONAN_CHANNEL": "mychannel"}): mulitpackager = get_patched_multipackager(tc, exclude_vcvars_precommand=True) mulitpackager.add({}, {"shared": True}) mulitpackager.add({}, {"shared": False}) @@ -125,7 +125,7 @@ def test_upload_only_recipe_env_var(self): # Re-use cache the upload the binary packages with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user", "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user", - "CONAN_UPLOAD_ONLY_RECIPE": "FALSE"}): + "CONAN_UPLOAD_ONLY_RECIPE": "FALSE", "CONAN_CHANNEL": "mychannel"}): mulitpackager = get_patched_multipackager(tc, exclude_vcvars_precommand=True) mulitpackager.add({}, {"shared": True}) mulitpackager.add({}, {"shared": False}) @@ -144,7 +144,8 @@ def test_upload_only_recipe_params(self): # Upload only the recipe with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user", - "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user"}): + "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user", + "CONAN_CHANNEL": "mychannel"}): mulitpackager = get_patched_multipackager(tc, exclude_vcvars_precommand=True, upload_only_recipe=True) mulitpackager.add({}, {"shared": True}) @@ -159,7 +160,8 @@ def test_upload_only_recipe_params(self): # Re-use cache the upload the binary packages with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user", - "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user"}): + "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user", + "CONAN_CHANNEL": "mychannel"}): mulitpackager = get_patched_multipackager(tc, exclude_vcvars_precommand=True, upload_only_recipe=False) mulitpackager.add({}, {"shared": True}) @@ -172,6 +174,23 @@ def test_upload_only_recipe_params(self): self.assertIn("Uploading package 1/2", tc.out) self.assertIn("Uploading package 2/2", tc.out) + def test_upload_package_revisions(self): + ts = TestServer(users={"user": "password"}) + tc = TestClient(servers={"default": ts}, users={"default": [("user", "password")]}) + tc.save({"conanfile.py": self.conanfile}) + with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user", + "CONAN_PASSWORD": "password", "CONAN_USERNAME": "user", + "CONAN_REVISIONS_ENABLED": "1"}): + mulitpackager = get_patched_multipackager(tc, exclude_vcvars_precommand=True) + mulitpackager.add({}, {"shared": True}) + mulitpackager.add({}, {"shared": False}) + mulitpackager.run() + self.assertNotIn("Skipping upload for 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9", tc.out) + self.assertNotIn("Skipping upload for 2a623e3082a38f90cd2c3d12081161412de331b0", tc.out) + self.assertIn("Uploading package 1/2", tc.out) + self.assertIn("Uploading package 2/2", tc.out) + self.assertIn("HALLO", tc.out) + class UploadDependenciesTest(unittest.TestCase): conanfile_bar = """from conans import ConanFile From 49843aa84add1667d5e6a7702704f99f19281b96 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 28 Mar 2019 11:26:28 -0300 Subject: [PATCH 2/2] #361 Parse revision Signed-off-by: Uilian Ries --- cpt/runner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpt/runner.py b/cpt/runner.py index 2036f682..0ff6e998 100644 --- a/cpt/runner.py +++ b/cpt/runner.py @@ -4,6 +4,7 @@ from conans import tools, __version__ as client_version from conans.model.version import Version +from conans.model.ref import ConanFileReference from cpt import __version__ as package_tools_version from cpt.config import ConfigManager @@ -113,7 +114,9 @@ def run(self): return for installed in r['installed']: reference = installed["recipe"]["id"] - if ((str(self._reference) in reference) or \ + if client_version >= Version("1.10.0"): + reference = str(ConanFileReference.loads(installed["recipe"]["id"]).copy_clear_rev()) + if ((reference == str(self._reference)) or \ (reference in self._upload_dependencies) or \ ("all" in self._upload_dependencies)) and \ installed['packages']: