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

test: support switching API versions in check.sh #1016

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adalinesimonian
Copy link

@adalinesimonian adalinesimonian commented Jan 18, 2025

Allows easily testing against a given version of the API bindings simply by passing a version to the -a/--api-version parameter.

I've been using this patch on my machine for integration testing.

@lilizoey lilizoey added quality-of-life No new functionality, but improves ergonomics/internals c: tooling CI, automation, tools labels Jan 18, 2025
@lilizoey
Copy link
Member

do we have to add support for specifically gdvm here? isn't the main advantage of this PR that you can specify a godot api version to compile against? i feel like it should be possible to do something like GODOT_BIN="gdvm run 4.2" ./check.sh itest -g 4.2 if you wanted to use gdvm specifically

@adalinesimonian
Copy link
Author

For the API features to get built in line with the version it felt cleaner to just roll it all together rather than chain two commands together. But I'm not picky if you have a preferred alternative.

@lilizoey
Copy link
Member

i do agree that it's cleaner, but only if you are already using gdvm. so id prefer changing it so that it only sets the api version feature.

also since almost everything is related to godot, including "godot" in --godot-version feels a bit redundant now. maybe -a/--api-version or just -v/--version? especially since with this change, we're only changing the api version we compile against, and not the binary used to run the program. which is also a benefit of splitting this feature up, as we do try to ensure that we can run in backwards compatible configurations (like compiling against 4.2 but running with 4.3).

@adalinesimonian
Copy link
Author

adalinesimonian commented Jan 18, 2025

Those are great points. Let me see if the bin path var would let arguments right now the way it is. I think possibly it would need an addl. var for arguments based on how it is being included in the script (e.g. GODOT4_BIN="gdvm" GODOT4_ARGS="run --console 4.2 --force" ./check.sh itest -v 4.2 which is quite a mouthful). One option is also to have a --gdvm flag which would generate the correct command automatically, at which point you just run ./check.sh itest --gdvm [optional version] -v 4.2 or something along those lines. gdvm does expose a godot binary to the path, but since the version is not pinned or set in the project, it will try to run the version for the project file, which seems to be 4.1. Using the gdvm command on the terminal is the only way to specify a version at runtime on the CLI.

@adalinesimonian adalinesimonian changed the title test: support gdvm in check.sh test: support switching godot versions in check.sh Jan 18, 2025
@adalinesimonian
Copy link
Author

I just split the API version from the version mechanism for gdvm and updated this PR's description. This allows for a clean and simple syntax with gdvm installed but allows selecting the API version if not using gdvm, also. What're your thoughts?

Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

While I appreciate the integration efforts with your project gdvm (I assume this one), I don't think it's in godot-rust's scope to integrate to third-party tools, unless they're official or so widely used that they've become de-facto standard in the Godot ecosystem. There are various reasons for this: unclear which tools should be integrated, who maintains the integration, if/how they are updated, whether their API is stable, more testing/bug surface and overall complexity/scope of the project. This reasoning also extends to tooling such as the check.sh script.

If you're interested in customizing your workflow, our .gitignore features a /script entry, in which you can add various scripts without interfering with files under version control. Regarding CI, we already test multiple versions, with various feature flags. If you fork the project, you can use GitHub Actions in your own repository and push changes there until they're ready for a PR. I find the feedback times quite reasonable (5-8min for full CI, 2-4 for minimal CI).

Apart from that, check.sh is mostly meant as a quick local check, but the CI workflows remain the authority on what's considered correct/suitable (also in case of discrepancies between CI and check.sh). Considering that, the -a|--api-version to set the api-version feature seems like a good addition, but functionality beyond that should probably be delegated to third-party tools.

So it would be nice if you could reduce the PR to the -a|--api-version flag. I feel a bit bad for the effort that went into the other parts, but please don't hesitate to discuss ideas before implementation next time 🙂

check.sh Outdated Show resolved Hide resolved
@adalinesimonian
Copy link
Author

adalinesimonian commented Jan 19, 2025

I can split off the -g flag into my own script. Don't worry about any effort wasted, it really wasn't. I made this change primarily for myself when I was testing against API versions and opened up this PR in the event it might be helpful to others. Since this script is just for the convenience of contributors, I didn't really think it be the same as an integration into the actual project. I'll move the sugar into a script in script/.

I'll add a GODOT_ARGS parameter so that arguments can be passed to godot before any are added by this script. That would make the full example of usage all together:

# Windows:

# Test against specifically 4.3.0 Godot with API version 4-3
GODOT4_BIN="gdvm" GODOT_ARGS="run --force --console 4.3.0 --" ./check.sh itest -a 4.3

# Test against latest 4.3.x Godot with API version 4-3
GODOT4_BIN="gdvm" GODOT_ARGS="run --force --console 4.3 --" ./check.sh itest -a 4.3

# Other platforms (*nix, macOS):

# Test against specifically 4.3.0 Godot with API version 4-3
GODOT4_BIN="gdvm" GODOT_ARGS="run --force 4.3.0 --" ./check.sh itest -a 4.3

# Test against latest 4.3.x Godot with API version 4-3
GODOT4_BIN="gdvm" GODOT_ARGS="run --force 4.3 --" ./check.sh itest -a 4.3

Which is a bit long and clunky, but it works.

I'll get to this when I have a moment.

@Bromeon
Copy link
Member

Bromeon commented Jan 19, 2025

Would something like this not work?

GODOT4_BIN="gdvm run --console 4.3 --"

@adalinesimonian
Copy link
Author

Not the way it's being used in the script, no:

run "$godotBin" --path itest/godot --headless -- "[${extraArgs[@]}]"

This would give you a gdvm run 4.3 --: command not found since it's not being expanded. but expanding the variable might cause issues if anyone's been passing GODOT4_BIN to check.sh with spaces in the path.

@adalinesimonian adalinesimonian changed the title test: support switching godot versions in check.sh test: support switching API versions in check.sh Jan 20, 2025
Allows easily testing with a given version of the Godot API bindings
simply by passing a version to the -a/--api-version parameter.
@adalinesimonian
Copy link
Author

Addressed comments and rebased onto main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: tooling CI, automation, tools quality-of-life No new functionality, but improves ergonomics/internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants