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

chore: Bump Rust version(s) #52

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

Conversation

alexpovel
Copy link

@alexpovel alexpovel commented Jul 22, 2024

Upstream base tree-sitter has seen some updates this now
incorporates.

It also bumps this crate's version. The scheme chosen is for the
Rust crate's version to be in lockstep with the tree-sitter
dependency. Looking at the major tree-sitter libraries,
this seems to be the general style chosen. For example:

The commit also adjust the Rust code to be
compatible (the &'static change was just a lint,
not a compile error). cargo build and cargo test now pass.

@alexpovel alexpovel force-pushed the patch-1 branch 2 times, most recently from 16f6b4d to 2ce3533 Compare July 22, 2024 20:17
Upstream base `tree-sitter` has seen some updates this now
incorporates.

It also bumps this crate's version. The scheme chosen is for the
Rust crate's version to be in lockstep with the `tree-sitter`
dependency. Looking at the major tree-sitter libraries,
this seems to be the general style chosen. For example:

- Python: https://github.com/tree-sitter/tree-sitter-python/blob/0dee05ef958ba2eae88d1e65f24b33cad70d4367/Cargo.toml
- TypeScript: https://github.com/tree-sitter/tree-sitter-typescript/blob/198d03553f43a45b92ac5d0ee167db3fec6a6fd6/Cargo.toml

The commit also adjust the Rust code to be
compatible (the `&'static` change was just a lint,
not a compile error). `cargo build` and `cargo
test` now pass.
MichaHoffmann
MichaHoffmann previously approved these changes Jul 24, 2024
Copy link
Collaborator

@MichaHoffmann MichaHoffmann left a comment

Choose a reason for hiding this comment

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

Lgtm @amaanq can you ptal?

@clason
Copy link
Contributor

clason commented Jul 26, 2024

We don't tie parser versions to the tree-sitter crate (that's what ABI is for, which can be checked independently of the version).

And aren't the bindings autogenerated?

@clason clason requested a review from amaanq July 26, 2024 10:55
@alexpovel
Copy link
Author

Thanks for your comments!

I'm not sure I understand the versioning scheme. Would appreciate guidance here!


Starting from current HEAD at 9e3ec98 , just bumping tree-sitter as:

diff --git a/Cargo.toml b/Cargo.toml
index d0b9dc6..6341487 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,7 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
 path = "bindings/rust/lib.rs"
 
 [dependencies]
-tree-sitter = "~0.20.10"
+tree-sitter = ">=0.22.0"
 
 [build-dependencies]
 cc = "1.0"

I can regenerate bindings as

cargo install [email protected] && ~/.cargo/bin/tree-sitter generate

using 0.22.6 as you did the other day in 9bb9943 . Now git diff bindings/rust gives

diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs
index 8851fed..718f897 100644
--- a/bindings/rust/build.rs
+++ b/bindings/rust/build.rs
@@ -7,6 +7,9 @@ fn main() {
         .flag_if_supported("-Wno-unused-parameter")
         .flag_if_supported("-Wno-unused-but-set-variable")
         .flag_if_supported("-Wno-trigraphs");
+    #[cfg(target_env = "msvc")]
+    c_config.flag("-utf-8");
+
     let parser_path = src_dir.join("parser.c");
     c_config.file(&parser_path);

aka no changes in lib.rs. cargo test then fails. The changes necessary for Rust to compile I added manually. I will amend the above diff from generate to the PR as well.


Re: versioning scheme. I found this example where the tree-sitter dependency was bumped a minor, while the Crate version wasn't.

Is the versioning I chose here wrong? I'm happy to adjust!

This is the result of running

```bash
cargo install [email protected] && ~/.cargo/bin/tree-sitter generate
```

and committing only the Rust changes.
@clason
Copy link
Contributor

clason commented Jul 26, 2024

The versioning scheme is basically semver, from the point of view of queries (so reflecting minor/major/breaking changes in the grammar only).

And try removing the bindings first; some files are not touched if they already exist.

This is the result of running

```bash
rm bindings/rust/{lib,build}.rs && cargo install [email protected] && ~/.cargo/bin/tree-sitter generate
```

and committing only the Rust changes. Removing
bindings first gives a clean slate with slightly
different results.
@alexpovel
Copy link
Author

Thank you. I regenerated after removing first, which gives slightly different results. Didn't squash yet to keep it readable.

Re: semver. The context for my PR is just that I'm trying to get this crate onto crates.io (with tree-sitter dep as >=0.22.0). It's not been released on there yet. So an initial release as 0.0.1 (the current one) would probably be fine with semver and is totally fine with my use case. Which initial version do you prefer?

@clason
Copy link
Contributor

clason commented Jul 27, 2024

Actually, versioning and publishing should be handled by our workflows; we'd prefer it if there was no "rogue publishing" that can interfere with that.

@ObserverOfTime

@ObserverOfTime
Copy link
Member

ObserverOfTime commented Jul 27, 2024

Publishing should be handled by our workflows.
Versioning should start at 0.1.0 or 1.0.0 (0.0.1 = experimental = unpublishable).
(Actually 1.2.0 or 2.0.0 since the parser is currently at 1.1.0.)

P.S. The CLI will help with versioning in the future.

@MichaHoffmann
Copy link
Collaborator

Do we have the secrets configured for this repository? I would add the actions then today

@clason
Copy link
Contributor

clason commented Jul 27, 2024

Ideally they should be available org-wide, like the NPM token (as we eventually want to publish ALL THE PARSERS).

@ObserverOfTime
Copy link
Member

ObserverOfTime commented Jul 27, 2024

Unfortunately, crates does not support team tokens and pypi has yet to approve the org.
Also, for the org-wide npm token to work, the package name must be @tree-sitter-grammars/tree-sitter-hcl.

@clason
Copy link
Contributor

clason commented Jul 28, 2024

@ObserverOfTime Can you set up the token and the publish workflow for this repo then?

@ObserverOfTime
Copy link
Member

Sure, but it would be published on my account.

@clason
Copy link
Contributor

clason commented Jul 28, 2024

Can we use our github app? It's a bit annoying that we have to tie packages to personal accounts that may move on, orphaning the package.

@ObserverOfTime
Copy link
Member

The app is for GitHub tokens, not registry tokens.

@alexpovel
Copy link
Author

For reference: https://doc.rust-lang.org/cargo/reference/publishing.html#cargo-owner . Multiple individuals (all fully entitled) can be made owners, alleviating the issue of orphaning. Teams can then be entitled to publish crate updates etc.

@alexpovel
Copy link
Author

Hey folks, is there a way I can help move this forward?

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.

4 participants