Skip to content

Commit edfd6c9

Browse files
committed
ci: test against the C library as written on this branch, not as published
This package declares openkal-musl by version, which is what a published manifest must say. A change spanning the two repositories cannot be tested that way: the version named does not exist in the index until the other half is released, and the run fails with E_NOT_FOUND: package 'openkal-musl@0.4.0' not found in the synced index which reads as a mistake in this manifest and is nothing of the kind. Every other repository in this ecosystem solves it by substituting a working tree. This one now does the same, for both halves of the stack beneath it: the C library at this branch where it has one, and the specification that C library reaches, so that what is tested is the stack as written rather than a mixture of one branch and one release. The substitution is asserted rather than assumed. One that matched nothing would leave the manifest naming a version, the resolver would fetch a published C library, and the run would report on that one while appearing to report on this branch --- which is the failure this whole mechanism exists to prevent, arriving by a different route.
1 parent cc4dcb7 commit edfd6c9

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,57 @@ jobs:
116116
mcpp toolchain install "${spec%@*}" "${spec#*@}"
117117
mcpp toolchain default "$spec"
118118
119+
# THE C LIBRARY THIS RUNTIME IS CONFIGURED FOR, AS WRITTEN ON THE BRANCH
120+
# UNDER TEST RATHER THAN AS PUBLISHED.
121+
#
122+
# This package declares openkal-musl by version, which is what a published
123+
# manifest must say. A change that spans the two repositories cannot be
124+
# tested that way: the version named here does not exist in the index until
125+
# the other half is released, and the run fails with
126+
#
127+
# E_NOT_FOUND: package 'openkal-musl@<version>' not found in the
128+
# synced index
129+
#
130+
# --- which reads as a mistake in this manifest and is nothing of the kind.
131+
#
132+
# The other repositories in this ecosystem solve it by substituting a
133+
# working tree, and this one now does the same. The substitution is
134+
# asserted rather than assumed: one that matched nothing would leave the
135+
# manifest naming a version, the resolver would fetch a published C
136+
# library, and the run would report on that one while appearing to report
137+
# on this branch.
138+
- name: The C library, as written on this branch
139+
run: |
140+
set -euo pipefail
141+
branch='${{ github.head_ref || github.ref_name }}'
142+
git clone --quiet https://github.com/mcpplibs/openkal-musl.git .musl
143+
if git -C .musl rev-parse --verify --quiet "origin/$branch" > /dev/null; then
144+
git -C .musl checkout --quiet "origin/$branch"
145+
echo "openkal-musl is at $branch $(git -C .musl rev-parse --short HEAD)"
146+
else
147+
echo "openkal-musl has no $branch; its default branch is used" \
148+
"($(git -C .musl rev-parse --short HEAD))"
149+
fi
150+
151+
# openkal-musl reaches the specification by whatever its own manifest
152+
# says. That becomes the same working tree, so that the whole stack
153+
# under test is the one written on this branch.
154+
git clone --quiet https://github.com/mcpplibs/openkal.git .spec
155+
if git -C .spec rev-parse --verify --quiet "origin/$branch" > /dev/null; then
156+
git -C .spec checkout --quiet "origin/$branch"
157+
fi
158+
159+
spec="$(cd .spec && pwd)"
160+
musl="$(cd .musl && pwd)"
161+
sed -i -E "s|^openkal = .*$|openkal = { path = \"$spec\" }|" .musl/mcpp.toml
162+
sed -i -E "s|^openkal-musl = .*$|openkal-musl = { path = \"$musl\" }|" mcpp.toml
163+
164+
grep -q "path = \"$musl\"" mcpp.toml \
165+
|| { echo "::error::the C library substitution matched nothing"; exit 1; }
166+
grep -q "path = \"$spec\"" .musl/mcpp.toml \
167+
|| { echo "::error::the specification substitution matched nothing"; exit 1; }
168+
echo "openkal-musl = { path = … }, and it reaches openkal the same way"
169+
119170
- name: The runtime builds
120171
run: mcpp build
121172

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ mcpp.lock
1212
# remove a file that is ALREADY TRACKED. This repository had two: one at the
1313
# root and one under `examples/import-std/`. The first cleanup found only the
1414
# root one, because the scan it used anchored the path at the beginning.
15+
16+
# The working trees the workflow substitutes for published dependencies.
17+
.musl/
18+
.spec/

0 commit comments

Comments
 (0)