Visual Studio Code, rebuilt in Rust
Rust
ci: check documents, advisories and SAFETY comments
rokartur6e17d2245d35
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.ymlindex e19f6e169cc..e27534bc34b 100644--- a/.github/actions/setup/action.yml+++ b/.github/actions/setup/action.yml@@ -30,6 +30,7 @@ runs:- uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stablewith:toolchain: stable+ components: clippy# Saved on failure too: the Windows and Linux tests are red today and would otherwise rebuild from scratch each run.# Saved from main only, as longbridge/gpui-component's CI does: five jobs' Rust and upstream caches pass the 10 GB# repository limit, and a pull request's caches, scoped to its ref, would evict main's.diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex ae3eb02ce99..5eccf2c5fab 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -37,7 +37,14 @@ jobs:toolchain: stable- run: bun port/tools/ledger-check.ts- run: bun test port/tools+ - run: bun port/tools/docs-check.ts- run: port/tools/check-licenses+ # native/deny.toml has the ignored advisories, each with its reason.+ - uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe # v2.0.20+ with:+ manifest-path: native/Cargo.toml+ arguments: --locked+ command: check advisoriestest:name: test (${{ matrix.os }} ${{ matrix.arch }})@@ -77,6 +84,11 @@ jobs:run: git config --global core.autocrlf false && git config --global core.longpaths true- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- uses: ./.github/actions/setup+ # clippy::undocumented_unsafe_blocks (native/Cargo.toml); every other clippy lint is off. The crates without+ # unsafe code forbid it, which the build itself checks (docs/memory-safety.md).+ - name: unsafe blocks have a SAFETY comment+ working-directory: native+ run: cargo clippy -p app -p exthost --all-targets --locked -- -A clippy::all- name: cargo testworking-directory: native# The dialog, keyboard and system-wide keybinding tests open X11 windows; GPUI's headless renderer uses Mesa's Vulkan.diff --git a/docs/memory-safety.md b/docs/memory-safety.mdindex 0df354d7c60..40cec10710f 100644--- a/docs/memory-safety.md+++ b/docs/memory-safety.md@@ -82,9 +82,9 @@ Each check fails on a violation. "Shown red" names the planted violation that pr|---|---|---|---|| No `unsafe` in the seven pure crates | `#![forbid(unsafe_code)]` at each crate root | Every build | An `unsafe` block added to `diff/src/lib.rs` stops the build. || An unsafe operation in an `unsafe fn` needs its own block | `unsafe_op_in_unsafe_fn = "deny"` in `native/Cargo.toml` | Every build | A raw pointer read without a block in an `unsafe fn` of `exthost` stops the build. |-| Each block has a `SAFETY` comment | `clippy::undocumented_unsafe_blocks = "deny"` in `native/Cargo.toml` | `cargo clippy --workspace --all-targets --locked -- -A clippy::all` | A block without a comment in `exthost/src/utc.rs` fails clippy. |-| `unsafe` only in the listed files | `bun port/tools/docs-check.ts` | Seconds, anywhere | A file with `unsafe` that is not in the inventory fails the check. |-| No known vulnerable dependency | `cargo deny --locked check advisories` with `native/deny.toml` | Seconds, needs the advisory database | The first run on the lock file failed on four advisories. |+| Each block has a `SAFETY` comment | `clippy::undocumented_unsafe_blocks = "deny"` in `native/Cargo.toml` | `cargo clippy -p app -p exthost --all-targets --locked -- -A clippy::all`, in the `test` jobs of `.github/workflows/ci.yml` | A block without a comment in `exthost/src/utc.rs` fails clippy. |+| `unsafe` only in the listed files | `bun port/tools/docs-check.ts` | Seconds, anywhere, and in the `checks` job of `.github/workflows/ci.yml` | A file with `unsafe` that is not in the inventory fails the check. |+| No known vulnerable dependency | `cargo deny --locked check advisories` with `native/deny.toml` | Seconds, needs the advisory database. In the `checks` job of `.github/workflows/ci.yml` | The first run on the lock file failed on four advisories. |Notes on the checks:@@ -93,7 +93,7 @@ Notes on the checks:- Windows: `port/tools/windows-build 'cargo xwin clippy -p app -p exthost --all-targets --target x86_64-pc-windows-msvc --locked -- -A clippy::all'`- Linux: `port/tools/linux-build 'cd native && rustup component add clippy && cargo clippy --workspace --all-targets --locked -- -A clippy::all'`. The image of `port/tools/linux/Dockerfile` has no clippy, so each run adds it.- An ignored advisory in `native/deny.toml` has a reason. If the reason no longer holds, remove the entry.-- The clippy and deny runs are not in a CI workflow yet. They belong in the workflow that runs on every push, one clippy run per OS.+- `.github/workflows/ci.yml` runs clippy in each `test` job, so once per OS. The Linux and Windows jobs are `expected-red` until their tests pass: a clippy failure there shows in the job but does not fail the workflow. Until then the `port/tools/windows-build` and `port/tools/linux-build` commands of this list are the gate for those two.## What the checks do not prove