Skip to content

Commit c21b352

Browse files
committed
ci: discover the backends to substitute rather than listing them
openkal-musl names a backend per target --- linux, macos, windows and opensbi, each conditional --- and every one of their versions moves with a change that spans these repositories. Each left unsubstituted fails the same way, one link further down: E_NOT_FOUND: package 'openkal-linux@0.6.0' (the host build) E_NOT_FOUND: package 'openkal-opensbi@0.2.0' (the bare-metal one) I named the first and the second appeared. The commit that named the first said "a chain is substituted correctly only when it is followed to its end", and then followed it by hand to one entry short of the end, which is the ordinary outcome of a list written from memory. The set is now read out of the manifest, so it cannot fall behind what that manifest declares. ⭐ AND THE LAST CHECK IS THE ONE THAT WOULD HAVE CAUGHT BOTH: after every substitution, nothing anywhere in the graph may still name a version. That is a property of the whole graph rather than of the entries someone remembered, and it fails at the substitution rather than at a resolver error further on, where the message names a package instead of naming the omission.
1 parent 0151d1a commit c21b352

2 files changed

Lines changed: 39 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,36 +156,52 @@ jobs:
156156
git -C .spec checkout --quiet "origin/$branch"
157157
fi
158158
159-
# ⚠️ THE WHOLE CHAIN, NOT THE FIRST TWO LINKS. openkal-musl names a
160-
# BACKEND as well as the specification, and that backend's version
161-
# moves with the same change:
159+
# ⚠️ EVERY BACKEND THE C LIBRARY NAMES, DISCOVERED RATHER THAN LISTED.
162160
#
163-
# E_NOT_FOUND: package 'openkal-linux@0.6.0' not found
161+
# openkal-musl names a backend per target: linux, macos, windows and
162+
# opensbi, each conditional. Their versions all move with a change that
163+
# spans these repositories, so each one left unsubstituted fails the
164+
# same way, one link further down:
164165
#
165-
# Substituting two of the three left the third naming a version the
166-
# index does not have yet, which is the same failure one link further
167-
# down. Every dependency that moves with this change is substituted.
168-
git clone --quiet https://github.com/mcpplibs/openkal-linux.git .impl
169-
if git -C .impl rev-parse --verify --quiet "origin/$branch" > /dev/null; then
170-
git -C .impl checkout --quiet "origin/$branch"
171-
fi
166+
# E_NOT_FOUND: package 'openkal-linux@0.6.0' (the host build)
167+
# E_NOT_FOUND: package 'openkal-opensbi@0.2.0' (the bare-metal one)
168+
#
169+
# I fixed the first by naming it, and the second appeared. A list
170+
# written by hand is a list that is one entry short, so the set is read
171+
# out of the manifest instead.
172+
for backend in $(grep -oE '^openkal-[a-z]+ = \{ version' .musl/mcpp.toml | cut -d' ' -f1); do
173+
git clone --quiet "https://github.com/mcpplibs/$backend.git" ".$backend"
174+
if git -C ".$backend" rev-parse --verify --quiet "origin/$branch" > /dev/null; then
175+
git -C ".$backend" checkout --quiet "origin/$branch"
176+
fi
177+
here="$(cd ".$backend" && pwd)"
178+
# The backend reaches the specification too, and by whatever form its
179+
# own manifest uses.
180+
sed -i -E "s|^openkal = .*$|openkal = { path = \"$(cd .spec && pwd)\" }|" ".$backend/mcpp.toml"
181+
sed -i -E "s|^$backend = \\{ version = \"[^\"]*\"(.*)$|$backend = { path = \"$here\"\\1|" \
182+
.musl/mcpp.toml
183+
grep -q "path = \"$here\"" .musl/mcpp.toml \
184+
|| { echo "::error::$backend was not substituted"; exit 1; }
185+
echo " $backend -> working tree"
186+
done
172187
173188
spec="$(cd .spec && pwd)"
174189
musl="$(cd .musl && pwd)"
175-
impl="$(cd .impl && pwd)"
176-
177-
sed -i -E "s|^openkal = .*$|openkal = { path = \"$spec\" }|" .impl/mcpp.toml
178190
sed -i -E "s|^openkal = .*$|openkal = { path = \"$spec\" }|" .musl/mcpp.toml
179-
sed -i -E "s|^openkal-linux = \\{ version = \"[^\"]*\"(.*)$|openkal-linux = { path = \"$impl\"\\1|" \
180-
.musl/mcpp.toml
181191
sed -i -E "s|^openkal-musl = .*$|openkal-musl = { path = \"$musl\" }|" mcpp.toml
182192
183-
for pair in "mcpp.toml:$musl" ".musl/mcpp.toml:$spec" ".musl/mcpp.toml:$impl" ".impl/mcpp.toml:$spec"; do
184-
f="${pair%%:*}"; want="${pair##*:}"
185-
grep -q "path = \"$want\"" "$f" \
186-
|| { echo "::error::a substitution matched nothing: $f should name $want"; exit 1; }
187-
done
188-
echo "the whole stack names working trees: runtime -> musl -> {openkal, openkal-linux}"
193+
grep -q "path = \"$musl\"" mcpp.toml \
194+
|| { echo "::error::the C library substitution matched nothing"; exit 1; }
195+
grep -q "path = \"$spec\"" .musl/mcpp.toml \
196+
|| { echo "::error::the specification substitution matched nothing"; exit 1; }
197+
198+
# ⚠️ THE LAST CHECK IS THE ONE THAT WOULD HAVE CAUGHT BOTH FAILURES:
199+
# nothing anywhere in the substituted graph still names a version.
200+
if grep -nE '^openkal[a-z-]* = (\"|\{ version)' .musl/mcpp.toml mcpp.toml; then
201+
echo "::error::something in the graph still names a version rather than a tree"
202+
exit 1
203+
fi
204+
echo "the whole stack names working trees, and nothing in it names a version"
189205
190206
- name: The runtime builds
191207
run: mcpp build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ mcpp.lock
1717
.musl/
1818
.spec/
1919
.impl/
20+
.openkal-*/

0 commit comments

Comments
 (0)