← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilasc/launchpad:publisher-excludes-conda-source-pkgs into launchpad:master

 

Ioana Lasc has proposed merging ~ilasc/launchpad:publisher-excludes-conda-source-pkgs into launchpad:master.

Commit message:
Publisher skips Conda source packages

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/432957
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:publisher-excludes-conda-source-pkgs into launchpad:master.
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index b4611ac..426a765 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -54,6 +54,7 @@ from lp.services.webapp.errorlog import ErrorReportingUtility, ScriptRequest
 from lp.services.worlddata.model.country import Country
 from lp.soyuz.adapters.proxiedsourcefiles import ProxiedSourceLibraryFileAlias
 from lp.soyuz.enums import (
+    ArchiveRepositoryFormat,
     BinaryPackageFormat,
     PackagePublishingPriority,
     PackagePublishingStatus,
@@ -67,6 +68,7 @@ from lp.soyuz.interfaces.component import IComponentSet
 from lp.soyuz.interfaces.distributionjob import (
     IDistroSeriesDifferenceJobSource,
 )
+from lp.soyuz.interfaces.files import ISourcePackageReleaseFile
 from lp.soyuz.interfaces.publishing import (
     DeletionError,
     IBinaryPackagePublishingHistory,
@@ -152,6 +154,12 @@ class ArchivePublisherBase:
         """See `IPublishing`"""
         try:
             for pub_file in self.files:
+                if (
+                    self.archive.repository_format
+                    == ArchiveRepositoryFormat.CONDA
+                    and ISourcePackageReleaseFile.providedBy(pub_file)
+                ):
+                    continue
                 pool_name = self.pool_name
                 pool_version = self.pool_version
                 component = (
diff --git a/lib/lp/soyuz/tests/test_publishing.py b/lib/lp/soyuz/tests/test_publishing.py
index ff6e308..3bb6467 100644
--- a/lib/lp/soyuz/tests/test_publishing.py
+++ b/lib/lp/soyuz/tests/test_publishing.py
@@ -10,6 +10,7 @@ import os
 import shutil
 import tempfile
 from functools import partial
+from unittest import mock
 
 import pytz
 import transaction
@@ -19,6 +20,7 @@ from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 
 from lp.app.errors import NotFoundError
+from lp.archivepublisher.artifactory import ArtifactoryPool
 from lp.archivepublisher.config import getPubConfig
 from lp.archivepublisher.diskpool import DiskPool
 from lp.archivepublisher.indices import (
@@ -43,7 +45,7 @@ from lp.services.channels import channel_string_to_list
 from lp.services.config import config
 from lp.services.database.constants import UTC_NOW
 from lp.services.librarian.interfaces import ILibraryFileAliasSet
-from lp.services.log.logger import DevNullLogger
+from lp.services.log.logger import BufferLogger, DevNullLogger
 from lp.soyuz.enums import (
     ArchivePublishingMethod,
     ArchivePurpose,
@@ -874,6 +876,28 @@ class TestNativePublishing(TestNativePublishingBase):
         pool_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
         self.assertEqual(open(pool_path).read().strip(), "Hello world")
 
+    @mock.patch.object(ArtifactoryPool, "addFile")
+    def test_publish_conda_source(self, mock):
+        root_url = "%s/%s" % (
+            "https://foo.example.com/artifactory";,
+            "repository",
+        )
+        archive = self.factory.makeArchive(
+            purpose=ArchivePurpose.PPA,
+            repository_format=ArchiveRepositoryFormat.CONDA,
+        )
+        pool = ArtifactoryPool(archive, root_url, BufferLogger())
+        # The getPubSource helper here constructs the chain obljects we
+        # need to be able to return a SourcePackagePublishingHistory object.
+        pub_source = self.getPubSource(
+            filecontent=b"Hello world",
+            archive=archive,
+            format=SourcePackageType.CI_BUILD,
+            user_defined_fields=[("bogus_filed", "instead_of_subdir")],
+        )
+        pub_source.publish(pool, self.logger)
+        self.assertFalse(mock.called)
+
     def test_publish_binaries(self):
         # Binary publications result in a PUBLISHED publishing record and
         # the corresponding files are dumped in the disk pool/.