Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ jobs:
exit "$EXIT_CODE"
fi

lint-crates:
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
Expand Down
36 changes: 36 additions & 0 deletions deps/crates/check-deps-in-sync-with-v8.sh
Original file line number Diff line number Diff line change
@@ -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

@legendecas legendecas Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Commands before && are exempt from set -e. This script exits with non-zero code because [ -z happens to be the last command.

To avoid someone later add a new command after this line, I think it will be better to explicitly exit with non-zero code.

Suggested change
[ -z "$MISMATCH" ] && echo "All versions match" >&2
[ -z "$MISMATCH" ] && echo "All versions match" >&2 || exit 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TIL, thanks! Another way would be to split it in two lines

Suggested change
[ -z "$MISMATCH" ] && echo "All versions match" >&2
[ -z "$MISMATCH" ]
echo "All versions match" >&2

But yeah, like René said, it looks like is going to be superseded by #64191 (comment) so I'm going to hold off from implementing changes here

Loading