Skip to content

Commit 9f87136

Browse files
committed
verify-action-build: support Dart-based actions (setup-dart)
Actions such as dart-lang/setup-dart compile their source from Dart to JavaScript in the `build` npm script (`dart compile js ...`) and then bundle via a bare `ncc build` invocation in `dist`. The node:slim base image has neither the Dart SDK nor `@vercel/ncc`, so the build loop silently fell through to the `npx ncc build --source-map` fallback, producing an incomplete rebuild missing `main.cjs` and `sig.txt`. When a `pubspec.yaml` is detected at the repo root, install the Dart SDK from Google's apt repo, install `@vercel/ncc` globally, and run `dart pub get` so the pubspec dependencies resolve before compilation. Also add `all` to the list of candidate npm scripts so actions whose `all` script chains build+package steps (the setup-dart convention) run as a single step. With these changes, `verify-action-build --from-pr 739` against dart-lang/setup-dart@e51d8e571e22 reports "All compiled JavaScript matches the rebuild". Generated-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e0f0ac7 commit 9f87136

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

utils/verify_action_build/dockerfiles/build_action.Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@ ARG COMMIT_HASH
3232

3333
RUN git clone "$REPO_URL" . && git checkout "$COMMIT_HASH"
3434

35+
# Dart-based actions (e.g. dart-lang/setup-dart) compile Dart sources with
36+
# `dart compile js` in their npm build script and then bundle via a bare
37+
# `ncc build` invocation in their dist script. Neither is available in the
38+
# node:slim base, so detect `pubspec.yaml` at the repo root and install
39+
# both the Dart SDK (from Google's apt repo) and `@vercel/ncc` globally so
40+
# the action's own `npm run` scripts can execute unmodified.
41+
ENV PATH="/usr/lib/dart/bin:${PATH}"
42+
RUN if [ -f pubspec.yaml ]; then \
43+
apt-get update && \
44+
apt-get install -y --no-install-recommends ca-certificates curl gnupg && \
45+
curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub \
46+
| gpg --dearmor -o /usr/share/keyrings/dart.gpg && \
47+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/dart.gpg] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main" \
48+
> /etc/apt/sources.list.d/dart_stable.list && \
49+
apt-get update && \
50+
apt-get install -y --no-install-recommends dart && \
51+
rm -rf /var/lib/apt/lists/* && \
52+
npm install -g @vercel/ncc && \
53+
dart pub get && \
54+
echo "dart-sdk: installed (pubspec.yaml detected)" >> /build-info.log && \
55+
echo "global-ncc: installed (pubspec.yaml detected)" >> /build-info.log && \
56+
echo "dart-pub-get: ran" >> /build-info.log; \
57+
fi
58+
3559
# Detect action type from action.yml or action.yaml.
3660
# For monorepo sub-actions (SUB_PATH set), check <sub_path>/action.yml first,
3761
# falling back to the root action.yml.
@@ -193,7 +217,7 @@ RUN OUT_DIR=$(cat /out-dir.txt); \
193217
fi && \
194218
if [ "$BUILD_DONE" = "false" ]; then \
195219
cd "$BUILD_DIR" && \
196-
for step in build package start; do \
220+
for step in all build package start; do \
197221
if $RUN_CMD run "$step" 2>/dev/null; then \
198222
echo "build-step: $RUN_CMD run $step (in $BUILD_DIR)" >> /build-info.log; \
199223
cd /action && \

0 commit comments

Comments
 (0)