-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: summarise 'charmcraft analyse' results #8
base: main
Are you sure you want to change the base?
Conversation
…lyse' on the charms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems cool! I've done some nitpicking though haha
# Remove the build environment - otherwise, this ends up using a huge amount | ||
# of disk space (in /var/snap/lxd). | ||
subprocess.run(["charmcraft", "clean"], check=True, cwd=repo) | ||
continuation = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type hint could be good here
I guess it's
tuple[Path, str, str] | None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation = None | |
continuation: tuple[Path, str, str] | None = None |
full_line = f"{continuation[2]} {line}" | ||
logger.warning("%s (%s): %s", *continuation[:-1], full_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unpack for readability?
repo, charm_name, prev_line = continuation
full_line = f'{prev_line} {line}'
logger.warning("%s (%s): %s", repo, charm_name, full_line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full_line = f"{continuation[2]} {line}" | |
logger.warning("%s (%s): %s", *continuation[:-1], full_line) | |
repo, charm_name, prev_line = continuation | |
full_line = f"{prev_line} {line}" | |
logger.warning("%s (%s): %s", repo, charm_name, full_line) |
) | ||
|
||
total = 0 | ||
overall_results = collections.defaultdict(lambda: collections.Counter()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use collections.Counter
without the lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall_results = collections.defaultdict(lambda: collections.Counter()) | |
overall_results = collections.defaultdict(collections.Counter) |
# of disk space (in /var/snap/lxd). | ||
subprocess.run(["charmcraft", "clean"], check=True, cwd=repo) | ||
continuation = None | ||
for charm in repo.glob("*.charm"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run with the repack
option, and there are already .charm
files with different names, this will get both, right? But I guess the expectation is that the only charm file is the one you made?
It doesn't seem like you can set the output filename, but you could use charmcraft pack
's --output
flag to set an output directory and remove the directory before repacking ... ./.cache/$charm/.packed/
maybe? or maybe a parallel structure like ./.packed-cache/$charm/
would be more convenient since you can easily remove all the packed charms in one operation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm somewhat assuming that the cache folder is only used by these tools, or is cleaned up to be that way. And yes, I really wanted to just get the output name but it doesn't seem possible, probably because of the history of charmcraft being able to produce multiple charms in a pack.
Putting them all somewhere else is an interesting idea, though.
Oh also I know namespaces are a honking great idea, but it might be nice to import |
I think we discussed this elsewhere but my personal taste is very much the opposite :) |
New summary script that:
charmcraft analyse
on the resulting charm files