Skip to content

Commit 2a3218c

Browse files
committed
tools: add inspector_protocol updater
1 parent 5cf3c3e commit 2a3218c

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

.github/workflows/tools.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ on:
2525
- gyp-next
2626
- histogram
2727
- icu
28+
- inspector_protocol
2829
- libuv
2930
- llhttp
3031
- minimatch
@@ -149,6 +150,14 @@ jobs:
149150
cat temp-output
150151
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
151152
rm temp-output
153+
- id: inspector_protocol
154+
subsystem: deps
155+
label: dependencies, inspector
156+
run: |
157+
./tools/dep_updaters/update-inspector-protocol.sh > temp-output
158+
cat temp-output
159+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
160+
rm temp-output
152161
- id: libuv
153162
subsystem: deps
154163
label: dependencies
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update inspector_protocol in the source tree to the version same with V8's.
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
8+
# shellcheck disable=SC1091
9+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
10+
11+
echo "Making temporary workspace..."
12+
13+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
14+
15+
cd "$WORKSPACE"
16+
17+
git clone https://chromium.googlesource.com/deps/inspector_protocol.git
18+
19+
INSPECTOR_PROTOCOL_DIR="$WORKSPACE/inspector_protocol"
20+
21+
echo "Comparing latest upstream with current revision"
22+
23+
set +e
24+
python $BASE_DIR/tools/inspector_protocol/roll.py \
25+
--ip_src_upstream "$INSPECTOR_PROTOCOL_DIR" \
26+
--node_src_downstream "$BASE_DIR"
27+
STATUS="$?"
28+
set -e
29+
30+
if [ "$STATUS" = "0" ]; then
31+
echo "Skipped because inspector_protocol is on the latest version."
32+
exit 0
33+
fi
34+
35+
python $BASE_DIR/tools/inspector_protocol/roll.py \
36+
--ip_src_upstream "$INSPECTOR_PROTOCOL_DIR" \
37+
--node_src_downstream "$BASE_DIR" \
38+
--force
39+
40+
NEW_VERSION=$(grep "Revision:" "$DEPS_DIR/inspector_protocol/README.node" | sed -n "s/^Revision: \(\\w*\)/\1/p")
41+
42+
# Update the version number on maintaining-dependencies.md
43+
# and print the new version as the last line of the script as we need
44+
# to add it to $GITHUB_ENV variable
45+
finalize_version_update "inspector_protocol" "$NEW_VERSION"

tools/inspector_protocol/roll.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ def RunCmd(cmd):
3838
return stdoutdata.decode('utf-8')
3939

4040

41-
def CheckRepoIsClean(path, suffix):
41+
def CheckRepoIsClean(path):
4242
os.chdir(path) # As a side effect this also checks for existence of the dir.
4343
# If path isn't a git repo, this will throw and exception.
4444
# And if it is a git repo and 'git status' has anything interesting to say,
4545
# then it's not clean (uncommitted files etc.)
4646
if len(RunCmd(['git', 'status', '--porcelain'])) != 0:
4747
raise Exception('%s is not a clean git repo (run git status)' % path)
48-
if not path.endswith(suffix):
49-
raise Exception('%s does not end with /%s' % (path, suffix))
5048

5149

5250
def CheckRepoIsNotAtMainBranch(path):
@@ -85,6 +83,16 @@ def ReadV8IPRevision(node_src_path):
8583
return line[len(REVISION_LINE_PREFIX):]
8684
raise Exception('No V8 inspector protocol revision found')
8785

86+
87+
def ReadNodeIPRevision(node_src_path):
88+
lines = open(os.path.join(node_src_path, 'deps/inspector_protocol/README.node')).readlines()
89+
for line in lines:
90+
line = line.strip()
91+
if line.startswith(REVISION_LINE_PREFIX):
92+
return line[len(REVISION_LINE_PREFIX):]
93+
raise Exception('No Node inspector protocol revision found')
94+
95+
8896
def CheckoutRevision(path, revision):
8997
os.chdir(path)
9098
return RunCmd(['git', 'checkout', revision])
@@ -114,8 +122,8 @@ def main(argv):
114122
upstream = os.path.normpath(os.path.expanduser(args.ip_src_upstream))
115123
downstream = os.path.normpath(os.path.expanduser(
116124
args.node_src_downstream))
117-
CheckRepoIsClean(upstream, '/src')
118-
CheckRepoIsClean(downstream, '/node')
125+
CheckRepoIsClean(upstream)
126+
CheckRepoIsClean(downstream)
119127
CheckRepoIsInspectorProtocolCheckout(upstream)
120128
# Check that the destination Git repo isn't at the main branch - it's
121129
# generally a bad idea to check into the main branch, so we catch this
@@ -124,6 +132,10 @@ def main(argv):
124132

125133
# Read V8's inspector_protocol revision
126134
v8_ip_revision = ReadV8IPRevision(downstream)
135+
node_ip_revision = ReadNodeIPRevision(downstream)
136+
if v8_ip_revision == node_ip_revision:
137+
print('Node is already at V8\'s inspector_protocol revision %s - nothing to do.' % v8_ip_revision)
138+
sys.exit(0)
127139
print('Checking out %s into %s ...' % (upstream, v8_ip_revision))
128140
CheckoutRevision(upstream, v8_ip_revision)
129141

0 commit comments

Comments
 (0)