Skip to content

Commit

Permalink
fix upload_policy=skip --build=missing issues (#15336)
Browse files Browse the repository at this point in the history
* fix upload_policy=skip --build=missing issues

* review
  • Loading branch information
memsharded authored Dec 26, 2023
1 parent 74557e4 commit 88cd0a6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
5 changes: 2 additions & 3 deletions conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,11 @@ def _process_node(self, node, build_mode, remotes, update):
break

if node.conanfile.upload_policy == "skip":
# Download/update shouldn't be checked in the servers if this is "skip-upload"
# The binary can only be in cache or missing.
if cache_latest_prev:
node.binary = BINARY_CACHE
node.prev = cache_latest_prev.revision
elif build_mode.allowed(node.conanfile):
node.should_build = True
node.binary = BINARY_BUILD
else:
node.binary = BINARY_MISSING
elif cache_latest_prev is None: # This binary does NOT exist in the cache
Expand Down
46 changes: 46 additions & 0 deletions conans/test/integration/command/install/install_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re
import textwrap
from collections import OrderedDict

Expand Down Expand Up @@ -488,6 +489,51 @@ def test_upload_skip_binaries_not_hit_server():
assert "pkg/0.1: Created package" in c.out


def test_upload_skip_build_missing():
c = TestClient(default_server_user=True)
pkg1 = GenConanfile("pkg1", "1.0").with_class_attribute('upload_policy = "skip"')
pkg2 = GenConanfile("pkg2", "1.0").with_requirement("pkg1/1.0", visible=False)
pkg3 = GenConanfile("pkg3", "1.0").with_requirement("pkg2/1.0")
c.save({"pkg1/conanfile.py": pkg1,
"pkg2/conanfile.py": pkg2,
"pkg3/conanfile.py": pkg3,
})
c.run("create pkg1")
c.run("create pkg2")
c.run("remove pkg1/*:* -c") # remove binaries
c.run("create pkg3 --build=missing")
assert re.search(r"Skipped binaries(\s*)pkg1/1.0", c.out)


def test_upload_skip_build_compatibles():
c = TestClient()
pkg1 = textwrap.dedent("""\
from conan import ConanFile
class Pkg1(ConanFile):
name = "pkg1"
version = "1.0"
settings = "build_type"
upload_policy = "skip"
def compatibility(self):
if self.settings.build_type == "Debug":
return [{"settings": [("build_type", "Release")]}]
""")
pkg2 = GenConanfile("pkg2", "1.0").with_requirement("pkg1/1.0")
pkg3 = GenConanfile("pkg3", "1.0").with_requirement("pkg2/1.0")
c.save({"pkg1/conanfile.py": pkg1,
"pkg2/conanfile.py": pkg2,
"pkg3/conanfile.py": pkg3,
})
c.run("create pkg1 -s build_type=Release")
pkg1id = c.created_package_id("pkg1/1.0")
c.run("create pkg2 -s build_type=Release")
c.run("remove pkg1/*:* -c") # remove binaries
c.run("create pkg3 -s build_type=Release --build=missing")
c.assert_listed_binary({"pkg1/1.0": (pkg1id, "Build")})
c.run("install pkg3 -s build_type=Debug --build=missing")
c.assert_listed_binary({"pkg1/1.0": (pkg1id, "Cache")})


def test_install_json_format():
# https://github.com/conan-io/conan/issues/14414
client = TestClient()
Expand Down

0 comments on commit 88cd0a6

Please sign in to comment.