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

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

adalinesimonian
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
@adalinesimonian adalinesimonian force-pushed the patch-1 branch 2 times, most recently from 9ec7ff8 to 23bce47 Compare January 22, 2025 08:38
@adalinesimonian
Copy link
Contributor Author

Addressed comments and rebased onto main.

@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1016

@Bromeon
Copy link
Member

Bromeon commented Feb 1, 2025

Thanks for the updates! 🙂

I tested this locally. One problem is that for other API versions than the default, there may be unused symbols and other warnings. At the moment, clippy is strict in the sense that any warnings are treated as errors.

Example: if I run

./check.sh -a 4.1

error messages


I don't really feel like adding thousand #[cfg] to "fix" all these occurrences, it adds lots of busywork and hard-to-read code for little value. We don't test CI clippy against all possible features, so those will keep creeping back in, anyway.

We could maybe pass -D warnings to cargo build calls in CI, but I'd say that's another discussion outside the scope of these changes.

Either way, check.sh failing on master will be treated as a bug by users, so we need to address this. Maybe simplest is to skip clippy invocations as soon as -a is provided (even if it's the current one), and instead print a warning/note and succeed. What do you think?

Would also need a rebase onto master.

@adalinesimonian
Copy link
Contributor Author

Either way, check.sh failing on master will be treated as a bug by users, so we need to address this. Maybe simplest is to skip clippy invocations as soon as -a is provided (even if it's the current one), and instead print a warning/note and succeed. What do you think?

I think that's a good idea. If clippy is being manually supplied I think it should still run it with a warning, and only omit it out of the checks run by default. If that works I can go ahead and make the change.

@adalinesimonian
Copy link
Contributor Author

Screenshot of ./check.sh
Screenshot of ./check.sh -a 4.1
Screenshot of ./check.sh -a 4.1 clippy

@adalinesimonian adalinesimonian force-pushed the patch-1 branch 3 times, most recently from 11b49b4 to 8489b6d Compare February 1, 2025 20:44
Allows easily testing with a given version of the Godot API bindings
simply by passing a version to the -a/--api-version parameter.
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.

Thanks a lot, looks great now!

@Bromeon Bromeon added this pull request to the merge queue Feb 1, 2025
Merged via the queue into godot-rust:master with commit 506f8f5 Feb 1, 2025
15 checks passed
@adalinesimonian adalinesimonian deleted the patch-1 branch February 1, 2025 21:08
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.

4 participants