-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add reproducible central buildspec generation #1115
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
base: main
Are you sure you want to change the base?
Conversation
return True | ||
|
||
|
||
def compare_rc_build_spec( |
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.
Most of the logic of this function is taken from https://github.com/oracle/macaron/blob/6a712af1ebdcb435bd5b7199dc1b4f5473663090/tests/vsa/compare_vsa.py
I think the comparing functions within compare_vsa.py
could be refactored out into a tests_util.py
module so that all "compare" scripts used in integration tests (here) could use if needed.
Please let me know if this should be done in a subsequent PR or this PR.
2547333
to
3014540
Compare
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
…spec script Signed-off-by: Trong Nhan Mai <[email protected]>
Signed-off-by: Trong Nhan Mai <[email protected]>
3014540
to
da329fe
Compare
pformat(patches), | ||
) | ||
|
||
group = purl.namespace |
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.
A Reproducible Central Buildspec file needs the GAV coordinate of the component. This will only make sense for an input maven
type PackageURL.
At the moment, we accept any type of PackageURL. Please let me know if it makes sense to enforce the input PackageURL to be of type maven when we are generating a Reproducible Central Buildspec ? (Ideally each type of Buildspec format might have different requirements on the input PURL)
purl, | ||
) | ||
return None | ||
final_jdk_version = "8" |
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 we should always try to obtain the jdk version from maven central jar, and only fall back to 8
if we cannot do so. Please feel free to let me know if this is desireable.
Because we are providing the path to the database from CLI argument, we need to support mounting this database file into the container file system too. |
Summary
This Pull Request adds a new command called
gen-build-spec
.This command generates a buildspec, which contains the build related information for a PURL that Macaron has analyzed. The output file will be stored within
output/macaron.buildspec
.An example
The content of
output/macaron.buildspec
, which uses the Reproducible Central buildspec format.This Buildspec ideally can be used directly as part of the Reproducible Central rebuild infrastructure.
Description of changes
Macaron database extractor
The first step to generate a buildspec is to extract the build related information from an existing Macaron SQLite database. The module
macaron_db_extractor.py
added in this commit does just that.It uses sqlalchemy SELECT statement for ORM Mapped Classes to extract the data from the database into equivalent ORM Mapped instances that we defined in src/macaron/database/table_definitions.py for example.
Maven and Gradle CLI Command Parser
We use the build commands obtained in CI/CD configuration (e.g. from github action workflow yaml file) for the final buildspec. However, those build commands cannot be used as is and they requires some additional patching to work as a rebuild command.
A proper way to patch any maven and gradle CLI build command is to first parse is. The maven and gradle CLI command parsers added in this commit leverage Python's builtin
argparse
library.CLI Build Command Patcher
The modules added in this commit uses the Maven and GRadle CLI Command Parser to parse and patch the build commands obtained from the Macaron database.
Jdk version finding from java Maven Central artifacts
Macaron can obtain the JDK version for a given build command obtained from CI/CD configuration. In some cases, the CI/CD configuration doesn't have enough information for us to obtain the JDK version. Therefore, we also rely on the JDK version included in
META-INF/MANIFEST.MF
in java artifacts from Maven Centralhttps://repo1.maven.org/
.The module
jdk_finder.py
added in this commit help download the java artifacts from Maven Central given a maven type PURL, then returns the JDK version if it is available inMETA-INF/MANIFEST.MF
.In some cases, the JDK version string from
META-INF/MANIFEST.MF
don't only contain the JDK major version. For example:Because Reproducible Central Buildspec requires only the major version of JDK, we need to extract that major version only. The
jdk_version_normalizer.py
module contains the logic to do just that. It is added this in commit.Generating the Reproducible Central Buildspec
The two commits
use all components listed above to generate the final Reproducible Central Buildspec
Testing
9d8a2a7
da329fe
A new script called compare_rc_build_spec.py is added to compare the result Buildspec in the integration tests.
Checklist
verified
label should appear next to all of your commits on GitHub.