From 8d44847a664fe2e525c6c77a6a2281276aca9a80 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Jun 2026 14:43:22 +0000 Subject: [PATCH] fix: skip packages without C examples in examples-random-c `examples-random-c` uses `PACKAGES_PATTERN='binding.gyp'` to select random packages. NAPI utility packages (e.g. `@stdlib/napi/argv-*`) have `binding.gyp` for their Node.js native add-on but ship no C example file. When one of these packages was selected, `examples-c` failed to compile, causing the `random_examples` CI workflow to fail on ~53% of runs (16/30 in 30 days). Add a pre-flight guard that checks for `*.c` files inside the package's `examples/` directory before invoking `examples-c`. Packages without C examples are silently skipped, leaving the `binding.gyp` selection pool intact while eliminating the false-positive failures. --- tools/make/lib/examples/c.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/make/lib/examples/c.mk b/tools/make/lib/examples/c.mk index 6da9286142c7..62675c8376c7 100644 --- a/tools/make/lib/examples/c.mk +++ b/tools/make/lib/examples/c.mk @@ -114,11 +114,13 @@ examples-c-files: #/ examples-random-c: $(NODE_MODULES) $(QUIET) $(MAKE) -f $(this_file) -s list-random-lib-pkgs PACKAGES_PATTERN='binding.gyp' | while read -r pkg; do \ - echo ""; \ - echo "Running example: $$pkg"; \ - NODE_ENV="$(NODE_ENV_EXAMPLES)" \ - NODE_PATH="$(NODE_PATH_EXAMPLES)" \ - $(MAKE) -f $(this_file) examples-c EXAMPLES_FILTER="$$pkg/.*" || exit 1; \ + if find "$$pkg/examples" -name "*.c" 2>/dev/null | grep -q .; then \ + echo ""; \ + echo "Running example: $$pkg"; \ + NODE_ENV="$(NODE_ENV_EXAMPLES)" \ + NODE_PATH="$(NODE_PATH_EXAMPLES)" \ + $(MAKE) -f $(this_file) examples-c EXAMPLES_FILTER="$$pkg/.*" || exit 1; \ + fi; \ done .PHONY: examples-random-c