-
Notifications
You must be signed in to change notification settings - Fork 990
fix(cli): retry + cache prebuild downloads in build-dist; add docker test #4051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||
| # | ||||||||||||||||
| # Reproduce the GitHub Actions Linux CLI build inside a Docker container. | ||||||||||||||||
| # Mirrors `.github/workflows/build-cli.yml` so we can validate the full | ||||||||||||||||
| # install + build + smoke-test flow without cutting a release. | ||||||||||||||||
| # | ||||||||||||||||
| # Usage: | ||||||||||||||||
| # packages/cli/scripts/build-dist-linux-docker.sh [linux-x64|linux-arm64] | ||||||||||||||||
| # | ||||||||||||||||
| # Outputs the tarball at packages/cli/dist/superset-<target>.tar.gz inside | ||||||||||||||||
| # the container's copy of the repo and runs the same require() smoke test | ||||||||||||||||
| # the CI workflow runs. | ||||||||||||||||
| set -euo pipefail | ||||||||||||||||
|
|
||||||||||||||||
| TARGET="${1:-linux-x64}" | ||||||||||||||||
| case "$TARGET" in | ||||||||||||||||
| linux-x64) PLATFORM="linux/amd64"; NODE_ARCH="x64" ;; | ||||||||||||||||
| linux-arm64) PLATFORM="linux/arm64"; NODE_ARCH="arm64" ;; | ||||||||||||||||
| *) echo "Usage: $0 [linux-x64|linux-arm64]" >&2; exit 1 ;; | ||||||||||||||||
| esac | ||||||||||||||||
|
|
||||||||||||||||
| REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)" | ||||||||||||||||
| BUN_VERSION="$(cat "$REPO_ROOT/.bun-version")" | ||||||||||||||||
| NODE_VERSION="22.22.2" | ||||||||||||||||
|
|
||||||||||||||||
| echo "[docker-build] target=$TARGET platform=$PLATFORM bun=$BUN_VERSION node=$NODE_VERSION" | ||||||||||||||||
| echo "[docker-build] repo: $REPO_ROOT" | ||||||||||||||||
|
|
||||||||||||||||
| # Mount the repo read-only and copy it into a writable workdir inside the | ||||||||||||||||
| # container so the host's darwin-arm64 node_modules don't bleed in. The | ||||||||||||||||
| # container does its own `bun install` against the lockfile. | ||||||||||||||||
| docker run --rm --platform "$PLATFORM" \ | ||||||||||||||||
| -v "$REPO_ROOT:/host:ro" \ | ||||||||||||||||
| -e TARGET="$TARGET" \ | ||||||||||||||||
| -e NODE_ARCH="$NODE_ARCH" \ | ||||||||||||||||
| -e NODE_VERSION="$NODE_VERSION" \ | ||||||||||||||||
| -e RELAY_URL="${RELAY_URL:-https://relay.superset.sh}" \ | ||||||||||||||||
| -e SUPERSET_API_URL="${SUPERSET_API_URL:-https://api.superset.sh}" \ | ||||||||||||||||
| -e SUPERSET_WEB_URL="${SUPERSET_WEB_URL:-https://app.superset.sh}" \ | ||||||||||||||||
| "oven/bun:${BUN_VERSION}" bash -euxc ' | ||||||||||||||||
| apt-get update -qq | ||||||||||||||||
| apt-get install -y --no-install-recommends \ | ||||||||||||||||
| curl python3 make g++ ca-certificates xz-utils rsync >/dev/null | ||||||||||||||||
|
|
||||||||||||||||
| curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz" \ | ||||||||||||||||
| | tar -xJ -C /usr/local --strip-components=1 | ||||||||||||||||
| node --version | ||||||||||||||||
| bun --version | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+48
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The whole motivation for this PR is that a transient 502 from GitHub/nodejs.org kills the pipeline. The Node.js installation step inside the container ( Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/cli/scripts/build-dist-linux-docker.sh
Line: 48-49
Comment:
**Single-shot `curl | tar` in the container setup**
The whole motivation for this PR is that a transient 502 from GitHub/nodejs.org kills the pipeline. The Node.js installation step inside the container (`curl -fsSL … | tar -xJ`) uses bare curl with no retry flags, so a transient failure here still kills the docker run. Since this is a developer-local script (not CI), the impact is low, but it's inconsistent with the fix being applied to `build-dist.ts`. Adding `--retry 3 --retry-delay 2 --retry-all-errors` to this curl call would make it consistent.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||
| rsync -a --exclude=node_modules --exclude=dist --exclude=.next /host/ /work/ | ||||||||||||||||
| cd /work | ||||||||||||||||
|
|
||||||||||||||||
| # Mirrors `.github/workflows/build-cli.yml` Linux install step. | ||||||||||||||||
| # Bun occasionally hits transient integrity-check failures on cold caches | ||||||||||||||||
| # in Docker, retry once before giving up. | ||||||||||||||||
| bun install --frozen --ignore-scripts || \ | ||||||||||||||||
| (rm -rf ~/.bun/install/cache && bun install --frozen --ignore-scripts) | ||||||||||||||||
| PTY_DIR=$(ls -d node_modules/.bun/node-pty@*/node_modules/node-pty) | ||||||||||||||||
| (cd "$PTY_DIR" && npx --yes node-gyp rebuild) | ||||||||||||||||
|
Comment on lines
+58
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the Bun store contains more than one ♻️ Proposed fix- PTY_DIR=$(ls -d node_modules/.bun/node-pty@*/node_modules/node-pty)
- (cd "$PTY_DIR" && npx --yes node-gyp rebuild)
+ mapfile -t PTY_DIRS < <(ls -d node_modules/.bun/node-pty@*/node_modules/node-pty 2>/dev/null || true)
+ if [[ ${`#PTY_DIRS`[@]} -ne 1 ]]; then
+ echo "Expected exactly 1 node-pty in Bun store, found ${`#PTY_DIRS`[@]}" >&2; exit 1
+ fi
+ (cd "${PTY_DIRS[0]}" && npx --yes node-gyp rebuild)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| npm rebuild @parcel/watcher | ||||||||||||||||
|
|
||||||||||||||||
| cd packages/cli | ||||||||||||||||
| bun run build:dist --target="$TARGET" | ||||||||||||||||
|
|
||||||||||||||||
| DIST="./dist/superset-${TARGET}" | ||||||||||||||||
| "$DIST/bin/superset" --version | ||||||||||||||||
| "$DIST/bin/superset" --help | head -5 | ||||||||||||||||
| "$DIST/lib/node" --version | ||||||||||||||||
| NODE_PATH="$DIST/lib/node_modules" "$DIST/lib/node" -e " | ||||||||||||||||
| for (const m of [\"better-sqlite3\", \"node-pty\", \"@parcel/watcher\", \"libsql\"]) { | ||||||||||||||||
| require(m); | ||||||||||||||||
| console.log(m, \"OK\"); | ||||||||||||||||
| } | ||||||||||||||||
| " | ||||||||||||||||
| echo "[docker-build] tarball: $(ls -la dist/superset-${TARGET}.tar.gz)" | ||||||||||||||||
| ' | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NODE_VERSIONdiffers from the bundled runtimeThe Docker script hardcodes
NODE_VERSION="22.22.2"for the container's build tooling, whilebuild-dist.tsdefinesNODE_VERSION = "22.13.0"as the Node runtime bundled into the distribution. These intentionally serve different roles, but they're both Node 22.x (ABI 127) so native modules compiled against 22.22.2 in the container will still be compatible with the bundled 22.13.0. However, if the CI workflow's build tool Node version ever diverges from 22.x (e.g., bumped to v24), the ABI assumption breaks and the smoke test would pass locally while CI fails. Consider extracting the build-tool Node version from.nvmrc/build-cli.ymlor at least adding a comment linking the two constants.Prompt To Fix With AI