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

Add conan graph outdated command #15838

Merged
merged 16 commits into from
Mar 19, 2024

Conversation

juansblanco
Copy link
Contributor

@juansblanco juansblanco commented Mar 8, 2024

Changelog: Feature: Add conan graph outdated command that lists the dependencies that have newer versions in remotes
Docs: conan-io/docs#3641

The command looks for newer versions of a recipe and its dependencies in the remotes, and displays the available versions. It also shows the version ranges for each library.
It requires the path to a conanfile or an specific library with --requires.
The remotes which should be looked at can be defined with --remote.

Possible updates:

  • Add revisions to check if there are newer revisions.
  • Solve version ranges to specify the possible update for each range.

Closes #9823
#7778

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

conan/cli/commands/graph.py Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
@juansblanco juansblanco requested a review from ErniGH March 11, 2024 09:58
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conans/test/integration/command_v2/test_outdated.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
@juansblanco juansblanco marked this pull request as ready for review March 12, 2024 13:47
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
Comment on lines 391 to 393
except Exception:
ConanOutput(f"{node_name} not found in remote {remote.name}")
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too broad exception. If the repo is off-line this should actually raise an error an stop.
Better:

  • Only capture specific exceptions
  • The ConanOutput(msg) is wrong, this means this is at least not tested.

conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
Comment on lines 11 to 29
tc.save({"conanfile.py": GenConanfile()})
tc.run("create . --name=zlib --version=1.0")

tc.run("create . --name=foo --version=1.0")
tc.save({"conanfile.py": GenConanfile().with_requires("foo/[>=1.0]")})
tc.run("create . --name=libcurl --version=1.0")

# Upload the created libraries to remote
tc.run("upload * -c -r=default")

# Create new version of libraries in remote and remove them from cache
tc.save({"conanfile.py": GenConanfile()})
tc.run("create . --name=foo --version=2.0")
tc.run("create . --name=zlib --version=2.0")
tc.run("upload * -c -r=default")
tc.run("remove foo/2.0 -c")
tc.run("remove zlib/2.0 -c")

tc.save({"conanfile.py": GenConanfile("app", "1.0").with_requires("zlib/1.0", "libcurl/[>=1.0]")})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole preparation of the test could be more compact and clear

Comment on lines 49 to 67
tc.save({"conanfile.py": GenConanfile()})
tc.run("create . --name=zlib --version=1.0")
tc.run("create . --name=foo --version=1.0")

tc.save({"conanfile.py": GenConanfile().with_requires("foo/[>=1.0]")})
tc.run("create . --name=libcurl --version=1.0")

# Upload the created libraries to remote
tc.run("upload * -c -r=default")

# Create new version of libraries in remote and remove them from cache
tc.save({"conanfile.py": GenConanfile()})
tc.run("create . --name=foo --version=2.0")
tc.run("create . --name=zlib --version=2.0")
tc.run("upload * -c -r=default")
tc.run("remove foo/2.0 -c")
tc.run("remove zlib/2.0 -c")

tc.save({"conanfile.py": GenConanfile("app", "1.0").with_requires("zlib/1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated to previous test, consider refactoring. Most likely you want a test that is parameterized, if is is very similar, just with or without lockfile.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting there, some more comments and improvements, but getting closer :)

conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
conan/cli/commands/graph.py Outdated Show resolved Hide resolved
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

conan/cli/commands/graph.py Outdated Show resolved Hide resolved
Comment on lines 402 to 404
except ConanException as message:
ConanOutput().warning(f"{message} in remote {remote.name}")
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this fail? Should it be a warning in all cases?
It is not the same that the remote is unavailable => should raise an error, that the package is not in the remote, which is ok, and shouldn't even warn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okey to remove the message then? We need to catch the exception when it doesn't find anything but maybe the continue is enough.

Do we want to additionally handle the error you mention when it can't connect to the remote?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you need to treat the different errors differently. Connection errors are bad, should be raised. 404-not found are not really an error in this context, not even a warning.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvements in tests pending too.

continue
except ConanException as message:
ConanOutput().warning(f"{message} in remote {remote.name}")
except ConanConnectionError as error:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not fully correct. There are other exceptions like AuthenticationException, \ ForbiddenException, RequestErrorException that are not a ConnectionError, and it still should be considered an error, not silently skipped. It is only when the server succesfully returns a 404-not found that we can continue

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
I think that second except-raise is unnecessary

conan/cli/commands/graph.py Outdated Show resolved Hide resolved
Co-authored-by: James <memsharded@gmail.com>
Copy link
Contributor

@jcar87 jcar87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

[question] check for a new package version
6 participants