Skip to content

fix: skip packages without C examples in examples-random-c#13137

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-random-examples-c-2026-06-25
Draft

fix: skip packages without C examples in examples-random-c#13137
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-random-examples-c-2026-06-25

Conversation

@Planeshifter

@Planeshifter Planeshifter commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Fixes persistent random_examples CI failures (~53% failure rate, 16/30 runs in the last 30 days).

Root cause

examples-random-c uses PACKAGES_PATTERN='binding.gyp' to select random packages. NAPI utility packages (e.g. @stdlib/napi/argv-complex64, @stdlib/napi/argv-dataview-cast) have a binding.gyp for their Node.js native add-on but ship no examples/c/*.c file. When one of these 98 packages was selected from the pool of 1514, examples-c failed, aborting the workflow.

With ~98/1514 (~6.5%) packages lacking C examples, the probability that at least one of 10 randomly selected packages fails is ~49%, matching the observed 53% failure rate.

Fix

Add a pre-flight find guard before calling examples-c. If a selected package has no *.c files under its examples/ directory, it is silently skipped.

 examples-random-c: $(NODE_MODULES)
 	$(QUIET) $(MAKE) -f $(this_file) -s list-random-lib-pkgs PACKAGES_PATTERN='binding.gyp' | while read -r pkg; do \
+		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

This keeps the original PACKAGES_PATTERN='binding.gyp' selection pool (changing it to example.c would be excluded by FIND_LIB_PACKAGES_EXCLUDE_FLAGS which strips **/examples/* paths, silently returning 0 packages).

Validation

  • Guard tested locally: NAPI packages return exit 1 from guard (skipped), math packages return exit 0 (run)
  • 3-agent review on initial approach caught that FIND_LIB_PACKAGES_EXCLUDE_FLAGS excludes examples/ subdirs, leading to the guard approach

@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

`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.
@Planeshifter Planeshifter force-pushed the philipp/ci-fix-random-examples-c-2026-06-25 branch from 2b15081 to 8d44847 Compare June 25, 2026 14:54
@Planeshifter Planeshifter changed the title fix: select C example packages by example.c rather than binding.gyp fix: skip packages without C examples in examples-random-c Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants