MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / incremental_build_keep

Function incremental_build_keep

tests/test_pipeline.c:3911–3946  ·  view source on GitHub ↗

Editing one Dockerfile keeps every image's build edge -- also the one * between nodes that both pre-existed (Image -> the unchanged Dockerfile), * which the incremental routes recompute whole. `legacy`: through the * full-load route, else the closure-repair route. Returns the build edge * count before / after as "full=N inc=M", or NULL; *route: the route taken. */

Source from the content-addressed store, hash-verified

3909 * full-load route, else the closure-repair route. Returns the build edge
3910 * count before / after as "full=N inc=M", or NULL; *route: the route taken. */
3911static char *incremental_build_keep(bool legacy, cbm_incremental_route_t *route) {
3912 char tmp[256];
3913 snprintf(tmp, sizeof(tmp), "/tmp/cbm_buildkeep_XXXXXX");
3914 if (!cbm_mkdtemp(tmp)) {
3915 return NULL;
3916 }
3917 write_temp_file(tmp, "src/web/Dockerfile", "FROM nginx:1.27\n");
3918 write_temp_file(tmp, "src/api/Dockerfile", "FROM golang:1.22\n");
3919 write_temp_file(tmp, "skaffold.yaml",
3920 "apiVersion: skaffold/v4beta6\nkind: Config\nbuild:\n artifacts:\n"
3921 " - image: web\n context: src/web\n"
3922 " - image: api\n context: src/api\n");
3923 char db_path[512];
3924 snprintf(db_path, sizeof(db_path), "%s/buildkeep.db", tmp);
3925 static const char builds[] =
3926 "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id WHERE e.type='DEPENDS_ON' "
3927 "AND s.label='Image' AND json_extract(e.properties,'$.via')='build'";
3928 int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, builds) : -1;
3929 write_temp_file(tmp, "src/web/Dockerfile", "FROM nginx:1.27\n# edited\n");
3930#if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API
3931 if (legacy) {
3932 cbm_pipeline_incremental_test_force_legacy_partial_once();
3933 }
3934#else
3935 (void)legacy;
3936#endif
3937 char *out = NULL;
3938 if (k8s_inc_index(tmp, db_path) == 0) {
3939 char buf[64];
3940 snprintf(buf, sizeof(buf), "full=%d inc=%d", full, k8s_inc_count(db_path, builds));
3941 out = strdup(buf);
3942 }
3943 *route = cbm_pipeline_incremental_test_last_route();
3944 th_rmtree(tmp);
3945 return out;
3946}
3947
3948TEST(incremental_dockerfile_edit_keeps_build_edges) {
3949 cbm_incremental_route_t route = CBM_INCREMENTAL_ROUTE_NONE;

Callers 1

test_pipeline.cFile · 0.85

Calls 7

cbm_mkdtempFunction · 0.85
write_temp_fileFunction · 0.85
k8s_inc_indexFunction · 0.85
k8s_inc_countFunction · 0.85
th_rmtreeFunction · 0.85

Tested by

no test coverage detected