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 Cargo Task to generate Deb packages #87

Merged

Conversation

morosanmihail
Copy link
Contributor

This creates a Kraken Task that allows users to generate Debian packages from a Cargo project.

These packages can then be published as needed, most likely to apt repositories.

kraken-std/src/kraken/std/cargo/__init__.py Outdated Show resolved Hide resolved
kraken-std/src/kraken/std/cargo/__init__.py Outdated Show resolved Hide resolved
kraken-std/src/kraken/std/cargo/__init__.py Outdated Show resolved Hide resolved
kraken-std/src/kraken/std/cargo/__init__.py Outdated Show resolved Hide resolved
package_name=package_name,
group="publish",
)
task.depends_on(":cargoBuildRelease")
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bit annoying because the task may not always be called cargoBuildRelease, it can also be cargoBuildDebug: https://github.com/kraken-build/kraken-build/blob/3011038a7b8c671c606c7c9f97e6b71771914a1c/kraken-std/src/kraken/std/cargo/__init__.py#L291-L292

Perhaps the cleaner solution here is to have CargoGenerateDebPackage accept a list of package_names which can be list[str] | list[Property[BinaryArtifact]].

Then, when calling cargo_generate_deb_package, you'd pass it the path to the binaries or libs coming from the build task:

https://github.com/kraken-build/kraken-build/blob/3011038a7b8c671c606c7c9f97e6b71771914a1c/kraken-std/src/kraken/std/cargo/tasks/cargo_build_task.py#L45-L49

Because if a task has a property which is another task's output property, kraken automatically creates a dependency between the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be fine, as we only want to package release binaries for now. It could definitely be improved in the longer run.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still, we cannot leave it as is because sometimes the build task will not exist: for example, it might be cargoBuildRelease on develop, and cargoBuildDebug on a feature branch, in which case this will fail.

If we don't want to automatically generate the dependency via Propertys, then we should defer to the caller (who will know better) the responsibility of adding the dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't we want this to fail if someone has defined it, but there's no build? The only way to use this is manual, for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, it is not the task that would fail, but the generation of the task graph. Meaning that you would not be able to run any kraken task, as building the dependency graph would fail with an error (something like No task matched the selector ':**:cargoBuildRelease')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checked and I think I can safely remove the dependency on any cargoBuild*. cargo deb seems to build an optimised binary even if cargo build wasn't run first, so it will work in any situation.

And it being part of the publish group should limit repeating work.

@ntrinquier ntrinquier merged commit 8bafc30 into kraken-build:develop Aug 8, 2023
13 checks passed
@morosanmihail morosanmihail deleted the mihailm_add_cargo_deb_generation branch August 8, 2023 11:47
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.

None yet

2 participants