conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.22k stars 979 forks source link

[question] Resolve latest compatible set of versions for literal CI/CD #9547

Closed domfellner closed 9 months ago

domfellner commented 3 years ago

Hi all,

I’m about to implement a literal CI/CD pipeline, so every commit (alternatively: every release) of any library should trigger a rebuild of the consumer application. We’re using SemVer and therefore model all requirements with version ranges like libA/[^1.0.0].

What I want to accomplish is that the latest comprehensive set of compatible versions is always used for this integration build. So let’s say, my app1 requires libB and libC which both require libA (so we have a classic diamond). The integration pipeline calls ‘conan create’ on app1, possibly as reference with the lockfile of the triggering package.

My naïve approach was to set app1’s requirements to libB/[*] and libC/[*]. This works as long as all latest versions are compatible (let’s assume all libs are 1.0.0 for now, requiring [^1.0.0] versions respectively). If libA releases a 2.0.0, app1 will still be buildable and ignore the new libA (as no new libB or libC is available), but if libB releases a 2.0.0 (requiring libA/[^2.0.0]), the diamond cannot be resolved any more. As there cannot be a fully integrated version of app1 with the new version (libC/2.0.0 is missing), the integration build will fail with a version conflict which is expected at this point.

When libC releases a 1.1.0 version afterwards, still relying on libA/[^1.0.0], there could be a fully compatible set of packages consisting of libA/1.0.0, libB/1.0.0, libC/1.1.0 and app1/latest. With app1 requiring the latest versions, it will always choose libB/2.0.0 and there is an error, but I want to fall back to the compatible set.

I could adapt app1’s requirements manually for different sets of versions, but following a literal CI/CD approach, this should be resolved automatically.

I’m thinking of some option in the version like

requires = [ 
    “libB/[*, latest_compatible=True]",
    "libC/[*, latest_compatible=True]"
]

which will start with the latest versions and in case there is a conflict will fall back and check the next previous version etc. The order of preference is given in the order of requirements (first requirements shall be downgraded at last). I’m aware that this can be time consuming, but would be an optional feature and I’d be willing to pay for it.

I wonder if some more people have the same use case. Even with lockfiles I couldn’t get this working. Am I missing something?

Thanks a lot for all the good work! Conan is coming to stay.

Regards Dom

domfellner commented 3 years ago

Am I the only one with this use case? Are there some initial thoughts how to approach this?

memsharded commented 3 years ago

Hi @domfellner

Yes, this is a complicated problem, let me summarize some important points:

Please let me know if the above clarifies a bit.

AbrilRBS commented 9 months ago

Closing as answered - While Conan 2 has and likely will introduce improvements over the algorithm, it's not currently expected to implement any kind of complete resolution. Thanks for the question!