diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 352bfd1e23bbea..225094026ffe7d 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -161,6 +161,24 @@ jobs: exit "$EXIT_CODE" fi + lint-rust: + if: github.event.pull_request.draft == false + runs-on: ubuntu-slim + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + sparse-checkout: | + tools/nix/pkgs.nix + deps/v8/DEPS + deps/crates/check-deps-in-sync-with-v8.sh + deps/crates/Cargo.toml + deps/crates/Cargo.lock + sparse-checkout-cone-mode: false + - uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5 + - name: Validate dependencies + run: nix-shell -I nixpkgs=./tools/nix/pkgs.nix --pure -p cacert gawk git jq tomlq --run ./deps/crates/check-deps-in-sync-with-v8.sh + lint-py: if: github.event.pull_request.draft == false runs-on: ubuntu-slim diff --git a/deps/crates/check-deps-in-sync-with-v8.sh b/deps/crates/check-deps-in-sync-with-v8.sh new file mode 100755 index 00000000000000..d6538d695eb81a --- /dev/null +++ b/deps/crates/check-deps-in-sync-with-v8.sh @@ -0,0 +1,36 @@ +#!/bin/sh +#! nix-shell --pure -i bash -p cacert gawk git jq tomlq +set -e + +BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) + +THIRD_PARTY_REPO=$(mktemp -d) +DEP_VERSIONS=$(mktemp) + +cleanup () { + EXIT_CODE=$? + rm -f "$DEP_VERSIONS" + rm -rf "$THIRD_PARTY_REPO" + exit $EXIT_CODE +} + +trap cleanup INT TERM EXIT + +tq -f "$BASE_DIR/deps/crates/Cargo.lock" -o json '.package' > "$DEP_VERSIONS" + + +REV=$(awk -F"'" "/'\\/chromium\\/src\\/third_party\\/rust'/{ print \$8 }" "$BASE_DIR/deps/v8/DEPS") +git clone --depth=1 --revision "$REV" https://chromium.googlesource.com/chromium/src/third_party/rust "$THIRD_PARTY_REPO" + +MISMATCH= +for dep in $(tq -f "$BASE_DIR/deps/crates/Cargo.toml" -o json '.dependencies' | jq -r 'keys | .[]'); do + CURRENT_VERSION=$(jq --arg dep_name "$dep" -r '.[] | select(.name == $dep_name) | .version' < "$DEP_VERSIONS") + REQUIRED_VERSION=$(grep '^Version: ' "$THIRD_PARTY_REPO/$dep"/*/README.chromium | awk '{ print $2 }') + + [ "$CURRENT_VERSION" = "$REQUIRED_VERSION" ] || { + echo "$dep should be on version $REQUIRED_VERSION, found $CURRENT_VERSION" >&2 + MISMATCH=1 + } +done + +[ -z "$MISMATCH" ] && echo "All versions match" >&2