Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Creating a lockfile for a test package #8669

Closed
1 task done
spoofedex opened this issue Mar 18, 2021 · 4 comments
Closed
1 task done

[question] Creating a lockfile for a test package #8669

spoofedex opened this issue Mar 18, 2021 · 4 comments
Milestone

Comments

@spoofedex
Copy link

Hi all,

When building binary packages, we upload them to a private Artifactory server. To do so, we use lockfiles, fetch the build-order, and build/upload each package that requires building.

We have some packages where the test package has some requirements additional to the tested package. When using "conan test" we could pass "--build missing", but then we can't (easily) upload the packages that were built. So we'd like to use lockfiles with test packages as well, which seems to be supported by "conan test", according to its documentation (it has an input and output lockfile).

It seems that we can't just specify an output lockfile for the test package: we need an initial input lockfile. This raises the question: how do we create that lockfile? For regular packages we use "conan lock create", but using this for test packages the lockfile lacks the tested package (as its dependency on the tested package is implicit), which causes errors because the tested package isn't part of the lockfile.

Is there some way to create this lockfile for the test package?

Thanks in advance!

Best regards,
SpoofedEx

@fanselm
Copy link

fanselm commented Jul 5, 2022

We're having same problem now.

We create a lockfile from our main products conanfile.txt and then we want to pass this to conan test, but if the test package's conanfile.py specifies build_requires that aren't used in the main product then it fails with <REF> ID <ID> not in lockfile. It would be nice if the build_requirements of the test package were simply ignored when conan test resolved dependencies from the lockfile.

@memsharded memsharded added this to the 2.0 milestone Jul 5, 2022
@memsharded
Copy link
Member

Hi all,

This has been solved in Conan 2.0, which much simplified and powerful lockfiles:

  • test_package will not fail if it doesn't find things in the lockfile (non-strict mode)
  • Things can be manually added to the lockfiles
  • Lockfiles can be merged

Please have a look at https://docs.conan.io/en/2.0/tutorial/consuming_packages/intro_to_versioning.html#lockfiles, and conan-io/tribe#34, testing and feedback very welcome!

@fanselm
Copy link

fanselm commented Jul 6, 2022

That sounds great. We'll make a temporary workaround and add it to the list of things we need to improve when we change to Conan 2.0

@memsharded
Copy link
Member

We have added explicit tests for this in 2.0:

, to cover the different potential flows:

Approach 1

Incrementally capture the main lock and the test_package lock

$ conan lock create .  #  the main grpah only
# now append the test_package
$ conan lock create test_package  --lockfile=conan.lock --lockfile-out=conan.lock

Approach 2

Apply lockfile partial without locking test_package

$ conan lock create .  # the main graph only
# this wont fail, even if the test_package has other, not locked requirements
$ create . --lockfile=conan.lock --lockfile-partial

If want to strictly enforce lockfile in the main graph:

$ conan create . --lockfile=conan.lock -tf="" # do not test_package
$ conan test test_package app/1.0 --lockfile=conan.lock --lockfile-partial

Approach 3

Directly locking requires and test_package requires in a single create:

# generates test_package requirements too
$ conan create . --lockfile-out=conan.lock

I think we can close this ticket as solve in 2.0, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants