Skip to content

Commit fc9550c

Browse files
jmsundarclaude
andcommitted
fix(scripts): [DEVOPS-2394] pin cx-contrib SHA in build-nodejs.sh
- Drop opentelemetry-js clone + OPENTELEMETRY_JS_PATH. Unused since cx-js was dropped (we resolve @opentelemetry/instrumentation from npm now). - Pin CX_CONTRIB_SHA to match publish-sandbox.sh and the publish workflow so local builds don't drift from CI. - Unify clone path under .build-cache/opentelemetry-js-contrib so both scripts share one cache on dev machines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 82c1eef commit fc9550c

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

scripts/build-nodejs.sh

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
#!/bin/bash
2-
# This script builds the Node.js Lambda layer for OpenTelemetry instrumentation
2+
# Builds the Node.js Lambda layer for local dev.
33
#
4-
# The script expects the dependencies to be cloned in specific locations
5-
# relative to this repository's root directory.
4+
# Auto-clones the pinned coralogix/opentelemetry-js-contrib fork to .build-cache/
5+
# on first run. Keep CX_CONTRIB_SHA in sync with:
6+
# - scripts/publish-sandbox.sh
7+
# - .github/workflows/publish-extend-otel-layer.yml
8+
# - UPSTREAM.md fork-points table
69
#
7-
# If you encounter build issues, try cleaning first:
8-
# git clean -xdf nodejs
10+
# Override the clone path with OPENTELEMETRY_JS_CONTRIB_PATH (e.g. to point at
11+
# a local checkout you are hacking on).
12+
#
13+
# If you hit build issues, try: git clean -xdf nodejs
914

1015
set -euo pipefail
1116

1217
ROOT_DIR=$(git rev-parse --show-toplevel)
1318

14-
# Expected by build_nodejs_layer.sh
15-
if [ -z "${OPENTELEMETRY_JS_CONTRIB_PATH:-}" ]; then
16-
export OPENTELEMETRY_JS_CONTRIB_PATH="$ROOT_DIR/opentelemetry-js-contrib-cx"
17-
fi
18-
19-
if [ -z "${OPENTELEMETRY_JS_PATH:-}" ]; then
20-
export OPENTELEMETRY_JS_PATH="$ROOT_DIR/opentelemetry-js"
21-
fi
22-
19+
CX_CONTRIB_REPO="https://github.com/coralogix/opentelemetry-js-contrib.git"
20+
CX_CONTRIB_SHA="3a9691a699ddd06c3644eec70bf4b50cc4217ba3"
21+
CX_CONTRIB_CACHE="${OPENTELEMETRY_JS_CONTRIB_PATH:-$ROOT_DIR/.build-cache/opentelemetry-js-contrib}"
2322

24-
if [ ! -d "$OPENTELEMETRY_JS_CONTRIB_PATH" ]; then
25-
git clone git@github.com:coralogix/opentelemetry-js-contrib.git "$OPENTELEMETRY_JS_CONTRIB_PATH" -b coralogix-autoinstrumentation
23+
echo "==> resolving cx-contrib fork at $CX_CONTRIB_SHA"
24+
if [ ! -d "$CX_CONTRIB_CACHE/.git" ]; then
25+
mkdir -p "$(dirname "$CX_CONTRIB_CACHE")"
26+
git clone --filter=blob:none "$CX_CONTRIB_REPO" "$CX_CONTRIB_CACHE"
2627
fi
28+
git -C "$CX_CONTRIB_CACHE" fetch --quiet origin "$CX_CONTRIB_SHA" 2>/dev/null || git -C "$CX_CONTRIB_CACHE" fetch --quiet origin
29+
git -C "$CX_CONTRIB_CACHE" checkout --quiet "$CX_CONTRIB_SHA"
2730

28-
if [ ! -d "$OPENTELEMETRY_JS_PATH" ]; then
29-
git clone git@github.com:coralogix/opentelemetry-js.git "$OPENTELEMETRY_JS_PATH" -b coralogix-autoinstrumentation
30-
fi
31+
export OPENTELEMETRY_JS_CONTRIB_PATH
32+
OPENTELEMETRY_JS_CONTRIB_PATH="$(cd "$CX_CONTRIB_CACHE" && pwd)"
3133

3234
"$ROOT_DIR/scripts/build_nodejs_layer.sh"
3335

34-
# Useful for using the layer locally
36+
# Unzip layer next to the zip for local Lambda-layer poking
3537
pushd "$ROOT_DIR/nodejs/packages/layer" >/dev/null
3638
rm -rf ./build/layer && unzip -q ./build/layer.zip -d ./build/layer
3739
popd >/dev/null

0 commit comments

Comments
 (0)