Skip to content

Commit 755367d

Browse files
committed
docs(adding-backends): harden the two gotchas that bit ds4
Both omissions are silent at the time you ADD a backend - the failure mode only appears later (the bump bot stays silent forever, or the path filter shows up on the next PR that touches your backend with zero CI jobs and looks broken for unrelated reasons). Expanding the `scripts/changed-backends.js` paragraph from a one-liner to a fully worked example, and adding a new sibling paragraph for the `bump_deps.yaml` + Makefile-pin contract. Both call out the specific mistakes from the ds4 timeline (#9758#9761) so future contributors can pattern-match on the cause. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent d6d8c99 commit 755367d

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

.agents/adding-backends.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,55 @@ The build matrix is data-only YAML at `.github/backend-matrix.yml` (not inside `
3434

3535
**Without an entry here no image is ever built or pushed, and the gallery entry in `backend/index.yaml` will point at a tag that does not exist.** The `dockerfile:` field must point at `./backend/Dockerfile.<lang>` matching the language bucket from step 1 (e.g. `Dockerfile.python`, `Dockerfile.golang`, `Dockerfile.rust`). The `tag-suffix` must match the `uri:` in the corresponding `backend/index.yaml` image entry exactly.
3636

37-
If you add a new language bucket, `scripts/changed-backends.js` also needs a branch in `inferBackendPath` so PR change-detection routes file edits correctly.
37+
**`scripts/changed-backends.js` registration — REQUIRED for any new dockerfile suffix.** This is the single most common omission, because it has no effect on the PR that adds the backend (when no prior path filter could catch it anyway) — it only breaks the *next* PR that touches your backend's directory, which then gets zero CI jobs and looks broken for unrelated reasons. Edit `scripts/changed-backends.js:inferBackendPath` and add a branch BEFORE the more-generic suffixes:
38+
39+
```js
40+
if (item.dockerfile.endsWith("<your-dockerfile-suffix>")) {
41+
return `backend/cpp/<your-backend>/`; // or backend/python|go|rust/...
42+
}
43+
```
44+
45+
The `endsWith()` test is against the matrix entry's `dockerfile:` value (e.g. `./backend/Dockerfile.ds4``endsWith("ds4")`). Specificity order matters here just like it does for importers: more-specific suffixes go BEFORE more-generic ones (e.g. `ds4` before `llama-cpp` even though both end with letters, because some upstream might one day call itself `super-ds4-llama-cpp`). Verify locally before pushing:
46+
47+
```bash
48+
# Confirm your dockerfile suffix is unique enough
49+
node -e "
50+
const yaml = require('js-yaml'); const fs = require('fs');
51+
const m = yaml.load(fs.readFileSync('.github/backend-matrix.yml','utf8'));
52+
for (const e of m.include.filter(e => e.backend === '<your-backend>')) {
53+
console.log(e.dockerfile, '->', e.dockerfile.endsWith('<suffix>'));
54+
}"
55+
```
56+
57+
A quick way to find the right insertion point: `grep -n 'item.dockerfile.endsWith' scripts/changed-backends.js`.
58+
59+
**`bump_deps.yaml` registration — REQUIRED for any backend pinning an upstream commit.** If your backend's Makefile has a `*_VERSION?=<sha>` pin to a third-party repo, the daily auto-bump bot at `.github/workflows/bump_deps.yaml` won't notice it unless you register the backend in its matrix. The bot runs `.github/bump_deps.sh` which `grep`s for `^$VAR?=` in the Makefile you list — so the pin MUST live in the Makefile (not in a separate shell script). The bump for ds4 (#9761) had to walk this back because the original landed the pin in `prepare.sh`, which the bot can't see. Pattern (for `antirez/ds4`):
60+
61+
```yaml
62+
# .github/workflows/bump_deps.yaml
63+
matrix:
64+
include:
65+
- repository: "antirez/ds4"
66+
variable: "DS4_VERSION"
67+
branch: "main"
68+
file: "backend/cpp/ds4/Makefile"
69+
```
70+
71+
And the corresponding Makefile shape (mirror `backend/cpp/llama-cpp/Makefile`):
72+
73+
```makefile
74+
DS4_VERSION?=ae302c2fa18cc6d9aefc021d0f27ae03c9ad2fc0
75+
DS4_REPO?=https://github.com/antirez/ds4
76+
...
77+
ds4:
78+
mkdir -p ds4
79+
cd ds4 && git init -q && \
80+
git remote add origin $(DS4_REPO) && \
81+
git fetch --depth 1 origin $(DS4_VERSION) && \
82+
git checkout FETCH_HEAD
83+
```
84+
85+
If you have a `prepare.sh` doing the clone, delete it — the recipe belongs in the Makefile target so `make purge && make` works as a clean-and-rebuild and so the bump bot finds the pin.
3886

3987
**Placement in file:**
4088
- CPU builds: Add after other CPU builds (e.g., after `cpu-chatterbox`)

0 commit comments

Comments
 (0)