Add separate production, testserver, and demo deployments
CI / test (push) Failing after 10s

This commit is contained in:
2026-09-14 19:58:31 +02:00
parent b87aa0aa17
commit d06ff4a94a
37 changed files with 1293 additions and 121 deletions
+10 -1
View File
@@ -4,8 +4,11 @@ import (
"errors"
"fmt"
"net/url"
"strings"
"gardomatic.kleiax.de/internal/platform/environment"
"gardomatic.kleiax.de/internal/platform/validate"
"gardomatic.kleiax.de/internal/storage"
"gardomatic.kleiax.de/internal/web"
)
@@ -18,7 +21,7 @@ func configFromEnvironment() (web.Config, error) {
if err != nil {
return web.Config{}, err
}
cfg := web.Config{Host: environment.String("GARDOMATIC_WEB_HOST", ""), Port: port, Env: environment.String("GARDOMATIC_ENV", "development"), APIBaseURL: environment.String("GARDOMATIC_API_BASE_URL", "http://localhost:4000"), SessionCookieName: environment.String("GARDOMATIC_SESSION_COOKIE_NAME", "gardomatic_session"), CookieSecure: cookieSecure}
cfg := web.Config{Host: environment.String("GARDOMATIC_WEB_HOST", ""), Port: port, Env: environment.String("GARDOMATIC_ENV", "development"), APIBaseURL: environment.String("GARDOMATIC_API_BASE_URL", "http://localhost:4000"), DemoAccountEmail: strings.ToLower(strings.TrimSpace(environment.String("GARDOMATIC_DEMO_ACCOUNT_EMAIL", ""))), SessionCookieName: environment.String("GARDOMATIC_SESSION_COOKIE_NAME", "gardomatic_session"), CookieSecure: cookieSecure}
var errs []error
if cfg.Port < 1 || cfg.Port > 65535 {
errs = append(errs, errors.New("GARDOMATIC_WEB_PORT must be between 1 and 65535"))
@@ -30,5 +33,11 @@ func configFromEnvironment() (web.Config, error) {
if cfg.Env == "production" && !cfg.CookieSecure {
errs = append(errs, errors.New("GARDOMATIC_COOKIE_SECURE must be true in production"))
}
if cfg.DemoAccountEmail != "" {
v := validate.New()
if storage.ValidateEmail(v, cfg.DemoAccountEmail); !v.Valid() {
errs = append(errs, errors.New("GARDOMATIC_DEMO_ACCOUNT_EMAIL must be a valid email address"))
}
}
return cfg, errors.Join(errs...)
}
+9 -1
View File
@@ -6,11 +6,19 @@ func TestConfigFromEnvironment(t *testing.T) {
t.Setenv("GARDOMATIC_WEB_HOST", "0.0.0.0")
t.Setenv("GARDOMATIC_WEB_PORT", "4444")
t.Setenv("GARDOMATIC_API_BASE_URL", "https://api.example.com")
t.Setenv("GARDOMATIC_DEMO_ACCOUNT_EMAIL", " Demo@Example.com ")
cfg, err := configFromEnvironment()
if err != nil {
t.Fatal(err)
}
if cfg.Host != "0.0.0.0" || cfg.Port != 4444 || cfg.APIBaseURL != "https://api.example.com" {
if cfg.Host != "0.0.0.0" || cfg.Port != 4444 || cfg.APIBaseURL != "https://api.example.com" || cfg.DemoAccountEmail != "demo@example.com" {
t.Fatalf("unexpected config: %#v", cfg)
}
}
func TestConfigRejectsInvalidDemoAccountEmail(t *testing.T) {
t.Setenv("GARDOMATIC_DEMO_ACCOUNT_EMAIL", "not-an-email")
if _, err := configFromEnvironment(); err == nil {
t.Fatal("expected invalid demo account email error")
}
}