-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[RFC] Migrate from qmlformat
to qml_formatter
#10929
Conversation
d276d65
to
19e7743
Compare
This seems to pull in the requirements of the whole rust build system into Mixxx. Probably not a good fit for us.
|
No, i don't think there is a binary distribution, and there's also no Python implementation that I know of. I found a 2 years old alpha-stage plugin for prettier (node JS), but I could not make it work (always fails to parse our QML). I don't think the rust dependency is a big problem. It's neither a compile-time nor a runtime dependency. It's only needed for running pre-commit locally, and you can still skip the hook and rely on CI if you don't want to install cargo. Also, @Swiftb0y and me are working on rekordcrate which is also written in Rust with the goal to replace the kaitai-based Rekordbox parser implementation and add support for serialization. So an actual compile-time rust dependency would be on the horizon anyway... The tool itself is still under development, but the devs of |
19e7743
to
30520b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only needed for running pre-commit locally, and you can still skip the hook and rely on CI if you don't want to install cargo.
After merging this, it will fail every commit with the obscure error message like above. This happens even without touching any qml file. I have no idea how many files are pulled in by cargo, but for now it feels a bit overdone and necessary hassle for a new contributor, just want to alter come c++ code.
Can we make this somehow less mandatory, like one of these ideas:
- disable it by default locally
- installing qml_formatter only if qml files have changed
- Skip hook if cargo is not installed
- Fail early with a descriptive error message
- add the cargo installation to all our environment scripts.
- Add qml_formatter to our vcpkg environment
Is it correct that cargo requires ~2 GB ? |
I think |
No, it uses 550 MiB (excluding stuff like gcc/llvm-libs/curl that you need anyway, even without rust):
|
How about "disable it by default locally" and wait until rust is settled in Mixxx anyway. Luckily the GitHub workflow runners have rust installed by default .. |
Done, have a look at: pre-commit/pre-commit#2534 |
Cool, now we just need to wait for a release. Can we disable this by default and carry on here? |
It installs rust locally, compiles and then deletes the rustup distribution. It could theoretically also delete the entire tooling and only keep the compiled binaries, but I wanted to get some feedback on the implementation first. I'm also unsure if this makes hook version bumps too annoying if it always reinstalls all over.
No, I don't think this is possible with pre-commit. I think it's not that much of an issue that it really prevents merging (I have the impression that most contributors are not using pre-commit for whatever reason anyway), but if you insist we can also wait for the next pre-commit release. |
At the moment this hook is only relevant for a handful of contributors. The others will face the error message above and annoyed by a > 500 MB download after figured out the solution for no reason. |
I'm guesstimating that a new pre-commit version will be released soon-ish, which will feature support for bootstrapping rust: pre-commit/pre-commit#2534 (comment) I've already set the minimum pre-commit version to 2.21.0, so that this PR should start working once the next pre-commit version is released. |
Well if we only run it on CI but not locally, then people will get annoyed that that pre-commit passes locally but not on CI... |
This PR is marked as stale because it has been open 90 days with no activity. |
1f5a473
to
aa71f70
Compare
Although `qml_formatter` is much less mature, we can at least pin a specific version via pre-commit. This is especially important since `qmlformat` seems to change its formatting rules on every version bump, so version incompatibilities between local computer and CI happen very often.
Mixxx is a C project, and requiring contributors to set up a rust installation on their systems just to be able to use `qml_formatter` is a bit tedious. Fortunately, pre-commit 2.21.0+ features support for bootstrapping Rust toolchains using rustup, so that no preexisting system install is necessary. See pre-commit/pre-commit#2534 for details. We set pre-commit 2.21.0 as the minimum required version, to prevent users that use an older pre-commit version and don't have rust installed from running into problems and to inform them that they should update. If someone uses an pre-commit version < 2.21.0, the following error message will be shown: $ pre-commit run An error has occurred: InvalidConfigError: ==> File .pre-commit-config.yaml ==> At Config() ==> At key: minimum_pre_commit_version =====> pre-commit version 2.21.0 is required but version 2.20.0 is installed. Perhaps run `pip install --upgrade pre-commit`. Check the log at /home/user/.cache/pre-commit/pre-commit.log
aa71f70
to
7ec6d21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit has been released as V2.21.0 including pre-commit/pre-commit#2534 see:
https://github.com/pre-commit/pre-commit/releases/tag/v2.21.0
This means that the next commit will require a 116 MB download including configuration it takes here 4 min.
Since it is a one time task, it is kind of OK now.
Thank you.
Although
qml_formatter
is much less mature, we can at least pin a specific version via pre-commit (in contrast,qmlformat
is distributed with Qt, so in order to update it we need to update our Qt version). This is especially annoying sinceqmlformat
seems to change its formatting rules on every version bump, so version incompatibilities between local computer and CI happen very often.There are still a few bugs blocking that prevent us from using it though:
case
statements insideswitch
qarmin/qml_formatter#2