diff --git a/.github/workflows/update-rust-analyzer.lock.yml b/.github/workflows/update-rust-analyzer.lock.yml index 087569e9c9e4..bc35237d9603 100644 --- a/.github/workflows/update-rust-analyzer.lock.yml +++ b/.github/workflows/update-rust-analyzer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"583eb1f28bb89d6fe6bc224f639ddb76e04e57c00c17d02df5183320edadabcd","body_hash":"990718b1868afabca459556cc701c1d0ef315857b226b054dfe36037ea0c6371","compiler_version":"v0.88.7","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.80"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"6e0ebbacd3b09e9100ae46887d7192b1faa136cca70fcf787678a834fdd2521b","body_hash":"990718b1868afabca459556cc701c1d0ef315857b226b054dfe36037ea0c6371","compiler_version":"v0.88.7","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.80"}} # gh-aw-manifest: {"version":1,"secrets":["GH_AW_CI_TRIGGER_TOKEN","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"820762786026740c76f36085b0efc47a31fe5020","version":"v7.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"5e508589e03a7757a7e05b26e834292f5445bfb6","version":"v0.88.7"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.14","digest":"sha256:f7df036c86575527b61f3f7df91c4412349a12b2a74988d929eafa2999230c98","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.14@sha256:f7df036c86575527b61f3f7df91c4412349a12b2a74988d929eafa2999230c98"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.14","digest":"sha256:6f95e2234dd9bd6333a8ff28ccea7ecf0204acd4a09108723844dbd2bf6268c5","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.14@sha256:6f95e2234dd9bd6333a8ff28ccea7ecf0204acd4a09108723844dbd2bf6268c5"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.28.14","digest":"sha256:3a379c5e96e29499c815e9dd2a71334d01c326a9b73991c76544fda9cae35c34","pinned_image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.28.14@sha256:3a379c5e96e29499c815e9dd2a71334d01c326a9b73991c76544fda9cae35c34"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.14","digest":"sha256:2ce8df3abf3e9b76e9c0cf5863da41f1ab3f89b20ad14b988806ab89e7bf2cd5","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.14@sha256:2ce8df3abf3e9b76e9c0cf5863da41f1ab3f89b20ad14b988806ab89e7bf2cd5"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.18","digest":"sha256:85b940556a8faa4e1fdbef124bfd75f2c4ebd855a10b88a1c3b6f3e97f6f1a53","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.18@sha256:85b940556a8faa4e1fdbef124bfd75f2c4ebd855a10b88a1c3b6f3e97f6f1a53"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23","pinned_image":"ghcr.io/github/gh-aw-node@sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23"},{"image":"ghcr.io/github/github-mcp-server:v1.11.0","digest":"sha256:fbec75de11c255213fa08d80fb166abe73d851fff631c51c0079872967720699","pinned_image":"ghcr.io/github/github-mcp-server:v1.11.0@sha256:fbec75de11c255213fa08d80fb166abe73d851fff631c51c0079872967720699"}],"mcp_servers":[{"name":"safeoutputs","tools":["create_pull_request","missing_data","missing_tool","noop"]}]} # This file was automatically generated by gh-aw (v0.88.7). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -540,7 +540,7 @@ jobs: env: GH_AW_FILE_ROOT: "${{ runner.temp }}/gh-aw" GH_AW_FILE_CONFIG: "{\"files\":[{\"path\":\"safeoutputs/config.json\",\"content_env\":\"GH_AW_SAFE_OUTPUTS_CONFIG\"}]}" - GH_AW_SAFE_OUTPUTS_CONFIG: "{\"create_pull_request\":{\"allowed_files\":[\"Cargo.lock\",\"shared/tree-sitter-extractor/Cargo.toml\",\"shared/yeast/Cargo.toml\",\"shared/yeast-macros/Cargo.toml\",\"shared/yeast-schema/Cargo.toml\",\"ruby/extractor/Cargo.toml\",\"unified/extractor/Cargo.toml\",\"unified/swift-syntax-rs/Cargo.toml\",\"MODULE.bazel\",\"MODULE.bazel.lock\",\"rust-toolchain.toml\",\"rust/**\",\"misc/bazel/3rdparty/**\"],\"branch_prefix\":\"automation/update-rust-analyzer/\",\"draft\":true,\"max\":1,\"max_patch_files\":1000,\"max_patch_size\":10240,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"README.md\",\"CONTRIBUTING.md\",\"CHANGELOG.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"request_review\",\"title_prefix\":\"Rust: \"},\"create_report_incomplete_issue\":{\"title-prefix\":\"[incomplete]\"},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_CONFIG: "{\"create_pull_request\":{\"allowed_files\":[\"Cargo.lock\",\"shared/tree-sitter-extractor/Cargo.toml\",\"shared/yeast/Cargo.toml\",\"shared/yeast-macros/Cargo.toml\",\"shared/yeast-schema/Cargo.toml\",\"ruby/extractor/Cargo.toml\",\"unified/extractor/Cargo.toml\",\"unified/swift-syntax-rs/Cargo.toml\",\"shared/yeast/src/**\",\"shared/yeast-macros/src/**\",\"shared/yeast-schema/src/**\",\"shared/tree-sitter-extractor/src/**\",\"MODULE.bazel\",\"MODULE.bazel.lock\",\"rust-toolchain.toml\",\"rust/**\",\"misc/bazel/3rdparty/**\"],\"branch_prefix\":\"automation/update-rust-analyzer/\",\"draft\":true,\"max\":1,\"max_patch_files\":1000,\"max_patch_size\":10240,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"README.md\",\"CONTRIBUTING.md\",\"CHANGELOG.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"request_review\",\"title_prefix\":\"Rust: \"},\"create_report_incomplete_issue\":{\"title-prefix\":\"[incomplete]\"},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{}}" with: script: | const path = require('path'); @@ -1799,7 +1799,7 @@ jobs: GH_AW_ALLOWED_DOMAINS: "*.githubusercontent.com,*.pythonhosted.org,anaconda.org,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,bcr.bazel.build,binstar.org,blog.bazel.build,bootstrap.pypa.io,codeload.github.com,conda.anaconda.org,conda.binstar.org,crates.io,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,docs.github.com,files.pythonhosted.org,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.blog,github.com,github.githubassets.com,index.crates.io,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,mirror.bazel.build,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,patch-diff.githubusercontent.com,patchdiff.githubusercontent.com,pip.pypa.io,ppa.launchpad.net,productionresultssa0.blob.core.windows.net,productionresultssa1.blob.core.windows.net,productionresultssa10.blob.core.windows.net,productionresultssa11.blob.core.windows.net,productionresultssa12.blob.core.windows.net,productionresultssa13.blob.core.windows.net,productionresultssa14.blob.core.windows.net,productionresultssa15.blob.core.windows.net,productionresultssa16.blob.core.windows.net,productionresultssa17.blob.core.windows.net,productionresultssa18.blob.core.windows.net,productionresultssa19.blob.core.windows.net,productionresultssa2.blob.core.windows.net,productionresultssa3.blob.core.windows.net,productionresultssa4.blob.core.windows.net,productionresultssa5.blob.core.windows.net,productionresultssa6.blob.core.windows.net,productionresultssa7.blob.core.windows.net,productionresultssa8.blob.core.windows.net,productionresultssa9.blob.core.windows.net,pypi.org,pypi.python.org,raw.githubusercontent.com,releases.bazel.build,repo.anaconda.com,repo.continuum.io,s.symcb.com,s.symcd.com,security.ubuntu.com,sh.rustup.rs,static.crates.io,static.rust-lang.org,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" GITHUB_SERVER_URL: ${{ github.server_url }} GITHUB_API_URL: ${{ github.api_url }} - GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_pull_request\":{\"allowed_files\":[\"Cargo.lock\",\"shared/tree-sitter-extractor/Cargo.toml\",\"shared/yeast/Cargo.toml\",\"shared/yeast-macros/Cargo.toml\",\"shared/yeast-schema/Cargo.toml\",\"ruby/extractor/Cargo.toml\",\"unified/extractor/Cargo.toml\",\"unified/swift-syntax-rs/Cargo.toml\",\"MODULE.bazel\",\"MODULE.bazel.lock\",\"rust-toolchain.toml\",\"rust/**\",\"misc/bazel/3rdparty/**\"],\"branch_prefix\":\"automation/update-rust-analyzer/\",\"draft\":true,\"max\":1,\"max_patch_files\":1000,\"max_patch_size\":10240,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"README.md\",\"CONTRIBUTING.md\",\"CHANGELOG.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"request_review\",\"title_prefix\":\"Rust: \"},\"create_report_incomplete_issue\":{\"title-prefix\":\"[incomplete]\"},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_pull_request\":{\"allowed_files\":[\"Cargo.lock\",\"shared/tree-sitter-extractor/Cargo.toml\",\"shared/yeast/Cargo.toml\",\"shared/yeast-macros/Cargo.toml\",\"shared/yeast-schema/Cargo.toml\",\"ruby/extractor/Cargo.toml\",\"unified/extractor/Cargo.toml\",\"unified/swift-syntax-rs/Cargo.toml\",\"shared/yeast/src/**\",\"shared/yeast-macros/src/**\",\"shared/yeast-schema/src/**\",\"shared/tree-sitter-extractor/src/**\",\"MODULE.bazel\",\"MODULE.bazel.lock\",\"rust-toolchain.toml\",\"rust/**\",\"misc/bazel/3rdparty/**\"],\"branch_prefix\":\"automation/update-rust-analyzer/\",\"draft\":true,\"max\":1,\"max_patch_files\":1000,\"max_patch_size\":10240,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"README.md\",\"CONTRIBUTING.md\",\"CHANGELOG.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"request_review\",\"title_prefix\":\"Rust: \"},\"create_report_incomplete_issue\":{\"title-prefix\":\"[incomplete]\"},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{}}" GH_AW_CI_TRIGGER_TOKEN: ${{ secrets.GH_AW_CI_TRIGGER_TOKEN }} with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-rust-analyzer.md b/.github/workflows/update-rust-analyzer.md index 970f5197ee01..074e9e4b7944 100644 --- a/.github/workflows/update-rust-analyzer.md +++ b/.github/workflows/update-rust-analyzer.md @@ -75,6 +75,14 @@ safe-outputs: - "ruby/extractor/Cargo.toml" - "unified/extractor/Cargo.toml" - "unified/swift-syntax-rs/Cargo.toml" + # A rust-analyzer update can require a newer Rust toolchain whose Clippy + # lints require compatibility fixes in any of the Rust sources. + # rust-analyzer dependency updates can also update tree-sitter APIs, + # requiring compatibility fixes in the shared extractor implementation. + - "shared/yeast/src/**" + - "shared/yeast-macros/src/**" + - "shared/yeast-schema/src/**" + - "shared/tree-sitter-extractor/src/**" - "MODULE.bazel" - "MODULE.bazel.lock" - "rust-toolchain.toml" diff --git a/MODULE.bazel b/MODULE.bazel index 9073266d77eb..aa561605c3cd 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -166,13 +166,16 @@ use_repo( http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# rust-analyzer sources needed by the rust ast-generator (see `rust/ast-generator/README.md`) +# rust-analyzer sources needed by the rust ast-generator (see `rust/ast-generator/README.md`). +# These should be updated through the `rust/scripts/update_rust_analyzer.py` script. RUST_ANALYZER_SRC_TAG = "2026-04-13" +RUST_ANALYZER_SRC_INTEGRITY = "sha256-UB/+EVx/6j4VGvnb7jfRqPaoc7Uwci3rEt6il+2J1Ds=" + http_archive( name = "rust-analyzer-src", build_file = "//rust/ast-generator:BUILD.rust-analyzer-src.bazel", - integrity = "sha256-UB/+EVx/6j4VGvnb7jfRqPaoc7Uwci3rEt6il+2J1Ds=", + integrity = RUST_ANALYZER_SRC_INTEGRITY, patch_args = ["-p1"], patches = [ "//rust/ast-generator:patches/rust-analyzer.patch", diff --git a/rust/scripts/update_rust_analyzer.py b/rust/scripts/update_rust_analyzer.py index 1eaeda2dcb90..54b79526446d 100755 --- a/rust/scripts/update_rust_analyzer.py +++ b/rust/scripts/update_rust_analyzer.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 +import base64 +import hashlib import json +import re import shlex import subprocess import sys @@ -10,6 +13,7 @@ REPO_ROOT = Path(__file__).resolve().parents[2] +MODULE_BAZEL = REPO_ROOT / "MODULE.bazel" RUST_EXTRACTOR_MANIFEST = REPO_ROOT / "rust/extractor/Cargo.toml" # The files that mention the fixed Rust toolchain version @@ -32,7 +36,7 @@ def run_codegen() -> None: run("bazel", "run", "//rust/codegen") except subprocess.CalledProcessError as error: print( - "\nCodegen failed. Carry out the instructions from step 4 in rust/updating-rust-analyzer.md manually.", + "\nCodegen failed. Carry out the instructions from step 5 in rust/updating-rust-analyzer.md manually.", file=sys.stderr, flush=True, ) @@ -61,12 +65,48 @@ def fetch(url: str) -> bytes: return response.read() -def get_compatible_rust_toolchain(rust_analyzer_version: str) -> str: - """Get the latest Rust toolchain released no later than rust-analyzer.""" - # Get the release date of the rust-analyzer version +def get_rust_analyzer_release_date(rust_analyzer_version: str) -> str: + """Get the release date of a rust-analyzer crate version.""" crate_url = f"https://crates.io/api/v1/crates/ra_ap_syntax/{rust_analyzer_version}" crate = json.loads(fetch(crate_url)) - rust_analyzer_release = crate["version"]["created_at"].split("T")[0] + return crate["version"]["created_at"].split("T")[0] + + +def update_rust_analyzer_sources(rust_analyzer_version: str) -> None: + """ + Update the rust-analyzer source archive used by the AST generator. + + Concretly, this updates `RUST_ANALYZER_SRC_TAG` and + `RUST_ANALYZER_SRC_INTEGRITY` in the MODULE.bazel file. + """ + + release_date = get_rust_analyzer_release_date(rust_analyzer_version) + archive_url = ( + "https://github.com/rust-lang/rust-analyzer/archive/refs/tags/" + f"{release_date}.tar.gz" + ) + archive = fetch(archive_url) + integrity = "sha256-" + base64.b64encode(hashlib.sha256(archive).digest()).decode() + + module = MODULE_BAZEL.read_text() + module = re.sub( + r'RUST_ANALYZER_SRC_TAG = "[^"]+"', + f'RUST_ANALYZER_SRC_TAG = "{release_date}"', + module, + count=1, + ) + module = re.sub( + r'RUST_ANALYZER_SRC_INTEGRITY = "[^"]+"', + f'RUST_ANALYZER_SRC_INTEGRITY = "{integrity}"', + module, + count=1, + ) + MODULE_BAZEL.write_text(module) + + +def get_compatible_rust_toolchain(rust_analyzer_version: str) -> str: + """Get the latest Rust toolchain released no later than rust-analyzer.""" + rust_analyzer_release = get_rust_analyzer_release_date(rust_analyzer_version) # `manifests.txt` is a list of all toolchains. The one we're interested in looks like # ``` @@ -168,20 +208,24 @@ def main() -> None: run("cargo", "update") commit_all("Cargo: Upgrade dependencies") - print_step(2, "Update the fixed Rust toolchain used by the extractor") + print_step(2, "Update the rust-analyzer sources used by the AST generator") + update_rust_analyzer_sources(new_rust_analyzer_version) + commit_all("Rust: Update rust-analyzer sources") + + print_step(3, "Update the fixed Rust toolchain used by the extractor") rust_toolchain = get_compatible_rust_toolchain(new_rust_analyzer_version) update_fixed_rust_toolchain_versions(rust_toolchain) commit_all("Rust: Update fixed toolchain") - print_step(3, "Regenerate vendored bazel files") + print_step(4, "Regenerate vendored bazel files") run("misc/bazel/3rdparty/update_tree_sitter_extractors_deps.sh") commit_all("Bazel: Regenerate vendored cargo dependencies") - print_step(4, "Run codegen") + print_step(5, "Run codegen") run_codegen() commit_all("Rust: Run codegen") - print_step(5, "Try compiling") + print_step(6, "Try compiling") run("bazel", "run", "//rust:install") diff --git a/rust/updating-rust-analyzer.md b/rust/updating-rust-analyzer.md index ed0f58a60d29..c68abb0b8fe3 100644 --- a/rust/updating-rust-analyzer.md +++ b/rust/updating-rust-analyzer.md @@ -28,7 +28,16 @@ pkg-config`. git commit -am 'Cargo: upgrade dependencies' --no-verify ``` -2. Update the fixed Rust toolchain used by the extractor. +2. Update the rust-analyzer sources used by the AST generator. + + In `MODULE.bazel`, update `RUST_ANALYZER_SRC_TAG` to the release date of the + new `ra_ap_` crates and update `RUST_ANALYZER_SRC_INTEGRITY` with the + integrity of the corresponding source archive. + + Commit the changes: + `git commit -am 'Rust: Update rust-analyzer sources'` + +3. Update the fixed Rust toolchain used by the extractor. The version should be updated to the latest release that precedes the new rust-analyzer version. @@ -38,7 +47,7 @@ pkg-config`. Commit the changes: `git commit -am 'Rust: Update fixed toolchain'` -3. Regenerate vendored bazel files (these allow faster builds, particularly on +4. Regenerate vendored bazel files (these allow faster builds, particularly on CI where it has to start from scratch each time), commit the changes: ``` misc/bazel/3rdparty/update_tree_sitter_extractors_deps.sh @@ -46,7 +55,7 @@ pkg-config`. git commit -am 'Bazel: regenerate vendored cargo dependencies' --no-verify ``` > [!NOTE] - > If in step 5 you also bump `rules_rust` or the Rust toolchain used for + > If in step 6 you also bump `rules_rust` or the Rust toolchain used for > building the extractor, those changes invalidate _all_ vendored files > (including the Python ones under `misc/bazel/3rdparty/py_deps`), not just > the tree-sitter ones. In that case run the umbrella script @@ -54,7 +63,7 @@ pkg-config`. > `py_deps` and `tree_sitter_extractors_deps`, and runs `bazel mod tidy`), > then commit all the regenerated files. -4. Run codegen +5. Run codegen ``` bazel run //rust/codegen ``` @@ -70,7 +79,7 @@ pkg-config`. new tests and/or downgrade/upgrade scripts down the line. -5. Try compiling +6. Try compiling ``` bazel run //rust:install ``` @@ -88,7 +97,7 @@ pkg-config`. to a more recent date while you're at it. * a toolchain and/or `rules_rust` bump invalidates the vendored files, so re-run `misc/bazel/3rdparty/update_cargo_deps.sh` (see the note in step - 3) and commit the regenerated files. + 4) and commit the regenerated files. * if it fails while compiling rust extractor code, you will need to adapt it to the new library version. * for example updating annotations in `annotations.py`, adding / removing @@ -98,11 +107,11 @@ pkg-config`. toolchain, running `rust/lint.py` might reformat or apply new lints to the code. -6. Check with CI if everything is in order. +7. Check with CI if everything is in order. -7. Run DCA with database caching disabled. Iterate on the code if needed. +8. Run DCA with database caching disabled. Iterate on the code if needed. -8. If in step 4 the schema was updated, add upgrade/downgrade scripts and a +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 merge conflicts (none of the other testing depends on having upgrade and downgrade scripts in place). See [Upgrading a language database