0
0
forked from toolshed/abra

Compare commits

...

2 Commits

Author SHA1 Message Date
3c6b506114 fix(deploy): Detects env version correctly 2025-03-04 10:36:00 +01:00
d3ed88189b chore(ci): Always run integration tests 2025-03-04 10:30:05 +01:00
4 changed files with 39 additions and 70 deletions

View File

@ -77,12 +77,6 @@ steps:
wget https://git.coopcloud.tech/toolshed/abra/raw/branch/main/scripts/tests/run-ci-int -O run-ci-int
chmod +x run-ci-int
sh run-ci-int
when:
event:
- cron:
cron:
# @daily https://docs.drone.io/cron/
- integration
volumes:
- name: deps

View File

@ -10,7 +10,6 @@ import (
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/tagcmp"
"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/lipgloss"
@ -64,11 +63,7 @@ func NewVersionOverview(
upperKind := strings.ToUpper(kind)
envVersion, err := recipe.GetEnvVersionRaw(app.Recipe.Name)
if err != nil {
return err
}
envVersion := app.Recipe.EnvVersion
if envVersion == "" {
envVersion = config.NO_VERSION_DEFAULT
}
@ -162,16 +157,7 @@ func DeployOverview(
toDeployChaosVersion = formatter.AddDirtyMarker(toDeployChaosVersion)
}
recipeName, exists := app.Env["RECIPE"]
if !exists {
recipeName = app.Env["TYPE"]
}
envVersion, err := recipe.GetEnvVersionRaw(recipeName)
if err != nil {
return err
}
envVersion := app.Recipe.EnvVersionRaw
if envVersion == "" {
envVersion = config.NO_VERSION_DEFAULT
}
@ -242,16 +228,7 @@ func UndeployOverview(
domain = config.NO_DOMAIN_DEFAULT
}
recipeName, exists := app.Env["RECIPE"]
if !exists {
recipeName = app.Env["TYPE"]
}
envVersion, err := recipe.GetEnvVersionRaw(recipeName)
if err != nil {
return err
}
envVersion := app.Recipe.EnvVersionRaw
if envVersion == "" {
envVersion = config.NO_VERSION_DEFAULT
}

View File

@ -119,22 +119,10 @@ type Features struct {
SSO string `json:"sso"`
}
func GetEnvVersionRaw(name string) (string, error) {
var version string
if strings.Contains(name, ":") {
split := strings.Split(name, ":")
if len(split) > 2 {
return version, fmt.Errorf("version seems invalid: %s", name)
}
version = split[1]
}
return version, nil
}
func Get(name string) Recipe {
version := ""
versionRaw := ""
dirty := false
if strings.Contains(name, ":") {
split := strings.Split(name, ":")
if len(split) > 2 {
@ -143,8 +131,10 @@ func Get(name string) Recipe {
name = split[0]
version = split[1]
versionRaw = version
if strings.HasSuffix(version, config.DIRTY_DEFAULT) {
version = strings.Replace(split[1], config.DIRTY_DEFAULT, "", 1)
dirty = true
log.Debugf("removed dirty suffix from .env version: %s -> %s", split[1], version)
}
}
@ -167,11 +157,13 @@ func Get(name string) Recipe {
dir := path.Join(config.RECIPES_DIR, escapeRecipeName(name))
r := Recipe{
Name: name,
EnvVersion: version,
Dir: dir,
GitURL: gitURL,
SSHURL: sshURL,
Name: name,
EnvVersion: version,
EnvVersionRaw: versionRaw,
Dirty: dirty,
Dir: dir,
GitURL: gitURL,
SSHURL: sshURL,
ComposePath: path.Join(dir, "compose.yml"),
ReadmePath: path.Join(dir, "README.md"),
@ -187,12 +179,13 @@ func Get(name string) Recipe {
}
type Recipe struct {
Name string
EnvVersion string
Dirty bool // NOTE(d1): git terminology for unstaged changes
Dir string
GitURL string
SSHURL string
Name string
EnvVersion string
EnvVersionRaw string
Dirty bool // NOTE(d1): git terminology for unstaged changes
Dir string
GitURL string
SSHURL string
ComposePath string
ReadmePath string

View File

@ -34,6 +34,7 @@ func TestGet(t *testing.T) {
recipe: Recipe{
Name: "foo",
EnvVersion: "1.2.3",
EnvVersionRaw: "1.2.3",
Dir: path.Join(cfg.GetAbraDir(), "/recipes/foo"),
GitURL: "https://git.coopcloud.tech/coop-cloud/foo.git",
SSHURL: "ssh://git@git.coopcloud.tech:2222/coop-cloud/foo.git",
@ -61,6 +62,23 @@ func TestGet(t *testing.T) {
recipe: Recipe{
Name: "mygit.org/myorg/cool-recipe",
EnvVersion: "1.2.4",
EnvVersionRaw: "1.2.4",
Dir: path.Join(cfg.GetAbraDir(), "/recipes/mygit_org_myorg_cool-recipe"),
GitURL: "https://mygit.org/myorg/cool-recipe.git",
SSHURL: "ssh://git@mygit.org/myorg/cool-recipe.git",
ComposePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/compose.yml"),
ReadmePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/README.md"),
SampleEnvPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/.env.sample"),
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/abra.sh"),
},
},
{
name: "mygit.org/myorg/cool-recipe:1e83340e+U",
recipe: Recipe{
Name: "mygit.org/myorg/cool-recipe",
EnvVersion: "1e83340e",
EnvVersionRaw: "1e83340e+U",
Dirty: true,
Dir: path.Join(cfg.GetAbraDir(), "/recipes/mygit_org_myorg_cool-recipe"),
GitURL: "https://mygit.org/myorg/cool-recipe.git",
SSHURL: "ssh://git@mygit.org/myorg/cool-recipe.git",
@ -105,16 +123,3 @@ func TestGetVersionLabelLocalDoesNotUseTimeoutLabel(t *testing.T) {
assert.NotEqual(t, label, defaultTimeoutLabel)
}
}
func TestDirtyMarkerRemoved(t *testing.T) {
r := Get("abra-test-recipe:1e83340e+U")
assert.Equal(t, "1e83340e", r.EnvVersion)
}
func TestGetEnvVersionRaw(t *testing.T) {
v, err := GetEnvVersionRaw("abra-test-recipe:1e83340e+U")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "1e83340e+U", v)
}