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

twoliter: Remove Release.toml from variant build #112

Merged

Conversation

ecpullen
Copy link
Contributor

Issue number:

Closes #109

Description of changes:

Instead of using Release.toml to determine the version, use the version listed in the variants Cargo.toml instead.

Testing done:

Unit test added to tests/variant_version
Integ test with project1

$ cargo run --manifest-path /home/ec2-user/twoliter/Cargo.toml -p twoliter build variant  hello-ootb

[cargo-make] INFO - Running Task: publish-setup
19:48:02 [INFO] No infra config at '/home/ec2-user/twoliter/tests/projects/project1/Infra.toml' - using local roles/keys
[cargo-make] INFO - Running Task: build-variant
   Compiling hello-ootb v0.1.0 (/home/ec2-user/twoliter/tests/projects/project1/variants/hello-ootb)
    Finished dev [optimized] target(s) in 1m 07s
[cargo-make] INFO - Build Done in 77.66 seconds.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@ecpullen ecpullen force-pushed the remove-releasetoml-variant branch from e1686f2 to 3ce1844 Compare November 14, 2023 20:00
@webern
Copy link
Contributor

webern commented Nov 20, 2023

Rebase me!

@ecpullen ecpullen force-pushed the remove-releasetoml-variant branch from 3ce1844 to d2dbe85 Compare November 20, 2023 18:33
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

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

Can't comment on twoliter/src/cmd/new.rs which appears to be extraneous in this PR.

twoliter/src/variant.rs Outdated Show resolved Hide resolved
serde_json::from_str::<Value>(
&exec(
Command::new("cargo").args([
"metadata",
Copy link
Contributor

@webern webern Nov 21, 2023

Choose a reason for hiding this comment

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

@bcressey we discussed a few ideas about where we should put image (i.e. variant) versions. There could be a single one for all variants in Twoliter.toml, variants could be enumerated and versioned in Twoliter.toml, we could put it in the variant's custom Cargo.toml metadata...

Here we are using the actual cargo package version as the variant's version. What do you think?

Note, we are doing this now to remove the Release.toml requirement.

Copy link
Contributor

@bcressey bcressey Nov 28, 2023

Choose a reason for hiding this comment

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

Here we are using the actual cargo package version as the variant's version. What do you think?

My biggest gripe is that it's inconsistent with the cargo manifests for packages, where the crate version is ignored and only the version in the package's spec file has any external effect. As a minor nit, I also don't love parsing the crate manifest in different ways with different tools; we already have a parser in buildsys and could factor that out into a standalone crate if we needed to.

A single version in Twoliter.toml is the most consistent with existing logic and would make what I consider to be the common case easier - a project where multiple variants are built and released together, all tied to a specific Git commit tagged with a version. Updating a dozen versions across all variant manifests would be a lot of boilerplate for a routine chore, vs. just editing the top-level file.

I am still somewhat interested in the direction where variants (and kits) all have associated RPM spec files, to include package dependencies via Requires and stray files that don't make sense elsewhere. If we did that we could get the variant's version from the spec file, which would be consistent with package versioning.

But I'm not convinced that would be better. Before we added application-inventory.json, none of these internal versions had any external significance. The spec file versions were mostly there as an implementation detail and a nod to spec file conventions. They're also a bit annoying to maintain since every package update requires at least two files to edit.

My preference would be to start with a top-level release-version field in Twoliter.toml, and if we need variant-specific versions for some reason, we could add a release-version-override field to package.metadata.build-variant.

@@ -137,6 +137,8 @@ TESTSYS_LOG_LEVEL = "info"
# Certain variables are defined here to allow us to override a component value
# on the command line.

BUILDSYS_VERSION_IMAGE = { script = ["awk -F '[ =\"]+' '$1 == \"version\" {print $2}' ${BUILDSYS_RELEASE_CONFIG_PATH}"], condition = { env_not_set = ["BUILDSYS_VERSION_IMAGE"]}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could require this to be set instead of discovering it from Release.toml here. This code is duplicated in Bottlerocket's Makefile.toml which means that Bottlerocket's build is always going to be setting this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could require this to be set instead of discovering it from Release.toml here. This code is duplicated in Bottlerocket's Makefile.toml which means that Bottlerocket's build is always going to be setting this.

Note, we discussed, in twoliter make we can look for BUILDSYS_VERSION_IMAGE, if it's not there or empty, we can get it from Twoliter.toml and set it before calling cargo make.

@webern webern mentioned this pull request Nov 22, 2023
7 tasks
@ecpullen ecpullen force-pushed the remove-releasetoml-variant branch from d2dbe85 to 7b0123f Compare November 28, 2023 19:41
local/README.md Outdated Show resolved Hide resolved
/// `quiet=true`, no output will be shown.
pub(crate) async fn exec(cmd: &mut Command, quiet: bool) -> Result<()> {
/// `quiet=true`, no output will be shown and will be returned instead.
pub(crate) async fn exec(cmd: &mut Command, quiet: bool) -> Result<String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than sometimes returning an empty string, I'd prefer to return a Result<Option<String>>.

@webern webern force-pushed the remove-releasetoml-variant branch from 7b0123f to 65b153a Compare November 30, 2023 22:31
@webern webern force-pushed the remove-releasetoml-variant branch 2 times, most recently from 2495717 to ff6125c Compare December 1, 2023 02:30
@webern
Copy link
Contributor

webern commented Dec 1, 2023

https://github.com/bottlerocket-os/twoliter/compare/249571779ab10b569546d86194c81bd58dbffd7d..ff6125c786f12f25f3ecf0362a5332d01972eec3

  • Broke the README change out to its own commit.
  • Added release-version to Twoliter.toml
  • Created a validating system when loading Twoliter.toml than can issue a warning about Release.toml and make sure it has the same version as Twoliter.toml.
  • Updated Ethan's commit to take the version from Twoliter.toml

TODO: Probably should add tests of the Release.toml validation.

@webern webern force-pushed the remove-releasetoml-variant branch from ff6125c to fd9907d Compare December 1, 2023 02:38
local/README.md Outdated
@@ -1,3 +1,55 @@
# Building The Alpha SDK
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file can be removed. It wasn't supposed to be a part of this branch.

Comment on lines +204 to +207
warn!(
"A Release.toml file was found. Release.toml is deprecated. Please remove it from \
your project."
);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this could encourage people building from the main repo to send a PR to remove Release.toml - might want to drop it.

webern and others added 4 commits December 6, 2023 17:53
When loading a project, issue a deprecation warning if Release.toml is
found. If it is found, ensure that its version field is aligned with
Twoliter.toml
It is no longer required to have a Release.toml file in the project.

Co-authored-by: Ethan Pullen <[email protected]>
Co-authored-by: Matthew James Briggs <[email protected]>
@ecpullen ecpullen force-pushed the remove-releasetoml-variant branch from fd9907d to ba4185a Compare December 6, 2023 17:57
@@ -15,9 +15,13 @@ BUILDSYS_IMAGES_DIR = "${BUILDSYS_BUILD_DIR}/images"
BUILDSYS_TOOLS_DIR = "${BUILDSYS_ROOT_DIR}/tools"
BUILDSYS_SOURCES_DIR = "${BUILDSYS_ROOT_DIR}/sources"
BUILDSYS_SBKEYS_DIR = "${BUILDSYS_ROOT_DIR}/sbkeys"
BUILDSYS_SBKEYS_PROFILE = { script = ['echo "${BUILDSYS_SBKEYS_PROFILE:-local}"'] }
BUILDSYS_SBKEYS_PROFILE = { script = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Please undo your IDE's auto-reformatting of this file.

@ecpullen ecpullen force-pushed the remove-releasetoml-variant branch from 328c851 to 13493e8 Compare December 7, 2023 19:55
@ecpullen ecpullen requested a review from webern December 7, 2023 20:08
@ecpullen ecpullen merged commit e88ede9 into bottlerocket-os:develop Dec 8, 2023
1 check passed
webern added a commit to webern/twoliter that referenced this pull request Dec 8, 2023
We had a mistake in bottlerocket-os#112
commit 67ef875. The check to make sure the version Release.toml matched
the release version in Twoliter.toml could never succeed due to
quotation marks around the version string.

This fixes it and adds a test to prove that it works.
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.

eliminate release.toml from build variant command
3 participants