conan-io / conan

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

[question] Run code analysis, test and generate documentation in separate steps #10019

Open paostman opened 2 years ago

paostman commented 2 years ago

Hi.

In our project we want to run static code analysis, generate documentation and run unit tests separated from building the program binaries.

What would be the best way to do this?

I have come up with adding an option for this. In the option you can for example specify that documentation shall be created. If option is left out the default is binary. The artifacts will when be in separate packages. Is the way to do it or do they exist any better ways in Conan to do this?

We would like to execute the above in parallel. Conan is however not thread safe but believe that is related to cache activities. Would it be possible to execute in parallel by creating separate lock files and then run “conan build” in parallel and then builds are finished export the packages. Could “conan create” work in this case? Conan create writes to the cache but the parallel builds will be packaged into separate packages.

BR Patrik

memsharded commented 2 years ago

Hi @paostman

You mean, you would like a fast conan create that just builds the binary, but doesn't do all the other steps? Then, like in a separate process, maybe at different time do something like conan create --docs or conan create --analysis?

An important question here is that if the resulting artifacts of those builds also needs to be stored as Conan packages (I guess you want to store the docs somewhere, but not sure if inside the Conan package or elsewhere). If the answer is yes, then I think the options approach sounds good. You can control the build and the package artifacts very easily with an option, everything is modeled and explicit.

One thing that is not clear is how to separate the unittests from the actual build of the library, because that would introduce a dependency, or would require a repeated build of the same thing that was built before. What is your idea about this?

Also, what is the reason you want to separate this. If at the end you have to perform all these tasks, wouldn't it be more efficient and simple to build them all while building the package?

A completely different story is the cache concurrency. Indeed, the cache is not concurrent in the general case. Typically, building different variants of the same package might be possible if you take some previous steps (like doing an export first, then conan install --build instead of create to avoid race conditions over the recipe export). But the general rule for CI jobs running in parallel is that each one should be running in its own CONAN_USER_HOME to avoid collisions.