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

[feature] Add hooks for validate and validate_build methods #17856

Draft
wants to merge 8 commits into
base: develop2
Choose a base branch
from

Conversation

uilianries
Copy link
Member

Motivation

Hello!

This PR brings a new hooks for validate() and validate_build() methods.

The intention is to help CI services validate a build without touching the recipe, by adding an extra layer of validations. For instance, the CI environment could not build a determined package due to custom settings, or some system library is not available because the O.S. is too old.

Details

Both validate and validate_build don't have a specific command, like export or build, so I used conan create to get a ride and check if is working.

Also, both methods are not defined by default, which means, the hook will only run when one of these methods is defined in the recipe.

Automation

Changelog: Feature: Add hooks pre_validate, post_validate, pre_validate_build and post_validate_build
Docs: TODO

/cc @jcar87

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@AbrilRBS AbrilRBS self-requested a review February 26, 2025 10:16
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@memsharded
Copy link
Member

#17879 has been merged to develop2, please merge from develop2 to get rid of HookManager instantiation issue.

compatibility_file = os.path.join(compatibility_plugin_folder, "compatibility.py")
if not os.path.exists(compatibility_file):
raise ConanException("The 'compatibility.py' plugin file doesn't exist. If you want "
"to disable it, edit its contents instead of removing it")
mod, _ = load_python_file(compatibility_file)
self._compatibility = mod.compatibility
self._hook_manager = HookManager(HomePaths(cache_folder).hooks_path)
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't instantiate HookManager here anymore.

unknown_mode = global_conf.get("core.package_id:default_unknown_mode", default="semver_mode")
non_embed = global_conf.get("core.package_id:default_non_embed_mode", default="minor_mode")
# recipe_revision_mode already takes into account the package_id
embed_mode = global_conf.get("core.package_id:default_embed_mode", default="full_mode")
python_mode = global_conf.get("core.package_id:default_python_mode", default="minor_mode")
build_mode = global_conf.get("core.package_id:default_build_mode", default=None)
self._modes = unknown_mode, non_embed, embed_mode, python_mode, build_mode
self._hook_manager = HookManager(HomePaths(self._home_folder).hooks_path)
Copy link
Member

Choose a reason for hiding this comment

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

Do not instantiate here a new HookManager

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.

3 participants