Skip to content

ci(clearcore): cache the vendor core instead of re-fetching teknic.com per run - #1942

Merged
zackees merged 2 commits into
mainfrom
agent/clearcore-package-cache
Nov 7, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/clearcore-package-cache

Conversation

@zackees

@zackees zackees commented Nov 7, 2026

Copy link
Copy Markdown
Member

Why

Build Teknic ClearCore (SAME53) went red on the 2026-11-07 push run (9928f7cc) before any compilation:

build error: package error: failed to download
https://www.teknic.com/files/downloads/ClearCore-1.7.4.zip: error sending request
(gave up after 5 attempts at byte offset 0; 5 consecutive attempts made no progress)
  • The URL answers HTTP/2 200, 11,167,324 bytes from a normal host (Sucuri proxy, x-sucuri-cache: HIT) — the host is not down.
  • The downloader already retries 5× over ~110 s; that budget was raised for this same host in Generic, longer, client-visible retry (and mirror fallback) for every external download; 15 s budget lost a ClearCore vendor fetch #1463 after a release gate lost the fetch.
  • teknic.com is a single vendor origin with no CDN and it intermittently refuses a GitHub runner — this is the second failure of that job in ~2 weeks (the other: run 40863455513, 2026-10-29).
  • check-windows.yml already carries the same 32 MB installed core between runs for exactly this reason. The per-board matrix — the thing that gates a merge — did not.

What

template_build.yml gains an optional package cache:

input meaning
package-cache-path one installed vendor package under the fbuild cache, e.g. ~/.fbuild/prod/cache/platforms/www-ClearCore-1.7.4
package-cache-hash-files file that pins that package's URL + checksum; hashed into the key
  • restore before the build, save after it (always(), main only, cache-hit != 'true'), no restore-keys — a fallback would restore a different vendor archive under the pinned name.
  • Default empty → all ~76 other boards are byte-identical in behaviour.

The opt-in is SOT data, not hand-written YAML: per-board workflows are regenerated from ci/board_families.json, so the record is

"package_cache": {
  "path": "~/.fbuild/prod/cache/platforms/www-ClearCore-1.7.4",
  "hash_files": "crates/fbuild-library/src/library/clearcore_core.rs",
  "note": "teknic.com is a single vendor host behind Sucuri with no CDN: ..."
}

and render_package_cache_block() renders the note as comments so the generated workflow explains itself. The renderer fails closed on a half record or a path outside ~/.fbuild/.

Why the restored tree is enough

PackageBase::staged_install_impl returns the install path as soon as it exists (no archive, no index row needed for the read path), and the tree on disk is platforms/www-ClearCore-1.7.4/94c1b42a3c09f4af/1.7.4/ with .install_complete — that is the directory CI must cache, and the key follows the file that pins the URL + sha256, so a repin downloads instead of restoring the old archive.

Verification (real output)

  • ci.test_fractional_workflows: 25 tests OK (two new: test_board_workflows_pass_only_declared_template_inputs, test_vendor_package_cache_is_opted_in_whole)
  • whole drift registry (ci-workflow-drift.yml's full module list): Ran 459 tests — OK
  • uv run ruff check ci/test_fractional_workflows.py ci/render_workflows.py → clean; ci/check_python_complexity.py → clean
  • uv run python ci/render_workflows.py → updated 1 workflow(s): build-clearcore.yml; --check → rc 0

RED proofs (each mutation, then restored green):

mutation result
drop hash_files from the SOT record render: build-clearcore.yml: package_cache lacks ['hash_files'] rc 1; test errors
drop hashFiles(...) from the restore/save key test fails
caller passes only package-cache-path build-clearcore.yml sets half the package-cache pair
revert the regenerated board workflow render_workflows.py --check fails

New-guard direction: a caller that passes an undeclared template input (or omits a required one) now fails a test instead of only failing at run startup on GitHub.

…m per run

The 2026-11-07 push run failed `Build Teknic ClearCore (SAME53)` before any
compilation: `failed to download https://www.teknic.com/files/downloads/
ClearCore-1.7.4.zip ... (gave up after 5 attempts at byte offset 0)`. The
downloader already retries 5x over ~110 s (#1463 raised that
budget after a release gate lost the same fetch), and the URL answers 200
from a normal host, so the host is not down -- teknic.com is a single vendor
origin behind Sucuri with no CDN and it intermittently refuses a runner.

`check-windows.yml` already carries that 32 MB installed core between runs
for exactly this reason; the per-board matrix, which is what gates a merge,
did not. `template_build.yml` gains an optional package cache: when a board
sets `package-cache-path`, one installed vendor package is restored before
the build and saved after it, keyed on a file that pins that package's URL
and checksum (`hashFiles(inputs.package-cache-hash-files)`), with no
`restore-keys` fallback so a repinned package can never restore the previous
archive under the new name.

The opt-in is SOT data, not hand-written YAML: per-board workflows are
regenerated from `ci/board_families.json`, which now carries a
`package_cache {path, hash_files, note}` record for clearcore and renders
the note as comments. The renderer fails closed on a half record or a path
outside `~/.fbuild/`.

Verification (real output): `ci.test_fractional_workflows` 25 tests OK, the
whole drift registry 459 tests OK, `ruff check` and
`ci/check_python_complexity.py` clean, `ci/render_workflows.py --check` rc 0
after regenerating exactly one workflow. RED proofs: dropping
`hash_files` from the SOT record fails the render ("package_cache lacks
['hash_files']") and errors the test; dropping the pinning hash from the
restore/save key fails the test; a caller-side half pair fails the test;
reverting the regenerated board workflow fails `--check`.

The restored tree is only accepted when it sits at
`{cache_root}/platforms/<stem>/<hash>/<version>` with `.install_complete`,
which is what `PackageBase::staged_install_impl` checks before it skips the
download.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The first commit wired the per-board workflow only, and CI proved that
insufficient: on PR #1942 `Restore board package cache` came up `skipped` in
`Teknic ClearCore (SAME53) / build`. Pull requests and merge-queue entries do
not run `build-clearcore.yml` -- they run the `pr_boards`/`boards` MATRIX,
which calls `template_build.yml` with an explicit `with:` list built from
matrix values. A cache configured only on the per-board workflow is
invisible to the jobs that actually gate a merge.

So the opt-in now rides the matrix: `package_cache_fields()` (one helper,
used by `ci-full`/`ci-test` matrix entries and by
`select_boards.matrix_entries`), forwarded from `matrix.package_cache_path`
and `matrix.package_cache_hash_files` in all three matrix jobs. Boards
without a record get empty strings, which keeps
`inputs.package-cache-path != ''` false and the steps skipped.

`validate_package_cache()` is now its own function (the combined
`validate_source_paths` crossed the C901 limit) and additionally fails
closed when two aliases of one build disagree about the pair --
`execution_boards` runs that build once, so a disagreement would silently
drop the cache for half the aliases.

Verification: regenerated ci-minimal/ci-test/ci-full show the new matrix
keys and forwarding lines; the whole drift registry is 461 tests OK
(`test_fractional_workflows` asserts every matrix job forwards the pair and
that ci-full's include carries it; `test_select_boards` asserts the
selection matrix carries the SOT record and an empty pair for every other
board); `ruff check` + `ci/check_python_complexity.py` clean;
`ci/render_workflows.py --check` rc 0. RED proofs: deleting the forwarding
lines from ci-minimal fails `test_fractional_workflows`; deleting
`**package_cache_fields(b)` from the selection matrix fails
`test_select_boards`.
@zackees zackees added the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Nov 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 7, 2026
@zackees
zackees added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit b3ab0aa Nov 7, 2026
152 of 157 checks passed
@zackees
zackees deleted the agent/clearcore-package-cache branch November 7, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run the complete release-equivalent CI matrix on this PR SHA

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant