forked from Mirrors/flatpak-builder
Don't prune build stages from cache with --{export,finish}-only
A commonly used CI workflow [1] is to chain the following steps: > flatpak-builder --stop-at=<module> > flatpak build <commands to build module from local checkout> > flatpak-builder --finish-only Unfortunately, the last step always purge all the compilation cache created by the first one. All build steps are marked unused by default and since they are skipped due to the option --finish-only, all of them are always pruned by the gc function. As a result, flatpak-builder cache becomes useless, a full compilation is always performed. Improve this by not cleaning unused stages when no compilation is done by flatpak-builder (i.e: when flatpak-builder is used with --export-only or --finish-only option). [1]: https://gitlab.gnome.org/GNOME/Initiatives/wikis/DevOps-with-Flatpakauto
parent
85eb2f1a64
commit
7bd6440b75
|
@ -1210,6 +1210,7 @@ builder_cache_disable_lookups (BuilderCache *self)
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
builder_gc (BuilderCache *self,
|
builder_gc (BuilderCache *self,
|
||||||
|
gboolean prune_unused_stages,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint objects_total;
|
gint objects_total;
|
||||||
|
@ -1218,20 +1219,23 @@ builder_gc (BuilderCache *self,
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, self->unused_stages);
|
if (prune_unused_stages)
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
||||||
{
|
{
|
||||||
const char *unused_stage = (const char *) key;
|
g_hash_table_iter_init (&iter, self->unused_stages);
|
||||||
g_autofree char *unused_ref = get_ref (self, unused_stage);
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||||
|
{
|
||||||
|
const char *unused_stage = (const char *) key;
|
||||||
|
g_autofree char *unused_ref = get_ref (self, unused_stage);
|
||||||
|
|
||||||
g_debug ("Removing unused ref %s", unused_ref);
|
g_debug ("Removing unused ref %s", unused_ref);
|
||||||
|
|
||||||
if (!ostree_repo_set_ref_immediate (self->repo,
|
if (!ostree_repo_set_ref_immediate (self->repo,
|
||||||
NULL,
|
NULL,
|
||||||
unused_ref,
|
unused_ref,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, error))
|
NULL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("Pruning cache\n");
|
g_print ("Pruning cache\n");
|
||||||
|
|
|
@ -59,6 +59,7 @@ GPtrArray *builder_cache_get_changes (BuilderCache *self,
|
||||||
GPtrArray *builder_cache_get_all_changes (BuilderCache *self,
|
GPtrArray *builder_cache_get_all_changes (BuilderCache *self,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean builder_gc (BuilderCache *self,
|
gboolean builder_gc (BuilderCache *self,
|
||||||
|
gboolean prune_unused_stages,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void builder_cache_checksum_str (BuilderCache *self,
|
void builder_cache_checksum_str (BuilderCache *self,
|
||||||
|
|
|
@ -332,6 +332,7 @@ main (int argc,
|
||||||
gboolean is_run = FALSE;
|
gboolean is_run = FALSE;
|
||||||
gboolean is_show_deps = FALSE;
|
gboolean is_show_deps = FALSE;
|
||||||
gboolean app_dir_is_empty = FALSE;
|
gboolean app_dir_is_empty = FALSE;
|
||||||
|
gboolean prune_unused_stages = FALSE;
|
||||||
g_autoptr(FlatpakContext) arg_context = NULL;
|
g_autoptr(FlatpakContext) arg_context = NULL;
|
||||||
g_autoptr(FlatpakTempDir) cleanup_manifest_dir = NULL;
|
g_autoptr(FlatpakTempDir) cleanup_manifest_dir = NULL;
|
||||||
g_autofree char *manifest_basename = NULL;
|
g_autofree char *manifest_basename = NULL;
|
||||||
|
@ -1064,7 +1065,10 @@ main (int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!builder_gc (cache, &error))
|
if (!opt_finish_only && !opt_export_only)
|
||||||
|
prune_unused_stages = TRUE;
|
||||||
|
|
||||||
|
if (!builder_gc (cache, prune_unused_stages, &error))
|
||||||
{
|
{
|
||||||
g_warning ("Failed to GC build cache: %s", error->message);
|
g_warning ("Failed to GC build cache: %s", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
|
Loading…
Reference in New Issue