-
-
Notifications
You must be signed in to change notification settings - Fork 600
Fix and enhance support for different bazel metadata versions #4194
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
Fix and enhance support for different bazel metadata versions #4194
Conversation
Signed-off-by: Adrian Braemer <[email protected]>
Signed-off-by: Adrian Braemer <[email protected]>
1647116
to
bdb908c
Compare
* by combining the paths we ensure to extract maximal information * I also added the possibility to extract information from a 'package_url' field Signed-off-by: Adrian Braemer <[email protected]>
Test failures seem unrelated to my changes |
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.
Thanks a lot @abraemer , a couple nits for your consideration. Looking good otherwise.
"name": "androidx.compose.animation:animation", | ||
"upstream_address": "https://developer.android.com/jetpack/androidx/releases/compose-animation#0.0.1", | ||
"version": "0.0.1", | ||
"package_url" : "pkg:maven/androidx.compose.animation/[email protected]" |
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.
Could you maybe link to some examples of this type of manifests with package_url
fields and maybe add one of those as tests, it's best to use real world examples probably. Or if you got this from some real example, you can also link that file here.
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.
Unfortunately, I cannot link you one of our internal files. However my example file is very close to an actual file (the version number is wrong but that's all).
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.
Unfortunately, I cannot link you one of our internal files.
No worries on that obviously, but can you find some other real examples with package_url
anywhere on github/elsewhere, or is this relatively new?
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 searched on GitHub but did not find any other files that use that field but also I did not find many examples of bzl files at all. So perhaps it is not very common (yet?).
As this doesn't interfere with other things, would you be okay with merging this anyways? After all it just adds another possible data source for bzl-files that has the potential to be useful for others :)
src/packagedcode/build.py
Outdated
# TODO: Store 'upstream_hash` somewhere | ||
) | ||
if 'vcs_commit_hash' in metadata_fields: | ||
package_data["extra_data"] = dict(vcs_commit_hash=metadata_fields['vcs_commit_hash']) |
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.
Wouldn't it be better to do a get() rather than checking if this exists in the mapping?
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.
When including the upstream_hash
, I rewrote this part. Now we always create the extra_data
dict with all keys and I use .get
to extract the values.
5a9bda6
to
65d2995
Compare
friendly ping since it has been 2 weeks now and I think this ready :) What do you think @AyanSinhaMahapatra? |
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.
Thanks for the changes @abraemer, this is almost ready with a couple small changes, apologies for the late review 😅
"name": "androidx.compose.animation:animation", | ||
"upstream_address": "https://developer.android.com/jetpack/androidx/releases/compose-animation#0.0.1", | ||
"version": "0.0.1", | ||
"package_url" : "pkg:maven/androidx.compose.animation/[email protected]" |
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.
Unfortunately, I cannot link you one of our internal files.
No worries on that obviously, but can you find some other real examples with package_url
anywhere on github/elsewhere, or is this relatively new?
65d2995
to
1051aa6
Compare
@AyanSinhaMahapatra friendly ping :) |
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.
Thanks++ @abraemer, last nit for your considerations. Ready to merge otherwise. Thanks for your patience.
Could you also merge from develop again, should get rid of the flaky test failures.
* always create extra_data dictionary * use get to extract information from metadatafields instead of branches * also extract upstream_hash Signed-off-by: Adrian Braemer <[email protected]>
1051aa6
to
658f0d8
Compare
@AyanSinhaMahapatra last nit is fixed and branch is up-to-date with develop. Let's see what CI says :) |
As we now store the upstream hash in the field `extra_data`, we need to make the test aware of that. Signed-off-by: Adrian Braemer <[email protected]>
Thanks++ @abraemer, all green and merging! |
I noticed that the conditions deciding between the two version for
.bzl
files are somewhat wrong. In Python'a' and 'b' in some_string
is equal to('a' and 'b') in some_string
and thus simplifies to'b' in some_string
. In this instance, I think it shouldn't make a huge difference because fortunately the stringsupstream_address
andvcs_commit_hash
still somewhat distinguish between versions.I think just fixing the conditions makes them too restrictive (AFAIK there is no real standard for these METADATA.bzl files), so I combined both paths into one. This ensures that we always extract as much information as possible.
I also added the option to use information from a
package_url
field which is important to me as we often have someMETADATA.bzl
files which are generated from Maven dependencies and thus thename
is invalid by PURL specification. I wrote a somewhat realistic test case for this.Tasks
Run tests locally to check for errors.
Closes #4196