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

Environment Checks #1093

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Bloo-dev
Copy link
Member

@Bloo-dev Bloo-dev commented Jan 28, 2025

This PR adresses #902.

Required environment checks are listed in a module's beet.yaml and are executed on /reload (during load). If a check fails, the module will not be installed and an error is printed in chat, similar to a missing dependency.

This PR is a draft on purpose. I am not that familiar with @SpecialBuilder32's versioning script, but wanted to get the ball rolling. Help is greatly appreciated.

Todo:

  • Wait on feedback from our versioning overlord
  • Add command_blocks_enabled echeck
  • Add world_generation_resources_present echeck
  • Add load_executed echeck too hard
  • Add minecraft version check via overlay setting a score
  • ~~Add warning that is printed when on a paper server, but does not disable modules~~~not needed

@Bloo-dev Bloo-dev added the tool This is related to our build pipeline label Jan 28, 2025
@@ -20,6 +20,7 @@ meta:
required:
gm4_metallurgy: 1.4.0
lib_player_death: 1.2.0
environment_checks: [gm4:score_on_non_player_entity]
Copy link
Member

Choose a reason for hiding this comment

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

What was your reasoning for making this configurable? Is there any reason we wouldn't want to just check the environment in every module, especially since they all use scoreboards to initialize through lantern load.

Copy link
Member Author

@Bloo-dev Bloo-dev Jan 28, 2025

Choose a reason for hiding this comment

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

That's mostly true for this check, but not for all. E.g. lib_machines needs command blocks to be enabled, but most modules don't need that. The same goes for world gen stuff.

If we prompt users to enable those features instead of opening a bug report with us (which is the point of this endeavour), we should only do so if said feature is really needed.

@@ -56,6 +57,26 @@ def modules(ctx: Context, opts: VersioningConfig):
lines.append(f"execute if score {dep_id} load.status matches 1.. unless score {dep_id} load.status matches {dep_ver.major} run data modify storage gm4:log queue append value {log_data}")
lines.append(f"execute if score {dep_id} load.status matches {dep_ver.major} unless score {dep_id}_minor load.status matches {dep_ver.minor}.. run data modify storage gm4:log queue append value {log_data}")

# add required environment checks
for namespaced_environment_check in opts.environment_checks:
Copy link
Member

Choose a reason for hiding this comment

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

I almost think we should only run environment checks on first install, instead of every reload? Also, we only need to perform each check once. Putting them into load makes each module run the same check again. Maybe we can finally utilize pre_load for this kind of setup check?

Copy link
Member

Choose a reason for hiding this comment

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

That would miss the edge case of importing an existing world to a new server.

Copy link
Member Author

@Bloo-dev Bloo-dev Jan 28, 2025

Choose a reason for hiding this comment

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

Putting them into load makes each module run the same check again

That's why these checks leave a score behind which is only reset post load. If the check was already done this reload, it won't need to check again and just uses the last result. That result is invalidated in post load, making sure the check is run again once next reload.

@Bloo-dev Bloo-dev marked this pull request as draft January 28, 2025 20:22
This allows echecks to provide a helpful "probable_cause" message
@Bloo-dev
Copy link
Member Author

Bloo-dev commented Feb 9, 2025

I have cleaned up the base python code to the point where I'm satisfied with functionality.

Here's what's left to do:

  • Decide: Should environment checks reside in function/environment_check/ during development, or should we place them in environment_check/ (same level as function/) and move all those files over at build time (may cause issues when someone names a folder in function/ the same as the folder we move the checks to.... Hence I don't really see a point in doing this)
  • Write the remaining checks. We can always add more checks later, I'd rather have this merged with some checks and add more later then have it sit around forever.

@Bloo-dev Bloo-dev marked this pull request as ready for review February 9, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool This is related to our build pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants