Compare commits

..

3 Commits

Author SHA1 Message Date
a51a3b57f6 change usage of tags to recipe versions in deploy.go
Some checks failed
continuous-integration/drone/push Build is failing
2026-01-11 19:32:03 +01:00
683a3bbf3d Merge branch 'main' into fixBrokenRecipeCheckout
Some checks failed
continuous-integration/drone/push Build is failing
2026-01-11 18:19:12 +00:00
ae9e49e1b5 fix: breaking GetRecipeVersions when an invalid recipe version exists
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2026-01-11 19:00:49 +01:00
6 changed files with 29 additions and 31 deletions

View File

@ -281,13 +281,21 @@ checkout as-is. Recipe commit hashes are also supported as values for
}
func getLatestVersionOrCommit(app appPkg.App) (string, error) {
versions, err := app.Recipe.Tags()
recipeVersions, warnings, err := app.Recipe.GetRecipeVersions()
if err != nil {
return "", err
}
if len(versions) > 0 && !internal.Chaos {
return versions[len(versions)-1], nil
for _, warning := range warnings {
log.Warn(warning)
}
if len(recipeVersions) > 0 && !internal.Chaos {
latest := recipeVersions[len(recipeVersions)-1]
for tag := range latest {
log.Debug(i18n.G("selected latest recipe version: %s (from %d available versions)", tag, len(recipeVersions)))
return tag, nil
}
}
head, err := app.Recipe.Head()

View File

@ -113,13 +113,6 @@ Use "--status/-S" flag to query all servers for the live deployment status.`),
totalAppsCount++
if status {
if err := app.Recipe.EnsureUpToDate(); err != nil {
log.Warnf(
"Failed to ensure repo is up to date for recipe: %s err: %s",
app.Recipe.Name,
err,
)
}
status := i18n.G("unknown")
version := i18n.G("unknown")
chaos := i18n.G("unknown")

View File

@ -98,10 +98,14 @@ var AppNewCommand = &cobra.Command{
var recipeVersions recipePkg.RecipeVersions
if recipeVersion == "" {
var err error
recipeVersions, _, err = recipe.GetRecipeVersions()
var warnings []string
recipeVersions, warnings, err = recipe.GetRecipeVersions()
if err != nil {
log.Fatal(err)
}
for _, warning := range warnings {
log.Warn(warning)
}
}
if len(recipeVersions) > 0 {
@ -110,6 +114,8 @@ var AppNewCommand = &cobra.Command{
recipeVersion = tag
}
log.Debug(i18n.G("selected recipe version: %s (from %d available versions)", recipeVersion, len(recipeVersions)))
if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
log.Fatal(err)
}

View File

@ -403,15 +403,18 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
Branch: plumbing.ReferenceName(ref.Name()),
}
if err := worktree.Checkout(checkOutOpts); err != nil {
log.Debug(i18n.G("failed to check out %s in %s", tag, r.Dir))
return err
log.Debug(i18n.G("failed to check out %s in %s: %s", tag, r.Dir, err))
warnMsg = append(warnMsg, i18n.G("skipping tag %s: checkout failed: %s", tag, err))
return nil
}
log.Debug(i18n.G("git checkout: %s in %s", ref.Name(), r.Dir))
config, err := r.GetComposeConfig(nil)
if err != nil {
return err
log.Debug(i18n.G("failed to get compose config for %s: %s", tag, err))
warnMsg = append(warnMsg, i18n.G("skipping tag %s: invalid compose config: %s", tag, err))
return nil
}
versionMeta := make(map[string]ServiceMeta)
@ -419,7 +422,9 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
img, err := reference.ParseNormalizedNamed(service.Image)
if err != nil {
return err
log.Debug(i18n.G("failed to parse image for %s in %s: %s", service.Name, tag, err))
warnMsg = append(warnMsg, i18n.G("skipping tag %s: invalid image reference in service %s: %s", tag, service.Name, err))
return nil
}
path := reference.Path(img)
@ -445,6 +450,7 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
return nil
}); err != nil {
log.Warn(i18n.G("GetRecipeVersions encountered error for %s: %s (collected %d versions)", r.Name, err, len(versions)))
return versions, warnMsg, nil
}

View File

@ -67,16 +67,6 @@ teardown(){
assert_output --partial "$TEST_SERVER"
assert_output --partial "$TEST_APP_DOMAIN"
assert_output --partial "deployed"
assert_output --partial "latest"
_remove_tags
run $ABRA app ls --status
assert_success
assert_output --partial "$TEST_SERVER"
assert_output --partial "$TEST_APP_DOMAIN"
assert_output --partial "deployed"
assert_output --partial "latest"
}
@test "filter by server" {

View File

@ -17,12 +17,7 @@ _remove_tags(){
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
assert_success
# If this was done without the --regexp I get this error:
# -- output differs --
# expected : 0
# actual : 0
# --
assert_output --regexp '[[:space:]]*0'
assert_output '0'
}
_reset_tags() {