conan-io / conan

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

[question]Git.tools will the feature stay in 2.0? #12630

Closed maitrey closed 1 year ago

maitrey commented 1 year ago

Dear Conan Folks,

I saw the documentation of git tools. https://docs.conan.io/en/latest/reference/tools.html#tools-git Is it supposed to stay in Conan-2.0 ? Asking as https://docs.conan.io/en/1.46/reference/conanfile/tools/scm/git.html says that: This example is the new way to implement the scm feature (to be removed in Conan 2.0), using this new Git capabilities.

Which is the correct way to proceed? My use-case is I want package versions automatically set when using locally and in CI/CD. Also, in order to use the git tools feature do I need to change my branching concept ? At the moment , it allows only alphabets, numbers , dash and underscore. My branching concept allows feature/, hotfix/, bugfix/, release/. Thanks for helping out.

memsharded commented 1 year ago

Hi @maitrey

They are very similar, but they are not the same. The one that will stay in 2.0 is https://docs.conan.io/en/latest/reference/conanfile/tools.html

Always check the import, the valid ones are from conan.tools.xxx, like from conan.tools.scm import Git. The invalid ones that are removed are from conans.tools import Git

maitrey commented 1 year ago

So, I donot see the methods in from conan.tools.scm import Git : get_branch(): Gets the current branch. get_tag(): Gets the current checkout tag (git describe --exact-match --tags) and returns None if not in a tag. I think I would have to use run() instead with git commands.

memsharded commented 1 year ago

Yes, you can do git.run("describe --exact-match --tags") to get it. In the new helper we are not trying to provide a method for every case, if they are correctly supported by a git.run(), and only the very basic ones are provided.

maitrey commented 1 year ago

If I use the method export as mentioned in the documentation the version is not getting set. I have to use set_version method in order to define the version. Please let me know if set_version is meant to stay in Conan2.x.

memsharded commented 1 year ago

set_version() stays in 2.0, yes.

maitrey commented 1 year ago

Also one more question with respect to automatic versions. My plan for package versions is:

My question is:

memsharded commented 1 year ago

Conan accept relaxed semantic versioning (1, and 1.0 are valid) and Conan 2.0 will accept extended semantic versioning, with more than 3 digits too.

Conan 2.0 will also allow first version parts to be strings, and order will be alphabetical.

Regarding your proposed versioning scheme, that highly depends on the needs. If feature branches are not named with something that is compatible with declared version ranges, then it becomes very problematic to test those packages, because it requires to modify consumer recipes to point to that specific branch name, there is no version range that can automatically fullfill that. The alternative is using multiple repos (like using a "features" server repo) and lockfiles (it will be easier in 2.0 than now in 1.X, which is complicated)

maitrey commented 1 year ago

Understood .. so basically recommendation is to use: one conan repo for feature branch/PR and another for tags. In that case, feature branch will get the version as 0.0.0-dev. in jenkins. And for local use-cases stay as 0.0.0-dev.0.

memsharded commented 1 year ago

Understood .. so basically recommendation is to use: one conan repo for feature branch/PR and another for tags. In that case, feature branch will get the version as 0.0.0-dev. in jenkins. And for local use-cases stay as 0.0.0-dev.0.

Yes, that would be something typical. But it is true that implementing it robustly against parallel development (multiple devs doing multiple PRs simultaneous over different packages belonging to the same product), might be a bit challenging with lockfiles in 1.X. Hopefully this will be greatly simplified in 2.0, and can be "standardized" as a good practice a bit more.

maitrey commented 1 year ago

Hi @memsharded ,

I run into some issues while I did implement 2 different repositories : One for tag builds and another one to handle branch/PR builds. When I run a jenkins pipeline it somehow doesnot find packages from branches/PR repos. It fails with the following message: ERROR: <!doctype html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=importmap-type content=systemjs-importmap><link rel=apple-touch-icon sizes=180x180 href=./apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=./favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=./favicon-16x16.png><link rel=mask-icon href=./safari-pinned-tab.svg color=#f5f5f2><link rel="shortcut icon" href=./favicon.ico><link rel=stylesheet type=text/css href=/ui/webapp/css/vendorStyles.css><link rel=stylesheet type=text/css href=/ui/webapp/css/application.css><script type=systemjs-importmap src=/ui/imports-map/imports.json></script><script src=/ui/externals/import-map-overrides/dist/import-map-overrides.js></script><script src=/ui/externals/systemjs/dist/s.min.js></script><script src=/ui/externals/systemjs/dist/extras/amd.min.js></script><script src=/ui/externals/systemjs/dist/extras/named-exports.min.js></script><link rel=preload href=/ui/externals/vue/dist/vue.min.js as=script><link rel=preload href=/ui/externals/vue-router/dist/vue-router.min.js as=script><link rel=preload href=/ui/externals/jfrog-ui-essentials/dist/jfrog-ui-essentials.umd.min.js as=script><link rel=preload href=/ui/externals/single-spa/lib/umd/single-spa.min.js as=script><base href=/ui/ ><title>JFrog</title><style>@keyframes heartbeatOut{from{opacity:1}50%{opacity:0;transform:scale(.8)}to{opacity:0;transform:scale(.8)}}@keyframes heartbeat{from{transform:scale3d(1,1,1)}50%{transform:scale3d(1.15,1.15,1.15)}to{transform:scale3d(1,1,1)}}.pounding-heart-container{display:none;align-items:center;justify-content:center;position:absolute;left:0;right:0;top:0;bottom:0;z-index:9999999999;background:linear-gradient(132.49deg,#414857 14.17%,#252831 83.36%)}.pounding-heart-container.show-splash{display:flex}.logo{width:130px;-webkit-backface-visibility:hidden;-ms-transform:translateZ(0);-webkit-transform:translateZ(0);transform:translateZ(0)}.logo.pulse{animation:heartbeat 1.7s infinite}.logo.zoom-out{animation:heartbeatOut 150ms forwards}</style><link href=/ui/css/app.4de23844.css rel=preload as=style><link href=/ui/css/chunk-vendors.cee239a1.css rel=preload as=style><link href=/ui/js/app.6fc3b8f2.js rel=preload as=script><link href=/ui/js/chunk-vendors.875331ae.js rel=preload as=script><link href=/ui/js/preloader.31ea7863.js rel=preload as=script><link href=/ui/css/chunk-vendors.cee239a1.css rel=stylesheet><link href=/ui/css/app.4de23844.css rel=stylesheet></head><body><div class="pounding-heart-container show-splash"><img class="logo pulse" src=/ui/img/jfrog.8f770bff.svg></div><noscript><strong>We're sorry but jfrog webapp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/ui/js/chunk-vendors.875331ae.js></script><script src=/ui/js/app.6fc3b8f2.js></script><script src=/ui/js/preloader.31ea7863.js></script></body></html> 14:42:58 14:42:58 Response from remote is not json, but 'text/html; charset=UTF-8' It is not very intuitive what exactly I am missing. I hope conan can fetch from 2 different remotes.

memsharded commented 1 year ago

Hi @maitrey

It seems you didn't add the right remote URL to conan remote add, but you used the WebUI URL, instead of the API URL. If you are using Artifactory, you need to get that from the SetMeUp button. Can you please share the result of conan remote list, and check that?

maitrey commented 1 year ago

Hi @memsharded ,

Silly mistake yes you are absolutely right. The remote URL was not configured correctly, I needed to use the api url.

memsharded commented 1 year ago

Good!

Is this question responded then? Maybe we can close it? Thanks!

maitrey commented 1 year ago

Ah not yet.. Hopefully this is the last one. I have two conan repositories now : one for releases and one for branch/PR . For my test-case, One use-case is that I am building a release which depends on a package build from a branch. But conan is unable to download packages from branch/PR repo. Do I need to specify somewhere to search in all remotes?

memsharded commented 1 year ago

One use-case is that I am building a release which depends on a package build from a branch.

But that doesn't look right? You mean packages from the release repo eventually depending on packages on the branch repo? I think it should only be allowed in the other direction. Am I missing something here?

In any case, yes, Conan is able to download packages from multiple remotes, that shouldn't be an issue. In Conan 1.X, a downloaded recipe might get associated and maintain the connection to the remote repo it was downloaded from, and expect its binaries to come from there. But if the recipe is in the other repo, it should work fine. It would be needed more details to reproduce.

maitrey commented 1 year ago

I found out the root cause of the issue : conan_cmd = "conan create . " + user_channel + " -pr:b=default -pr:h="+variant + " -r" + remote The remote was specified to release repo and perhaps therefore it could not find the packages from the branch/PR repo. Now it can find them. Thank You! You can close the issue. I have some issues with uploading the package but i will open another issue if needed. Many Thanks!

memsharded commented 1 year ago

Great, thanks!