@@ -59,3 +59,54 @@ Sometimes, especially if resolving conflicts on generated files, you might need
5959bazel run @codeql//rust/codegen -- --force
6060```
6161for code generation to succeed.
62+
63+ ### Updating ` rust-analyzer `
64+
65+ Here's a rundown of the typical actions to perform to do a rust-analyzer (and other dependencies) update. A one-time setup consists in
66+ installing [ ` cargo-edit ` ] ( https://crates.io/crates/cargo-edit ) with ` cargo install cargo-edit ` . On Ubuntu that also requires
67+ ` sudo apt install libssl-dev pkg-config ` .
68+
69+ 1 . From the root of the ` codeql ` repo checkout, run a Cargo upgrade:
70+ ```
71+ cargo upgrade --incompatible --pinned
72+ ```
73+ 2 . Look at a diff of the ` Cargo.toml ` files: if all ` ra_ap_ ` prefixed dependencies have been updated to the same number, go on to the next step.
74+ Otherwise, it means the latest ` rust-analyzer ` update has not been fully rolled out to all its crates in ` crates.io ` .
75+ _ All ` ra_ap_ ` versions must agree!_
76+ Downgrade by hand to the minimum one you see, and run a ` cargo update ` after that to fix the ` Cargo.lock ` file.
77+ 3 . Commit the changes, skipping ` pre-commit ` hooks if you have them enabled:
78+ ```
79+ git commit -am 'Cargo: upgrade dependencies' --no-verify
80+ ```
81+ 4 . Regenerate vendored bazel files (these allow faster builds, particularly on CI where it has to start from scratch each time), commit the changes:
82+ ```
83+ misc/bazel/3rdparty/update_tree_sitter_extractors_deps.sh
84+ git add .
85+ git commit -am 'Bazel: regenerate vendored cargo dependencies' --no-verify
86+ ```
87+ 5 . Run codegen
88+ ```
89+ bazel run //rust/codegen
90+ ```
91+ Take note whether ` rust/schema/ast.py ` was changed. That might need tweaks, new tests and/or downgrade/upgrade scripts down the line.
92+ 6 . Try compiling
93+ ```
94+ bazel run //rust:install
95+ ```
96+ * if it succeeds: good! You can move on to the next step.
97+ * if it fails while compiling rust-analyzer dependencies, you need to update the rust toolchain. Sometimes the error will tell you
98+ so explicitly, but it may happen that the error is more obscure. To update the rust toolchain:
99+ * you will need to open a PR on the internal repo updating ` RUST_VERSION ` in ` MODULE.bazel ` . In general you can have this merged
100+ independently of the changes in ` codeql ` .
101+ * in ` codeql ` , update both ` RUST_VERSION ` in ` MODULE.bazel ` _ and_ ` rust-toolchain.toml ` files. You may want to also update the
102+ nightly toolchain in ` rust/extractor/src/nightly-toolchain/rust-toolchain.toml ` to a more recent date while you're at it.
103+ * if it fails while compiling rust extractor code, you will need to adapt it to the new library version.
104+ * for example updating annotations in ` annotations.py ` , adding / removing generated tests.
105+
106+ If you had to do any changes, commit them. If you updated the rust toolchain, running ` rust/lint.py ` might reformat or apply new
107+ lints to the code.
108+ 7 . Check with CI if everything is in order.
109+ 8 . Run DCA with database caching disabled. Iterate on the code if needed.
110+ 9 . If in step 5 the schema was updated, add upgrade/downgrade scripts and a change note. This is best done last to reduce the chance of
111+ merge conflicts (none of the other testing depends on having upgrade and downgrade scripts in place). See
112+ [ Upgrading a language database schema] ( docs/prepare-db-upgrade.md ) .
0 commit comments