WIP: ci: add [free|open|net]BSD ci test jobs

bitcoin/bitcoin: PR #36147

1 minor finding · 7 suggestions

Findings

Link

[minor] · FreeBSD host example writes into the developer's default datadir path

The new host-mode example preserves the real HOME, so the existing sentinel write aborts CI when ~/.bitcoin is a directory, or leaves a regular file there otherwise.

Location: ci/README.md:54 (head).

Details and suggested fix

With DANGER_RUN_CI_ON_HOST=1, the wrapper executes 03_test_script.sh directly. Its echo > "${HOME}/.bitcoin" runs under errexit before the depends build. If the developer already has a default datadir, the redirect fails. Otherwise, it leaves a file that prevents creation of the default datadir until removed. These consequences follow from source inspection, not an executed host run. Use a throwaway home in the example, such as HOME="$(mktemp -d)", so the sentinel does not touch the developer's real datadir path.


Optional improvements

Link

[suggestion] · The new VM action inherits repository-default token permissions

The workflow does not enforce read-only token permissions for the newly allowed VM action; its effective token authority depends on repository settings, and its cache authority remains unverified.

Location: .github/workflows/ci.yml:619 (head).

Details and suggested fix

Declare permissions: contents: read on the bsd job so enabling vmactions/freebsd-vm@v1 does not also depend on repository token defaults. The action runs before shared-cache saves on eligible default-branch pushes and requests prepared-image caching, so its cache authority also needs an explicit trust decision. Its implementation and credential access were not inspected, and no compromise path is established; read-only token permissions alone would not establish cache isolation. The documented policy against general hash pinning also means a SHA pin is a separate tradeoff, not a substitute for these boundaries.


Link

[suggestion] · The stated BSD testing scope exceeds the FreeBSD-only implementation

Only FreeBSD gains runtime tests; NetBSD and OpenBSD remain cross-build-only, so this head does not exercise the platform-specific causes of the two motivating regressions.

Location: .github/workflows/ci.yml:577 (head).

Details and suggested fix

The new matrix has one FreeBSD entry, while the remaining NetBSD and OpenBSD configurations explicitly disable unit and functional tests. A FreeBSD VM cannot exercise the NetBSD descriptor ceiling from #36078 or the OpenBSD ephemeral-port behavior from #36145. Rescope the title and description to FreeBSD, including the single action that needs enabling. Also remove the description's REST-timeout change, which is absent from this patch. This makes the proposed coverage and infrastructure cost assessable without requiring the other BSD jobs in this series.


Link

[suggestion] · Replacing FreeBSD Cross removes Linux-to-FreeBSD toolchain coverage

Native depends still builds FreeBSD binaries, but the replacement no longer exercises the Linux Clang, FreeBSD SDK/sysroot, and LLVM cross-toolchain configuration.

Location: .github/workflows/ci.yml:455 (base).

Details and suggested fix

The deleted job explicitly built depends with clang --target=x86_64-unknown-freebsd, a FreeBSD sysroot, lld, and LLVM 23 tools. The native configuration instead guesses HOST inside the VM and uses its local toolchain. Retaining the cross job alongside the native tests would preserve checks of SDK and cross-toolchain integration that native compilation cannot provide. If losing that configuration is intentional, state that tradeoff explicitly rather than treating the native build as equivalent cross-build coverage.


Link

[suggestion] · The FreeBSD VM does not configure addresses needed by bind tests

Unless the VM already has the required routable addresses, two bind tests skip without failing CI; this is additional coverage to enable, not a regression, and the skips were not observed.

Location: .github/workflows/ci.yml:633 (head).

Details and suggested fix

Host mode does not set BIND_TEST_ROUTABLE_IPV4 or BIND_TEST_ROUTABLE_IPV6, so feature_bind_port_discover and feature_bind_port_externalip use 1.1.1.5 and, for discovery, 1111:1111::5. They catch startup bind failures and raise SkipTest before checking address discovery and external-IP port selection. Before ./ci/test_run_all.sh, add the aliases documented in the tests to an active non-loopback VM interface: ifconfig <iface> 1.1.1.5/32 alias and ifconfig <iface> inet6 1111:1111::5/128 alias. Configure them at runtime rather than relying on the cached preparation step.


Link

[suggestion] · The FreeBSD test exclusions lack durable reasons and follow-up references

The configuration excludes two functional tests without recording the reported FreeBSD failure and excessive runtime, leaving no in-tree explanation of when to restore that coverage.

Location: ci/test/00_setup_env_freebsd_native.sh:14 (head).

Details and suggested fix

The PR description says feature_reindex_init fails and p2p_private_broadcast_retry_v1 takes extraordinarily long, but the runner only logs Excluding <name>. Add a short comment beside this setting with each reason, a follow-up issue, and the condition for re-enabling the test. That preserves the current runnable selection while making the acknowledged coverage gaps traceable without the PR description.


Link

[suggestion] · The FreeBSD job commit bundles shared CI behavior changes

Commit 168994444fac93f325378c5f313cf511c1c3365f mixes the FreeBSD workflow replacement with shared interpreter and host-portability changes, making their effects on existing jobs harder to review independently.

Location: ci/test/03_test_script.sh:16 at 168994444fac (commit) (commit).

Details and suggested fix

Keep d60f8c78854693d7f9a4a55b423147fe1e49ee82 as the standalone lsof fix and c2e1772bc94c46d8144611f45ac220a144370074 as the PULL_FILTER refactor. Before 168994444fac93f325378c5f313cf511c1c3365f, add a preparatory commit containing the PYTHON default and consumers, ${MAKE:-make} plumbing, sysctl fallback, host-mode CCACHE_TEMPDIR creation, and BSD system-info and CONFIG_SHELL branches. Explain the shared behavior changes there. Moving the Python default and consumers together, retaining the make fallback, and using the existing temporary-cache default preserves their prerequisites. Drop the unused CI_LIMIT_NOFILE hook or introduce it with a configuration that needs it. The final commit can then focus on the native job, environment, documentation, SDK removal, and BSD installation skip. This is a review-flow improvement, not a final-tree defect.


Link

[suggestion] · The new Python override selects different interpreters within one CI run

No tracked configuration overrides PYTHON, but callers that do will select it for some CI scripts while the unit-test wrapper and IWYU helpers still use python3.

Location: ci/test/00_setup_env.sh:40 (head).

Details and suggested fix

The new export is included in the Docker settings allow-list, so a host-provided PYTHON now reaches containers as well as selecting 02_run_container.py. Functional tests and several helpers honor it, but WITH_SANITIZER_ENV and the IWYU calls remain hard-coded. A host-specific interpreter path may also be unavailable inside the container; the documented clean environment avoids accidental inheritance but does not complete the override. Use "$PYTHON" consistently for these CI-owned invocations and document that Docker callers must select an interpreter available inside the container.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

The historical motivation for in-repository BSD CI was to catch platform breakage before merging, rather than repeatedly discover it in external nightly builds and require follow-up fixes.

At the pinned base, the FreeBSD job explicitly disables unit and functional tests. The head enables their normal execution inside FreeBSD 15.1, with feature_reindex_init and p2p_private_broadcast_retry_v1 excluded. This changes when maintainers receive runtime feedback, not Bitcoin's protocol rules.

Source 1 · Source 2

The preceding FreeBSD cross-build was deliberately proposed as an alternative to native VM CI because the native proposal had permissions/caching difficulties and potential determinism issues. Linux/Clang cross-compilation also offered a possible path toward FreeBSD binaries produced through Guix.

This explains why the base has a Linux-hosted Clang toolchain and FreeBSD SDK despite not executing the resulting tests. The head replaces that arrangement for FreeBSD, while retaining the other BSD cross-build jobs. The earlier choice addressed build coverage and infrastructure constraints, rather than establishing that compilation alone covered runtime behavior.

Source 1 · Source 2

BSD test portability has historically included adapting operating-system inspection tools and suppressing spurious diagnostics. The earlier test-support work made lsof optional, suppressed its NetBSD warnings, and removed OpenBSD support from get_bind_addrs because that platform does not provide lsof.

The head installs lsof in the FreeBSD VM and extends the existing warning-suppression flag from NetBSD to FreeBSD. The helper still extracts machine-readable listening-socket addresses for assertions; the affected behavior is test instrumentation and diagnostic output.

Source 1

Caching BSD build inputs was motivated by reliability and shared-resource costs as well as speed: repeated SDK downloads could delay or fail jobs, and separating archive caches from image caches would reduce dependence on, and load upon, archive servers.

The base downloads and verifies a FreeBSD SDK for cross-compilation. The head removes that FreeBSD SDK path and instead caches a prepared VM alongside build inputs and compiler results. The earlier proposal supplies the historical rationale for avoiding repeated environment preparation, but does not establish equivalent behavior between those cache mechanisms.

Source 1

Ralph's inferences

Executing tests on the target operating system provides a different kind of evidence from successfully cross-compiling: it exercises resource limits, socket allocation behavior, and interactions with platform utilities.

Two inspected historical fixes illustrate this distinction. #36078 describes NetBSD's select-based descriptor ceiling affecting node startup in functional tests; #36145 describes OpenBSD ephemeral ports overlapping the test framework's allocated range. These support the rationale for target-OS execution, without implying that a FreeBSD job covers other BSDs or necessarily catches probabilistic failures.

Source 1 · Source 2 · Source 3

Unresolved disagreements

The inspected record does not settle how much pre-merge BSD coverage is worth relative to CI resource consumption and maintenance noise. Advocates emphasized earlier detection; objections emphasized limited resources, intermittent infrastructure failures, and the possibility that occasional post-merge fixes cost less than maintaining another always-running job.

The head adds native VM execution to the shared workflow, with a two-hour job limit, explicit memory allocation, and caches. Earlier discussion also reported resource problems in nested BSD VMs. Those are historical tradeoffs relevant to this execution model, not findings about the present patch.

Source 1 · Source 2 · Source 3 · Source 4

Third-party VM actions raised an unresolved trust and operational-control question. One objection asked whether malicious or backdoored actions could compromise the repository; the response pointed to read-only workflow token permissions. Later discussion also questioned reliance on upstream-controlled caching behavior, even after caching became configurable.

The head introduces vmactions/freebsd-vm@v1 and documents the required repository permission. The historical concern therefore includes the external action's authority and its control over resource use, not merely whether FreeBSD can run the tests. The inspected exchanges do not establish either a compromise path or a definitive security resolution.

Source 1 · Source 2 · Source 3 · Source 4 · Source 5