Repository navigation
698 lines (619 loc) · 30.8 KB
/
Copy pathcode.yml
File metadata and controls
698 lines (619 loc) · 30.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
name: code
# The code half of this volume, which did not exist until P01 started.
#
# Why this is a separate workflow from checks.yml: that one is mostly the published
# Markdown and the tree's own rules, so it stays fast. This one carries the language
# matrix and is allowed to be slower.
#
# THAT DESCRIPTION USED TO SAY checks.yml "needs nothing but Python", and it had
# stopped being true. That workflow builds P04's capture emitter and, from Sunday
# 18 October 2026, P05's reduction suite under four targets including the
# sanitisers. Both are small host builds that belong beside the thing they prove
# rather than in this matrix, which exists for a different claim: the same source
# compiled under three versions of a language with no per-version source and no
# ifdefs. A reduction with one implementation has nothing to say about that claim,
# so it is not here, and the reason is written down rather than left as an absence
# somebody later reads as an oversight.
#
# **The point of the matrix is the point of the project.** The same two source
# files are compiled under three versions of the language, with no per-version
# source and no ifdefs, because the claim P01 makes is that the table is
# expressible without reaching for anything a later version added. A version that
# fails here is a finding about that claim, not a build problem to patch around.
#
# The warning set is -Werror with the usual pedantry, so a construct that a newer
# version merely deprecates fails rather than passing with a note nobody reads.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
c:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std: [c11, c17, c23]
name: C (${{ matrix.std }})
steps:
- uses: actions/checkout@v4
- name: Which compiler this is
run: gcc --version
# -Wconversion is in the set on purpose. The table carries uint16 runs and
# uint32 times, and an implicit narrowing between them is exactly the kind
# of defect that passes every behavioural test and then truncates a hold on
# a long-running node.
- name: Compile and run the row-coverage test
run: |
set -e
mkdir -p build-host
# gcc 14 spells this standard -std=c23; gcc 13 only knows it as -std=c2x,
# the pre-release name for the same document. The runner had gcc 13 on
# the first run and refused c23 outright. Probe, use whichever this gcc
# accepts, and say which, so the log records the compiler's vocabulary
# rather than failing on it.
STD=${{ matrix.std }}
if [ "$STD" = c23 ] && ! gcc -std=c23 -fsyntax-only -x c /dev/null 2>/dev/null; then
echo "this gcc has no -std=c23; using -std=c2x, the same standard under its pre-release name"
STD=c2x
fi
echo "CSTD=$STD" >> "$GITHUB_ENV"
echo "compiler: $(gcc --version | head -1), standard flag: -std=$STD"
gcc -std=$STD -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes \
-o build-host/test_presence_${{ matrix.std }} \
projects/01-presence/c/presence.c \
projects/01-presence/c/test_presence.c
./build-host/test_presence_${{ matrix.std }}
# A sanitised run of the same test. The dispatcher indexes a table by a
# row number it computed itself, and an off-by-one there would read past
# the end; -O2 alone will not say so.
- name: The same test under the address and undefined-behaviour sanitisers
run: |
set -e
gcc -std=$CSTD -O1 -g \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-Wall -Wextra -Werror \
-o build-host/test_presence_san_${{ matrix.std }} \
projects/01-presence/c/presence.c \
projects/01-presence/c/test_presence.c
./build-host/test_presence_san_${{ matrix.std }}
# P02's cascade, under the same standard and the same flags. It is a different
# shape from P01's table: eight guarded arms as one pure function rather than
# rows, and the test asserts WHICH ARM fired and not only the code, because
# several arms produce the same code and two of them produce the fall-through
# between them. A permuted cascade can leave every code identical.
- name: Compile and run the claim cascade
run: |
set -e
gcc -std=$CSTD -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes \
-o build-host/test_claim_${{ matrix.std }} \
projects/02-the-claim/c/claim.c \
projects/02-the-claim/c/test_claim.c
./build-host/test_claim_${{ matrix.std }}
# The spool is a ring indexed modulo its own capacity in three places, which is
# exactly where an off-by-one keeps every count correct and corrupts a slot.
# -O2 alone will not say so.
- name: The claim cascade under the address and undefined-behaviour sanitisers
run: |
set -e
gcc -std=$CSTD -O1 -g \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-Wall -Wextra -Werror \
-o build-host/test_claim_san_${{ matrix.std }} \
projects/02-the-claim/c/claim.c \
projects/02-the-claim/c/test_claim.c
./build-host/test_claim_san_${{ matrix.std }}
# The C++ side, three versions, two compilers. presence.hpp is the C++17 baseline
# and must compile unchanged under all three; presence23.hpp and presence26.hpp
# add only what their version offers, behind feature-test macros. The test's
# last lines are a report of which additions this compiler actually provided,
# and docs/LANGUAGE_IDIOMS.md is filled from that report rather than from a
# standards table. So read the log, not only the badge.
cpp:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std: [c++17, c++23, c++2c]
cxx: [g++, clang++]
name: C++ ${{ matrix.std }} via ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v4
- run: ${{ matrix.cxx }} --version
- name: Compile and run the row-coverage test, and print the feature report
run: |
set -e
mkdir -p build-host
# The first run found that gcc 13 has no C++26 mode at all: neither
# -std=c++2c nor -std=c++26 is accepted. There is nothing to translate
# the flag to, so when that happens the C++26 probes are measured under
# the highest mode this compiler has, c++23, and every one of them will
# report NOT available. That result is the finding, and the log says so
# in words so that a green badge cannot be mistaken for C++26 support.
STD=${{ matrix.std }}
if [ "$STD" = c++2c ] && ! ${{ matrix.cxx }} -std=c++2c -fsyntax-only -x c++ /dev/null 2>/dev/null; then
if ${{ matrix.cxx }} -std=c++26 -fsyntax-only -x c++ /dev/null 2>/dev/null; then
STD=c++26
else
echo "this compiler has NO C++26 mode; the C++26 probes are measured under -std=c++23 and will all report NOT available"
STD=c++23
fi
fi
echo "CXXSTD=$STD" >> "$GITHUB_ENV"
echo "compiler: $(${{ matrix.cxx }} --version | head -1), standard flag: -std=$STD"
${{ matrix.cxx }} -std=$STD -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-fno-exceptions -fno-rtti \
-o build-host/test_presence_cpp \
projects/01-presence/cpp/test_presence.cpp
./build-host/test_presence_cpp
# -fno-exceptions above is the kernel adapter's reality. std::expected and
# std::variant are both fine without exceptions as used here; this step
# proves that nothing in the three headers quietly needs them.
- name: The same under the sanitisers
run: |
set -e
${{ matrix.cxx }} -std=$CXXSTD -O1 -g \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-Wall -Wextra -Werror -fno-exceptions -fno-rtti \
-o build-host/test_presence_cpp_san \
projects/01-presence/cpp/test_presence.cpp
./build-host/test_presence_cpp_san
# P02's cascade, the same standard and the same flags. Where P01's table is a table
# in every language, this one is a chain of named predicates in C and an array of
# {guard, code} in C++, which is the same ordered policy in the shape each language
# reasons about best. The C++ form is the one that can be checked at compile time,
# and three of the claims P01 makes in a test are static_asserts here.
- name: Compile and run the claim cascade, and print the feature report
run: |
set -e
${{ matrix.cxx }} -std=$CXXSTD -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-fno-exceptions -fno-rtti \
-o build-host/test_claim_cpp \
projects/02-the-claim/cpp/test_claim.cpp
./build-host/test_claim_cpp
- name: The claim cascade under the sanitisers
run: |
set -e
${{ matrix.cxx }} -std=$CXXSTD -O1 -g \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-Wall -Wextra -Werror -fno-exceptions -fno-rtti \
-o build-host/test_claim_cpp_san \
projects/02-the-claim/cpp/test_claim.cpp
./build-host/test_claim_cpp_san
# Rust, three editions, one source. Unlike the C and C++ matrices this is not
# three compilers' opinions: one toolchain builds every edition, and an edition
# changes what the language permits rather than what the library offers. So the
# pinned toolchain in rust-toolchain.toml is half the claim and its version is
# printed below, because "compiles under three editions" says nothing about
# which compiler did it.
rust:
runs-on: ubuntu-latest
name: Rust, editions 2018, 2021 and 2024
defaults:
run:
working-directory: projects/01-presence/rust
steps:
- uses: actions/checkout@v4
- name: Which toolchain the pin resolves to
run: |
rustup show active-toolchain
cargo --version
rustc --version
# Formatting and lints before the tests, because a warning here is a build
# failure by the workspace's own lint setting and it is cheaper to see why
# before a test log scrolls past it.
- name: Formatting
run: cargo fmt --all --check
- name: Clippy, warnings denied, every target
run: cargo clippy --workspace --all-targets -- -D warnings
# The real check. The same presence_core.rs and tests_core.rs compiled and
# run three times, once per edition. An edition that needed its own source
# would fail here rather than becoming a footnote.
- name: The row-coverage tests, under each edition
run: cargo test --workspace -- --nocapture
# no_std is a claim about the node, and a host test proves nothing about it:
# the test configuration pulls in std for the harness. This builds the
# library alone for a bare-metal target, which is where the claim is either
# true or a link error.
- name: The library builds for a bare-metal target, which is what no_std means
run: |
rustup target add thumbv7em-none-eabihf
cargo build --release --target thumbv7em-none-eabihf \
-p presence-e2018 -p presence-e2021 -p presence-e2024
# P02's cascade, the same three editions and the same gates. A separate job rather than
# more steps in the one above, because each project carries its own workspace and a
# working directory is set per job.
rust_claim:
runs-on: ubuntu-latest
name: Rust, the claim cascade, editions 2018, 2021 and 2024
defaults:
run:
working-directory: projects/02-the-claim/rust
steps:
- uses: actions/checkout@v4
- name: Which toolchain the pin resolves to
run: |
rustup show active-toolchain
cargo --version
rustc --version
- name: Formatting
run: cargo fmt --all --check
- name: Clippy, warnings denied, every target
run: cargo clippy --workspace --all-targets -- -D warnings
# --nocapture because the tests print what the representation costs: the size of
# Option<fn> against a bare fn, the event size the spool arithmetic depends on, and
# the count of inputs the invariants were checked over. A test that prints a number
# the design depends on is the habit this volume keeps.
- name: The cases and the criteria, under each edition
run: cargo test --workspace -- --nocapture
- name: The library builds for a bare-metal target, which is what no_std means
run: |
rustup target add thumbv7em-none-eabihf
cargo build --release --target thumbv7em-none-eabihf \
-p claim-e2018 -p claim-e2021 -p claim-e2024
# The same source through a second compiler. Two toolchains disagreeing about a
# table of function pointers would be a finding worth having, and a warning one
# of them raises and the other does not is the commonest way a portable claim
# turns out to be a gcc claim.
clang:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std: [c11, c17, c23]
name: C via clang (${{ matrix.std }})
steps:
- uses: actions/checkout@v4
- run: clang --version
- name: Compile and run
run: |
set -e
mkdir -p build-host
clang -std=${{ matrix.std }} -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes \
-o build-host/test_presence_clang_${{ matrix.std }} \
projects/01-presence/c/presence.c \
projects/01-presence/c/test_presence.c
./build-host/test_presence_clang_${{ matrix.std }}
- name: Compile and run the claim cascade
run: |
set -e
clang -std=${{ matrix.std }} -O2 \
-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes \
-o build-host/test_claim_clang_${{ matrix.std }} \
projects/02-the-claim/c/claim.c \
projects/02-the-claim/c/test_claim.c
./build-host/test_claim_clang_${{ matrix.std }}
# The table under a real kernel, which is a different claim from the ones above.
# Those compile the table; this runs it with a real queue, a real dispatch task and
# a real software timer, and asserts the row sequence is the one the direct-dispatch
# test produces. Same rows, different plumbing.
#
# The kernel is cloned at a pinned tag rather than vendored, so this job also says
# which version the claim was made against. The build itself checks that no
# allocator is linked, which is what configSUPPORT_DYNAMIC_ALLOCATION 0 means, and
# the run has four phases; the two worth having are a release produced by the timer
# rather than by an injected event, and a queue deliberately overrun to prove a lost
# event is counted rather than dropped in silence.
freertos:
runs-on: ubuntu-latest
name: FreeRTOS, the adapter on a host
defaults:
run:
working-directory: projects/01-presence/freertos
steps:
- uses: actions/checkout@v4
- name: The kernel, at the tag this claim is made against
run: make fetch
- name: Build, and refuse a binary containing an allocator
run: make
- name: The four phases
run: make run
zephyr:
runs-on: ubuntu-latest
name: Zephyr, the same adapter test on native_sim
steps:
- uses: actions/checkout@v4
# native_sim compiles with the host gcc and needs no Zephyr SDK, which is the
# whole reason this job is affordable. The 32-bit multilib is for the board
# itself: plain native_sim is a 32-bit target, and native_sim/native/64 would
# be a different board string from the one the page documents.
- name: Host packages, and no SDK
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake ninja-build gperf device-tree-compiler python3-pip python3-venv gcc-multilib g++-multilib
# A virtual environment rather than pip --user, because Ubuntu's system Python
# is marked externally managed and refuses the latter outright. This also
# mirrors the local loop, which activates ~/zephyrproject/.venv.
- name: A virtual environment, on PATH for every step below
run: |
python3 -m venv ~/zephyr-venv
~/zephyr-venv/bin/pip install --upgrade pip west
echo "$HOME/zephyr-venv/bin" >> "$GITHUB_PATH"
# Keyed on the revision below, so a green run is repeatable and a red one is
# about this repository rather than about upstream having moved overnight.
- name: Restore the Zephyr tree if it has been fetched before
id: tree
uses: actions/cache@v4
with:
path: ~/zephyrproject
key: zephyr-v4.5.0-rc1-narrow-depth1
# Shallow, and every module rather than a hand-picked set: choosing which
# modules native_sim pulls in would be a guess, and the cache makes the whole
# tree cost one fetch.
- name: The tree, at a tag, shallow
if: steps.tree.outputs.cache-hit != 'true'
run: |
west init -m https://github.com/zephyrproject-rtos/zephyr --mr v4.5.0-rc1 ~/zephyrproject
cd ~/zephyrproject
west update --narrow -o=--depth=1
# Order matters and cost an hour once: zephyr-export runs CMake, which imports
# Zephyr's own Python, so the packages have to be in place before it is called.
- name: Zephyr's Python packages, then the CMake package registry
run: |
cd ~/zephyrproject
west packages pip --install
west zephyr-export
- name: The version this run is against
run: git -C ~/zephyrproject/zephyr describe --tags --always
# No -DZEPHYR_TOOLCHAIN_VARIANT here on purpose. CMakeLists.txt sets it when
# nothing else has, and this job is the check that the documented three-line
# build is the build.
- name: Build, from outside any west workspace
run: |
cmake -B build-zephyr -GNinja -DBOARD=native_sim -S projects/01-presence/zephyr
ninja -C build-zephyr
- name: The same four phases FreeRTOS runs
run: ./build-zephyr/zephyr/zephyr.exe | tee phases.log
# The executable returns the failure count, but a simulation that never reached
# the phases would also exit 0, so the printed line is the gate as well.
- name: The run must have said so
run: |
grep -q "^PASSED: 0 failure(s)$" phases.log
# ------------------------------------------------- P05's criterion 6, settled in this job
#
# WHY HERE. That criterion reduces to one comparison: P01's application object is byte for
# byte what it was, while the reading reaching it comes from P05's part through P05's
# reduction. The reference side of that comparison is the build three steps above, so this
# job is the only place in the workflow where the comparison costs one more configure.
#
# AND BOTH SIDES MUST BE THE SAME MACHINE. P01's application is native_sim, which compiles
# with the host gcc; P05's own builds are cross builds for the board. An object from one
# compared against an object from the other would be x86 against ARM, which is not a
# comparison, and scripts/check_object_identity.py now refuses such a pair outright.
# projects/05-the-zones/docs/CRITERION6.md carries the design and the three refutations.
#
# NOTHING HERE TOUCHES THE PART. P05's reduction names no operating system and no vendor
# interface, so this needs no board, no shield, no vendor clone and no cross toolchain.
- name: P05's reduction feeding P01's machine, built the way P01 is built
run: |
cmake -B build-p05-integration -GNinja -DBOARD=native_sim \
-S projects/05-the-zones/integration
ninja -C build-p05-integration
# The three grids in that application are the seam's own cases: a full grid posts its
# distance, a grid with no valid zone posts nothing rather than a range of zero, and a
# negative distance posts nothing rather than the sixty-five thousand a cast would make of
# it. The printed verdict is the gate, for the same reason it is above: a run that never
# reached the cases would also exit 0.
- name: The seam decides its three cases
run: |
./build-p05-integration/zephyr/zephyr.exe | tee integration.log
grep -q "^PASSED: 0 failure(s)$" integration.log
# THE OBJECT PATH IS DERIVED AND NOT WRITTEN DOWN, which is the one thing this step has to
# get right. CMake hangs the absolute source path under CMakeFiles/app.dir/, so the path
# holds this checkout's directory and differs between a bench and a runner. It is the same
# in both builds, because both compile the same absolute presence.c, which is why one
# argument addresses both.
- name: P01's machine is byte for byte what it was
run: |
obj="CMakeFiles/app.dir$PWD/projects/01-presence/c/presence.c.obj"
echo "comparing $obj"
python3 scripts/check_object_identity.py build-zephyr build-p05-integration "$obj"
# P02's cascade under the same two kernels, from the same shared phases.c. The pair is
# worth having for a reason that proved itself on Tuesday 6 October 2026: a stale local
# binary printed a pass for a change it had not been built with, and the only thing that
# noticed was the second kernel building the same file and printing different numbers.
freertos_measure:
runs-on: ubuntu-latest
name: FreeRTOS, the seven operations on a host, every capture refused
defaults:
run:
working-directory: projects/04-what-the-kernel-primitives-cost/freertos
steps:
- uses: actions/checkout@v4
- name: The kernel, at the tag this claim is made against
run: make fetch
- name: Build, and refuse a binary containing an allocator
run: make
# `make check` runs the binary, whose own verdicts set the exit status, and then feeds
# the period capture to the reduction and requires a refusal for its clock. A host build
# that could get a capture past the reduction is the thing the contract forbids, so the
# job is green only when the reduction says no.
- name: Seven operations complete, criterion 4 refutes, and the reduction refuses
run: make check
# THE BOARD IMAGE, COMPILED AND NOT RUN. No board is attached to a runner, so what this proves
# is that the Cortex-M7 port, the sibling volume's board support at its pinned commit, and
# the adapter link into one image with no allocator in it. The figures come from the bench,
# under the same reflash-first rule as every capture since Thursday 8 October 2026.
freertos_board:
runs-on: ubuntu-latest
name: FreeRTOS, the board image for the NUCLEO-H7A3ZI-Q, linked and allocator-free
defaults:
run:
working-directory: projects/04-what-the-kernel-primitives-cost/freertos
steps:
- uses: actions/checkout@v4
- name: The Cortex-M toolchain, newlib and all
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-none-eabi
- name: The kernel, at the tag this claim is made against
run: make fetch
- name: The board support, at the commit this claim is made against
run: make fetch-bsp
- name: Link the image and refuse one containing an allocator
run: make board
freertos_claim:
runs-on: ubuntu-latest
name: FreeRTOS, the claim cascade on a host
defaults:
run:
working-directory: projects/02-the-claim/freertos
steps:
- uses: actions/checkout@v4
- name: The kernel, at the tag this claim is made against
run: make fetch
- name: Build, and refuse a binary containing an allocator
run: make
- name: The four phases
run: make run
zephyr_claim:
runs-on: ubuntu-latest
name: Zephyr, the claim cascade on native_sim
steps:
- uses: actions/checkout@v4
- name: Host packages, and no SDK
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake ninja-build gperf device-tree-compiler \
python3-pip python3-venv gcc-multilib g++-multilib
- name: A virtual environment, on PATH for every step below
run: |
python3 -m venv ~/zephyr-venv
~/zephyr-venv/bin/pip install --upgrade pip west
echo "$HOME/zephyr-venv/bin" >> "$GITHUB_PATH"
# The same cache key as the zephyr job above: one tree, pinned to one tag, restored by
# whichever job runs first.
- name: Restore the Zephyr tree if it has been fetched before
id: tree
uses: actions/cache@v4
with:
path: ~/zephyrproject
key: zephyr-v4.5.0-rc1-narrow-depth1
- name: The tree, at a tag, shallow
if: steps.tree.outputs.cache-hit != 'true'
run: |
west init -m https://github.com/zephyrproject-rtos/zephyr \
--mr v4.5.0-rc1 ~/zephyrproject
cd ~/zephyrproject
west update --narrow -o=--depth=1
- name: Zephyr's Python packages, then the CMake package registry
run: |
cd ~/zephyrproject
west packages pip --install
west zephyr-export
- name: Build, from outside any west workspace
run: |
cmake -B build-claim -GNinja -DBOARD=native_sim \
-S projects/02-the-claim/zephyr
ninja -C build-claim
- name: The same four phases FreeRTOS runs
run: ./build-claim/zephyr/zephyr.exe | tee phases.log
- name: The run must have said so
run: |
grep -q "^PASSED: 0 failure(s)$" phases.log
# P03 is the first project in this volume that CROSS COMPILES. P01's and P02's adapters
# build for native_sim with the host compiler, which is what made them free and is also
# why neither says anything about a build for the real part. This one needs the Zephyr SDK,
# which is about 170 MB for the minimal SDK plus the ARM toolchain and is cached.
#
# Two criteria, neither needing hardware. The first is chapter 03's headline claim.
p03_one_sensor:
runs-on: ubuntu-latest
name: P03, one application across two buses
steps:
- uses: actions/checkout@v4
- name: Host packages
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake ninja-build gperf device-tree-compiler python3-pip python3-venv
- name: A virtual environment, on PATH for every step below
run: |
python3 -m venv ~/zephyr-venv
~/zephyr-venv/bin/pip install --upgrade pip west
echo "$HOME/zephyr-venv/bin" >> "$GITHUB_PATH"
- name: Restore the Zephyr tree if it has been fetched before
id: tree
uses: actions/cache@v4
with:
path: ~/zephyrproject
key: zephyr-v4.5.0-rc1-narrow-depth1
- name: The tree, at a tag, shallow
if: steps.tree.outputs.cache-hit != 'true'
run: |
west init -m https://github.com/zephyrproject-rtos/zephyr \
--mr v4.5.0-rc1 ~/zephyrproject
cd ~/zephyrproject
west update --narrow -o=--depth=1
- name: Zephyr's Python packages, then the CMake package registry
run: |
cd ~/zephyrproject
west packages pip --install
west zephyr-export
- name: Restore the SDK if it has been fetched before
id: sdk
uses: actions/cache@v4
with:
path: ~/zephyr-sdk-1.0.1
key: zephyr-sdk-1.0.1-arm-only
# Only the ARM toolchain, not every architecture the SDK can carry.
- name: The Zephyr SDK, ARM only
if: steps.sdk.outputs.cache-hit != 'true'
run: |
cd ~/zephyrproject
west sdk install -t arm-zephyr-eabi
# THE BUILD STAMP, PROVED BY BUILDING TWICE, which is the only way to know. It needs
# cmake and ninja and no toolchain at all, so it rides in this job for the two tools rather
# than for anything to do with this part. Four wirings are configured and built twice each,
# and two of them are expected to stamp once only: a gate for an unconditional rule that
# had never been shown to fail is the defect it was written about, one level up. See
# scripts/test_build_stamp.py for what the afternoon of Monday 26 October 2026 cost.
- name: The build stamp regenerates at every build, and the wirings that do not are shown
run: python3 scripts/test_build_stamp.py
- name: The two-wire build
run: |
cmake -B build-i2c -GNinja -DBOARD=nucleo_h7a3zi_q \
-DDTC_OVERLAY_FILE=overlays/i2c.overlay -S projects/03-one-sensor
ninja -C build-i2c
- name: The four-wire build
run: |
cmake -B build-spi -GNinja -DBOARD=nucleo_h7a3zi_q \
-DDTC_OVERLAY_FILE=overlays/spi.overlay -S projects/03-one-sensor
ninja -C build-spi
# Criterion 1, restated: the instructions must be identical and the objects may differ
# only in the devicetree ordinal of the device they name. The chapter asked for byte
# equality and the first run of these two builds refuted it; the difference was one
# symbol name carrying an ordinal, and the instructions were the same.
- name: One application, two buses, the same code
run: python3 scripts/check_object_identity.py build-i2c build-spi
# Criterion 4. The build FAILING is the pass, so its status is inverted here rather
# than read off the end of a pipeline: a pipeline reports its last command's status,
# which has already misled this project once.
- name: A description that cannot be true is refused, and names the bus
run: |
set +e
cmake -B build-impossible -GNinja -DBOARD=nucleo_h7a3zi_q \
-DDTC_OVERLAY_FILE=overlays/impossible.overlay \
-S projects/03-one-sensor > impossible.log 2>&1
status=$?
set -e
cat impossible.log
if [ "$status" -eq 0 ]; then
echo "FAIL the build accepted an overlay naming a bus this part does not have"
exit 1
fi
grep -q "undefined node label 'i2c5'" impossible.log
echo "refused, and the message names the bus"