Skip to content

Commit

Permalink
warn if building in cache with editable (#17325)
Browse files Browse the repository at this point in the history
* warn if building in cache with editable

* Update conans/client/graph/graph_binaries.py

* Update test/integration/editable/transitive_editable_test.py

---------

Co-authored-by: Abril Rincón Blanco <git@rinconblanco.es>
  • Loading branch information
memsharded and AbrilRBS authored Nov 20, 2024
1 parent b325a4b commit f3c7aaa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def _evaluate_node(self, node, build_mode, remotes, update):
"didn't enable 'tools.graph:vendor=build' to compute " \
"its dependencies"
node.binary = BINARY_INVALID
if any(n.node.binary in (BINARY_EDITABLE, BINARY_EDITABLE_BUILD)
for n in node.transitive_deps.values()):
conanfile.output.warning("Package is being built in the cache using editable "
"dependencies, this is dangerous", warn_tag="risk")

def _process_node(self, node, build_mode, remotes, update):
# Check that this same reference hasn't already been checked
Expand Down
23 changes: 19 additions & 4 deletions test/integration/editable/transitive_editable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_transitive_editables_half_diamond():
# https://github.com/conan-io/conan/issues/4445
client = TestClient()
client = TestClient(light=True)
client.save({"libc/conanfile.py": GenConanfile("libc", "0.1"),
"libb/conanfile.py": GenConanfile("libb", "0.1").with_require("libc/0.1"),
"liba/conanfile.py": GenConanfile("liba", "0.1").with_requires("libb/0.1",
Expand Down Expand Up @@ -78,7 +78,7 @@ def layout(self):

def test_transitive_editables_python_requires_version_range():
# https://github.com/conan-io/conan/issues/14411
client = TestClient(default_server_user=True)
client = TestClient(default_server_user=True, light=True)
client.save({"dep/conanfile.py": GenConanfile("dep", "0.1"),
"pkg/conanfile.py": GenConanfile("pkg", "0.1").with_python_requires("dep/[*]")})
client.run("editable add pkg", assert_error=True)
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_transitive_editable_cascade_build():
"""
https://github.com/conan-io/conan/issues/15292
"""
c = TestClient()
c = TestClient(light=True)
pkga = GenConanfile("pkga", "1.0").with_package_type("static-library")
pkgb = GenConanfile("pkgb", "1.0").with_requires("pkga/1.0").with_package_type("static-library")
pkgc = GenConanfile("pkgc", "1.0").with_requires("pkgb/1.0").with_package_type("static-library")
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_transitive_editable_cascade_package_id():
"""
https://github.com/conan-io/conan/issues/15292
"""
c = TestClient()
c = TestClient(light=True)
pkga = GenConanfile("pkga", "1.0").with_package_type("static-library")
pkgb = GenConanfile("pkgb", "1.0").with_requires("pkga/1.0").with_package_type("static-library")
pkgc = GenConanfile("pkgc", "1.0").with_requires("pkgb/1.0").with_package_type("shared-library")
Expand Down Expand Up @@ -207,3 +207,18 @@ def test_transitive_editable_cascade_package_id():
# The consumers didn't need a new binary, even if I modified pkg
c.assert_listed_binary({"pkgb/1.0": (pkgb_id, "Cache"),
"pkgc/1.0": (pkgc_id, "Build")})


def test_warning_from_cache():
c = TestClient(light=True)
c.save({"pkga/conanfile.py": GenConanfile("pkga", "1.0"),
"pkgb/conanfile.py": GenConanfile("pkgb", "1.0").with_requires("pkga/1.0"),
"pkgc/conanfile.py": GenConanfile("pkgc", "1.0").with_requires("pkgb/1.0")})
c.run("editable add pkga")
c.run("create pkgb")
assert "pkgb/1.0: WARN: risk: Package is being built in the cache using editable" in c.out
c.run("create pkgc")
assert "pkgc/1.0: WARN: risk: Package is being built in the cache using editable" in c.out
c.run("create pkgc --build=*")
assert "pkgb/1.0: WARN: risk: Package is being built in the cache using editable" in c.out
assert "pkgc/1.0: WARN: risk: Package is being built in the cache using editable" in c.out

0 comments on commit f3c7aaa

Please sign in to comment.