ci: make the FreeBSD job actually build, and fail when it does not - #2213
Merged
Conversation
ci/freebsd.build.sh started with "#!/usr/bin/env bash -e". env(1) does not split its first operand, so it looked for a program literally named "bash -e", printed "env: bash -e: No such file or directory" and exited 127 before a single line of the script ran. score has therefore never been compiled by the FreeBSD job - see for instance run 31948475911, where the whole build step is those five words between "Start Build" and "End Build". Nothing noticed because the workflow ran the script as "./ci/freebsd.build.sh && echo ... Success ...": the && swallows the failure, and the step's status is that of the trailing "End Build" echo, which always succeeds. Adding set -e to the run block is not enough on its own either - errexit is specified to ignore any command of an AND-OR list other than the last one. So set the option inside the script instead, and let the workflow run it as a plain command under set -e. Note that bash lives in /usr/local/bin on FreeBSD, which is why this one keeps env rather than the "#!/bin/bash -e" of its siblings. Verified on a FreeBSD 15.0 VM with a cmake stub that fails on --build: the workflow block exits 0 before, 1 after, and still 0 when the build succeeds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Verification transcript, FreeBSD 15.0 VM (same 1. master, replayed with a 2. the real build, full checkout with every add-on With With ossia/score-addon-sysinfo#3 applied: So the FreeBSD job on this PR is expected to go red until ossia/score-addon-sysinfo#3 lands — that red is the fix working. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The FreeBSD job has been green since it was added, and it has never compiled score even once.
What is broken
ci/freebsd.build.shstarted with:#!/usr/bin/env bash -eenv(1)does not split its first operand, so this asks for a program literally namedbash -e. On FreeBSD that is:and the script exits 127 without running a single line. It is not a FreeBSD quirk either — GNU
envsays the same thing (use -[v]S to pass options in shebang lines).#!/bin/bash -e, which every otherci/*.build.shuses, is not an option here: on FreeBSD bash is/usr/local/bin/bash.Here is the whole build step of run 31948475911 on master:
Two milliseconds, and a green checkmark.
Why CI did not notice
.github/workflows/bsd.ymlran the script as:The
&&turns the failure into a skippedecho, and the step's exit status is that of the last command in the block — the unconditionalEnd Buildecho, which always succeeds. So no matter what the script does, the step is green.Adding
set -eto the block is not enough on its own: errexit is specified to ignore any command of an AND-OR list other than the last one, sofalse && echo hidoes not stop an errexit shell. The&&has to go.The change
ci/freebsd.build.sh: keepenv(bash is not in/binthere), move the option into the script asset -e, with a comment so it does not get folded back into the shebang..github/workflows/bsd.yml:set -ein the run block, and run the build script as a plain command instead of the left-hand side of an&&.The deps line is deliberately left alone — #2202 rewrites it along with
ci/common.deps.sh, and its version of this hunk is a superset of this one, so the two converge.How it was verified
In a FreeBSD 15.0 VM built from the same
vmactions/freebsd-builderimage the CI uses, with the packages this workflow installs. The workflow's build block was replayed against acmakestub that fails on--build:env: bash -e: No such file or directoryFAKE CMAKE: build FAILEDBuild Successand running master's script by hand on FreeBSD gives exit status 127.
Then the real thing:
./ci/freebsd.build.shon a full checkout with all the add-ons, which now runs and reports what it finds.What it finds
Once the script actually runs, master does not compile on FreeBSD. One add-on is responsible:
score-addon-sysinfovendors lfreist/hwinfo, whose "unix" backend is really the Linux one — it needs<netpacket/packet.h>and_SC_AVPHYS_PAGES, neither of which FreeBSD has, and it reads/procand/systhroughout. That is fixed in ossia/score-addon-sysinfo#3, which skips the add-on on the BSDs and explains why a real BSD backend belongs upstream rather than in a shim.Merge that one first.
ci/common.deps.shclones the add-on from its default branch, so as soon as it lands the FreeBSD job here goes green on its own — and with this PR, green will finally mean something. Merged the other way round, this PR turns the job red until the add-on fix follows.With the add-on out of the way, the whole of master compiles and links on FreeBSD 15.0.