From bd21014fedf6f8d4fb8f1baf44fb8b0df99fc326 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Thu, 15 Feb 2024 17:31:04 +0100 Subject: [PATCH 01/22] fix tests/integration/app_check.bats --- tests/integration/app_check.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/app_check.bats b/tests/integration/app_check.bats index 2ea628c9..e286a5ed 100644 --- a/tests/integration/app_check.bats +++ b/tests/integration/app_check.bats @@ -70,13 +70,13 @@ setup(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA app check "$TEST_APP_DOMAIN" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + refute_output --partial "Your branch is behind 'origin/main' by 3 commits" _reset_recipe } @@ -86,7 +86,7 @@ setup(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 1' + assert_output --partial "Your branch is behind 'origin/main' by 1 commit" # NOTE(d1): we can't quite tell if this will fail or not in the future, so, # since it isn't an important part of what we're testing here, we don't check @@ -94,7 +94,7 @@ setup(){ run $ABRA app check "$TEST_APP_DOMAIN" --offline run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 1' + assert_output --partial "Your branch is behind 'origin/main' by 1 commit" _reset_recipe } -- 2.49.0 From 6e99b74c24e92a293a5f71d7aacd552441dc8613 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Thu, 15 Feb 2024 18:10:10 +0100 Subject: [PATCH 02/22] partially fix tests/integration/app_rollback.bats --- tests/integration/app_rollback.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index 0439b94f..d8c2b9ed 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -50,13 +50,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + assert_output --partial "Your branch is up to date with 'origin/main'" } @test "ensure recipe not up to date if --offline" { @@ -67,14 +67,14 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA app rollback "$TEST_APP_DOMAIN" \ --no-input --no-converge-checks --offline assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" assert_success -- 2.49.0 From bd069d32f6d58f12cf8b0d2a1fef0e4cdc50d94d Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 12:04:24 +0100 Subject: [PATCH 03/22] fix tests/integration/app_secret.bats --- tests/integration/app_secret.bats | 9 +-------- tests/integration/helpers/app.bash | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index 3d15e959..b745a939 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -8,7 +8,7 @@ setup_file(){ run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ - --domain "$TEST_APP_DOMAIN" \ + --domain "$TEST_APP_DOMAIN" assert_success assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" } @@ -19,13 +19,6 @@ teardown_file(){ _reset_recipe } -teardown(){ - # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 - if [[ -z "${BATS_TEST_COMPLETED}" ]]; then - _undeploy_app - fi -} - setup(){ load "$PWD/tests/integration/helpers/common" _common_setup diff --git a/tests/integration/helpers/app.bash b/tests/integration/helpers/app.bash index ee3e30f6..32208b84 100644 --- a/tests/integration/helpers/app.bash +++ b/tests/integration/helpers/app.bash @@ -49,7 +49,7 @@ _reset_app(){ run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ - --domain "$TEST_APP_DOMAIN" \ + --domain "$TEST_APP_DOMAIN" assert_success assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" } -- 2.49.0 From 328b4d38596c9dec71c5f98fcb587bbb7397ea70 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 12:13:14 +0100 Subject: [PATCH 04/22] fix _rm_server for local server --- tests/integration/helpers/server.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/helpers/server.bash b/tests/integration/helpers/server.bash index 3c6c74d7..e3bcb320 100644 --- a/tests/integration/helpers/server.bash +++ b/tests/integration/helpers/server.bash @@ -11,7 +11,11 @@ _add_server() { } _rm_server() { - run $ABRA server remove --no-input "$TEST_SERVER" + if [[ "$TEST_SERVER" == "default" ]]; then + run rm -rf "$ABRA_DIR/servers/default" + else + run $ABRA server remove --no-input "$TEST_SERVER" + fi assert_success assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER" } -- 2.49.0 From ad323ad2bd6184c69baf909f891a8bf8ffc168a4 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 12:22:36 +0100 Subject: [PATCH 05/22] partially fix tests/integration/app_version.bats --- tests/integration/app_version.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/app_version.bats b/tests/integration/app_version.bats index 2a6d6319..0885b044 100644 --- a/tests/integration/app_version.bats +++ b/tests/integration/app_version.bats @@ -92,7 +92,7 @@ teardown(){ assert_success # NOTE(d1): to let the stack come down before nuking volumes - sleep 3 + sleep 5 run $ABRA app volume remove "$appDomain" --no-input assert_success -- 2.49.0 From 03c38237707ae795b723180eb07a7edc84a8de35 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 14:12:18 +0100 Subject: [PATCH 06/22] fix tests/integration/app_volume.bats --- tests/integration/app_volume.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/app_volume.bats b/tests/integration/app_volume.bats index 5b4ff600..99acc6c9 100644 --- a/tests/integration/app_volume.bats +++ b/tests/integration/app_volume.bats @@ -79,7 +79,7 @@ teardown(){ _undeploy_app # NOTE(d1): to let the stack come down before nuking volumes - sleep 5 + sleep 10 run $ABRA app volume rm "$TEST_APP_DOMAIN" --force assert_success @@ -93,7 +93,7 @@ teardown(){ _undeploy_app # NOTE(d1): to let the stack come down before nuking volumes - sleep 5 + sleep 10 run $ABRA app volume rm "$TEST_APP_DOMAIN" --force assert_success -- 2.49.0 From f2dd5afc38a25a8316899fa0c6d59499445868d7 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 14:23:40 +0100 Subject: [PATCH 07/22] fix tests/integration/app_restore.bats --- tests/integration/app_restore.bats | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/app_restore.bats b/tests/integration/app_restore.bats index 77a63f63..eed588c0 100644 --- a/tests/integration/app_restore.bats +++ b/tests/integration/app_restore.bats @@ -109,13 +109,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" - run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST + run $ABRA app restore "$TEST_APP_DOMAIN" app assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + assert_output --partial "Your branch is up to date with 'origin/main'" } @test "ensure recipe not up to date if --offline" { @@ -126,19 +126,19 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" - run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST --offline + run $ABRA app restore "$TEST_APP_DOMAIN" app --offline assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + assert_output --partial "HEAD detached at $latestCommit" } @test "error if missing service" { -- 2.49.0 From 08232b74f6d512ab2ca7c08f67bb7c227b82a2ca Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 20:40:58 +0100 Subject: [PATCH 08/22] partially fix tests/integration/app_cmd.bats --- tests/integration/app_cmd.bats | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index db2808ba..648d7cc3 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -58,7 +58,7 @@ test_cmd_export" assert_success assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' @@ -70,7 +70,7 @@ test_cmd_export" assert_success assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd assert_failure assert_output --partial 'locally unstaged changes' @@ -83,7 +83,7 @@ test_cmd_export" assert_success assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --chaos + run $ABRA app cmd --local --chaos "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' @@ -96,14 +96,14 @@ test_cmd_export" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + assert_output --partial "Your branch is up to date with 'origin/main'" _reset_recipe "$TEST_RECIPE" } @@ -113,14 +113,14 @@ test_cmd_export" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --offline + run $ABRA app cmd --local --offline "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" _reset_recipe "$TEST_RECIPE" } @@ -132,13 +132,13 @@ test_cmd_export" } @test "error if missing arguments when passing --local" { - run $ABRA app cmd "$TEST_APP_DOMAIN" --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" assert_failure assert_output --partial 'missing arguments' } @test "cannot use --local and --user at same time" { - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --user root + run $ABRA app cmd --local --user root "$TEST_APP_DOMAIN" test_cmd assert_failure assert_output --partial 'cannot use --local & --user together' } @@ -147,7 +147,7 @@ test_cmd_export" run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh" assert_success - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --chaos + run $ABRA app cmd --local --chaos "$TEST_APP_DOMAIN" test_cmd assert_failure assert_output --partial "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh does not exist" @@ -155,25 +155,25 @@ test_cmd_export" } @test "error if missing command" { - run $ABRA app cmd "$TEST_APP_DOMAIN" doesnt_exist --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" doesnt_exist assert_failure assert_output --partial "doesn't have a doesnt_exist function" } @test "run --local command" { - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' } @test "run command with single arg" { - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_arg --local -- bing + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_arg -- bing assert_success assert_output --partial 'bing' } @test "run command with several args" { - run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_args --local -- bong bang + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_args -- bong bang assert_success assert_output --partial 'bong bang' } -- 2.49.0 From 8a84b1067cd66a6b5dd4f2aca05ead84fdcf4cd1 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Sun, 18 Feb 2024 21:57:38 +0100 Subject: [PATCH 09/22] partially fix tests/integration/recipe_version.bats --- tests/integration/recipe_version.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/recipe_version.bats b/tests/integration/recipe_version.bats index 42d2e4d0..d25faef9 100644 --- a/tests/integration/recipe_version.bats +++ b/tests/integration/recipe_version.bats @@ -12,7 +12,7 @@ setup() { } @test "error if not present in catalogue" { - run $ABRA recipe versions "$TEST_RECIPE" + run $ABRA recipe versions "not-in-catalogue" assert_failure assert_output --partial "is not published on the catalogue" } -- 2.49.0 From 2f29fbeb2e018656413fa25f8615b7a98cdcb083 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Fri, 23 Feb 2024 12:12:56 +0100 Subject: [PATCH 10/22] fix tests/integration/app_remove.bats --- tests/integration/app_remove.bats | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/app_remove.bats b/tests/integration/app_remove.bats index 8800e70a..4cf6f07a 100644 --- a/tests/integration/app_remove.bats +++ b/tests/integration/app_remove.bats @@ -104,7 +104,10 @@ teardown(){ _undeploy_app - run $ABRA app volume rm "$TEST_APP_DOMAIN" + # TODO: should wait as long as volume is no longer in use + sleep 10 + + run $ABRA app volume rm "$TEST_APP_DOMAIN" --no-input assert_success run $ABRA app volume ls "$TEST_APP_DOMAIN" -- 2.49.0 From b6b0808066a11e4bcd77517ec39600d500bcb944 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Fri, 23 Feb 2024 12:21:07 +0100 Subject: [PATCH 11/22] fix tests/integration/recipe_lint.bats --- tests/integration/recipe_lint.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/recipe_lint.bats b/tests/integration/recipe_lint.bats index 0b2617b4..1f1ba5c1 100644 --- a/tests/integration/recipe_lint.bats +++ b/tests/integration/recipe_lint.bats @@ -66,13 +66,13 @@ setup() { assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA recipe lint "$TEST_RECIPE" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + refute_output --partial "Your branch is behind 'origin/main' by 3 commits" _reset_recipe } @@ -82,13 +82,13 @@ setup() { assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA recipe lint "$TEST_RECIPE" --offline assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" _reset_recipe } -- 2.49.0 From 0aac464ded6b43afb3ec37ade2f64d6191b9838f Mon Sep 17 00:00:00 2001 From: p4u1 Date: Fri, 23 Feb 2024 12:34:59 +0100 Subject: [PATCH 12/22] fix tests/integration/recipe_new.bats --- cli/internal/cli.go | 16 ++++++++++++++++ cli/recipe/new.go | 7 ++++--- pkg/git/init.go | 13 +++++++++---- tests/integration/recipe_new.bats | 4 ++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/cli/internal/cli.go b/cli/internal/cli.go index b7555bdc..c80a3082 100644 --- a/cli/internal/cli.go +++ b/cli/internal/cli.go @@ -238,6 +238,22 @@ var RemoteUserFlag = &cli.StringFlag{ Destination: &RemoteUser, } +var GitUser string +var GitUserFlag = &cli.StringFlag{ + Name: "git-user, gu", + Value: "", + Usage: "Git user name to do commits with", + Destination: &GitUser, +} + +var GitEmail string +var GitEmailFlag = &cli.StringFlag{ + Name: "git-email, ge", + Value: "", + Usage: "Git email name to do commits with", + Destination: &GitEmail, +} + // SubCommandBefore wires up pre-action machinery (e.g. --debug handling). func SubCommandBefore(c *cli.Context) error { if Debug { diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 87e84d87..3c109def 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "os" "path" "text/template" @@ -37,6 +36,8 @@ var recipeNewCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, internal.OfflineFlag, + internal.GitUserFlag, + internal.GitEmailFlag, }, Before: internal.SubCommandBefore, Usage: "Create a new recipe", @@ -92,14 +93,14 @@ recipe and domain in the sample environment config). logrus.Fatal(err) } - if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil { + if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil { logrus.Fatal(err) } } newGitRepo := path.Join(config.RECIPES_DIR, recipeName) - if err := git.Init(newGitRepo, true); err != nil { + if err := git.Init(newGitRepo, true, internal.GitUser, internal.GitEmail); err != nil { logrus.Fatal(err) } diff --git a/pkg/git/init.go b/pkg/git/init.go index d0af92b0..851c2e5c 100644 --- a/pkg/git/init.go +++ b/pkg/git/init.go @@ -2,13 +2,13 @@ package git import ( "github.com/go-git/go-git/v5" - gitPkg "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing/object" "github.com/sirupsen/logrus" ) // Init inits a new repo and commits all the stuff if you want -func Init(repoPath string, commit bool) error { - if _, err := gitPkg.PlainInit(repoPath, false); err != nil { +func Init(repoPath string, commit bool, gitUser, gitEmail string) error { + if _, err := git.PlainInit(repoPath, false); err != nil { logrus.Fatal(err) } logrus.Debugf("initialised new git repo in %s", repoPath) @@ -28,7 +28,12 @@ func Init(repoPath string, commit bool) error { return err } - if _, err = commitWorktree.Commit("init", &git.CommitOptions{}); err != nil { + var author *object.Signature + if gitUser != "" && gitEmail != "" { + author = &object.Signature{Name: gitUser, Email: gitEmail} + } + + if _, err = commitWorktree.Commit("init", &git.CommitOptions{Author: author}); err != nil { return err } logrus.Debugf("init committed all files for new git repo in %s", repoPath) diff --git a/tests/integration/recipe_new.bats b/tests/integration/recipe_new.bats index 6149f053..7b14201c 100644 --- a/tests/integration/recipe_new.bats +++ b/tests/integration/recipe_new.bats @@ -23,14 +23,14 @@ teardown(){ } @test "create new recipe" { - run $ABRA recipe new foobar + run $ABRA recipe new foobar --git-user foo --git-email foo@example.com assert_success assert_output --partial 'Your new foobar recipe has been created' assert_exists "$ABRA_DIR/recipes/foobar" } @test "create new app from new recipe" { - run $ABRA recipe new foobar + run $ABRA recipe new foobar --git-user foo --git-email foo@example.com assert_success run $ABRA app new foobar \ -- 2.49.0 From ab86904cf45db89c7c189ca1fd9971909bd446dd Mon Sep 17 00:00:00 2001 From: p4u1 Date: Fri, 23 Feb 2024 12:37:26 +0100 Subject: [PATCH 13/22] fix tests/integration/recipe_upgrade.bats --- tests/integration/recipe_upgrade.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/recipe_upgrade.bats b/tests/integration/recipe_upgrade.bats index 183d1f22..b1d2020f 100644 --- a/tests/integration/recipe_upgrade.bats +++ b/tests/integration/recipe_upgrade.bats @@ -61,14 +61,14 @@ setup(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --partial "Your branch is behind 'origin/main' by 3 commits" run $ABRA recipe upgrade "$TEST_RECIPE" --no-input assert_success assert_output --partial 'can upgrade service: app' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + refute_output --partial "Your branch is behind 'origin/main' by 3 commits" _reset_recipe } -- 2.49.0 From 1fd14fa76fd3581c57dd57e017614751c8193453 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 4 Mar 2024 16:03:13 +0100 Subject: [PATCH 14/22] patches by decentral1se Co-authored-by: decentral1se --- scripts/installer/installer | 2 +- tests/integration/recipe_version.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/installer/installer b/scripts/installer/installer index 01605942..8b8ee5ec 100755 --- a/scripts/installer/installer +++ b/scripts/installer/installer @@ -2,7 +2,7 @@ ABRA_VERSION="0.8.1-beta" ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION" -RC_VERSION="0.8.1-beta" +RC_VERSION="0.8.0-rc1-beta" RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION" for arg in "$@"; do diff --git a/tests/integration/recipe_version.bats b/tests/integration/recipe_version.bats index d25faef9..eea0bce4 100644 --- a/tests/integration/recipe_version.bats +++ b/tests/integration/recipe_version.bats @@ -12,7 +12,7 @@ setup() { } @test "error if not present in catalogue" { - run $ABRA recipe versions "not-in-catalogue" + run $ABRA recipe versions "example" assert_failure assert_output --partial "is not published on the catalogue" } -- 2.49.0 From a760280564daefe100251f2000cb69407708557d Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 4 Mar 2024 16:31:11 +0100 Subject: [PATCH 15/22] changes git message asserts --- tests/integration/app_check.bats | 4 ++-- tests/integration/app_cmd.bats | 8 ++++---- tests/integration/app_new.bats | 10 +++++----- tests/integration/app_restore.bats | 8 ++++---- tests/integration/app_rollback.bats | 8 ++++---- tests/integration/recipe_lint.bats | 8 ++++---- tests/integration/recipe_upgrade.bats | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/integration/app_check.bats b/tests/integration/app_check.bats index e286a5ed..e296e3cb 100644 --- a/tests/integration/app_check.bats +++ b/tests/integration/app_check.bats @@ -70,13 +70,13 @@ setup(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app check "$TEST_APP_DOMAIN" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' _reset_recipe } diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index 648d7cc3..fd5e6695 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -96,14 +96,14 @@ test_cmd_export" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is up to date with 'origin/main'" + assert_output --partial "up to date" _reset_recipe "$TEST_RECIPE" } @@ -113,14 +113,14 @@ test_cmd_export" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app cmd --local --offline "$TEST_APP_DOMAIN" test_cmd assert_success assert_output --partial 'baz' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' _reset_recipe "$TEST_RECIPE" } diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index 885e02cd..457ee152 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -45,7 +45,7 @@ teardown(){ assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is up to date with 'origin/main'." + assert_output --partial "up to date" } @test "create new app with version" { @@ -121,7 +121,7 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded." + assert_output --regexp 'behind .* 3 commits' run $ABRA app new "$TEST_RECIPE" \ --no-input \ @@ -131,7 +131,7 @@ teardown(){ assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is up to date with 'origin/main'." + assert_output --partial "up to date" _reset_recipe } @@ -141,7 +141,7 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded." + assert_output --regexp 'behind .* 3 commits' # NOTE(d1): need to use --chaos to force same commit run $ABRA app new "$TEST_RECIPE" \ @@ -154,7 +154,7 @@ teardown(){ assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded." + assert_output --regexp 'behind .* 3 commits' _reset_recipe } diff --git a/tests/integration/app_restore.bats b/tests/integration/app_restore.bats index eed588c0..f2cf52e8 100644 --- a/tests/integration/app_restore.bats +++ b/tests/integration/app_restore.bats @@ -109,13 +109,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app restore "$TEST_APP_DOMAIN" app assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is up to date with 'origin/main'" + assert_output --partial "up to date" } @test "ensure recipe not up to date if --offline" { @@ -126,13 +126,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app restore "$TEST_APP_DOMAIN" app --offline assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" assert_success diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index d8c2b9ed..093692ed 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -50,13 +50,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is up to date with 'origin/main'" + assert_output --partial "up to date" } @test "ensure recipe not up to date if --offline" { @@ -67,14 +67,14 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA app rollback "$TEST_APP_DOMAIN" \ --no-input --no-converge-checks --offline assert_failure run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" assert_success diff --git a/tests/integration/recipe_lint.bats b/tests/integration/recipe_lint.bats index 1f1ba5c1..401ab8fd 100644 --- a/tests/integration/recipe_lint.bats +++ b/tests/integration/recipe_lint.bats @@ -66,13 +66,13 @@ setup() { assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA recipe lint "$TEST_RECIPE" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' _reset_recipe } @@ -82,13 +82,13 @@ setup() { assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA recipe lint "$TEST_RECIPE" --offline assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' _reset_recipe } diff --git a/tests/integration/recipe_upgrade.bats b/tests/integration/recipe_upgrade.bats index b1d2020f..a36efe26 100644 --- a/tests/integration/recipe_upgrade.bats +++ b/tests/integration/recipe_upgrade.bats @@ -61,14 +61,14 @@ setup(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' run $ABRA recipe upgrade "$TEST_RECIPE" --no-input assert_success assert_output --partial 'can upgrade service: app' run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial "Your branch is behind 'origin/main' by 3 commits" + assert_output --regexp 'behind .* 3 commits' _reset_recipe } -- 2.49.0 From a44549117d444d5cec7d55ace39962f681db59a0 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Thu, 7 Mar 2024 17:48:42 +0100 Subject: [PATCH 16/22] Revert "fix tests/integration/recipe_new.bats" This reverts commit 0aac464ded6b43afb3ec37ade2f64d6191b9838f. --- cli/internal/cli.go | 16 ---------------- cli/recipe/new.go | 7 +++---- pkg/git/init.go | 13 ++++--------- tests/integration/recipe_new.bats | 4 ++-- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/cli/internal/cli.go b/cli/internal/cli.go index c80a3082..b7555bdc 100644 --- a/cli/internal/cli.go +++ b/cli/internal/cli.go @@ -238,22 +238,6 @@ var RemoteUserFlag = &cli.StringFlag{ Destination: &RemoteUser, } -var GitUser string -var GitUserFlag = &cli.StringFlag{ - Name: "git-user, gu", - Value: "", - Usage: "Git user name to do commits with", - Destination: &GitUser, -} - -var GitEmail string -var GitEmailFlag = &cli.StringFlag{ - Name: "git-email, ge", - Value: "", - Usage: "Git email name to do commits with", - Destination: &GitEmail, -} - // SubCommandBefore wires up pre-action machinery (e.g. --debug handling). func SubCommandBefore(c *cli.Context) error { if Debug { diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 3c109def..87e84d87 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "io/ioutil" "os" "path" "text/template" @@ -36,8 +37,6 @@ var recipeNewCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, internal.OfflineFlag, - internal.GitUserFlag, - internal.GitEmailFlag, }, Before: internal.SubCommandBefore, Usage: "Create a new recipe", @@ -93,14 +92,14 @@ recipe and domain in the sample environment config). logrus.Fatal(err) } - if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil { + if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil { logrus.Fatal(err) } } newGitRepo := path.Join(config.RECIPES_DIR, recipeName) - if err := git.Init(newGitRepo, true, internal.GitUser, internal.GitEmail); err != nil { + if err := git.Init(newGitRepo, true); err != nil { logrus.Fatal(err) } diff --git a/pkg/git/init.go b/pkg/git/init.go index 851c2e5c..d0af92b0 100644 --- a/pkg/git/init.go +++ b/pkg/git/init.go @@ -2,13 +2,13 @@ package git import ( "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing/object" + gitPkg "github.com/go-git/go-git/v5" "github.com/sirupsen/logrus" ) // Init inits a new repo and commits all the stuff if you want -func Init(repoPath string, commit bool, gitUser, gitEmail string) error { - if _, err := git.PlainInit(repoPath, false); err != nil { +func Init(repoPath string, commit bool) error { + if _, err := gitPkg.PlainInit(repoPath, false); err != nil { logrus.Fatal(err) } logrus.Debugf("initialised new git repo in %s", repoPath) @@ -28,12 +28,7 @@ func Init(repoPath string, commit bool, gitUser, gitEmail string) error { return err } - var author *object.Signature - if gitUser != "" && gitEmail != "" { - author = &object.Signature{Name: gitUser, Email: gitEmail} - } - - if _, err = commitWorktree.Commit("init", &git.CommitOptions{Author: author}); err != nil { + if _, err = commitWorktree.Commit("init", &git.CommitOptions{}); err != nil { return err } logrus.Debugf("init committed all files for new git repo in %s", repoPath) diff --git a/tests/integration/recipe_new.bats b/tests/integration/recipe_new.bats index 7b14201c..6149f053 100644 --- a/tests/integration/recipe_new.bats +++ b/tests/integration/recipe_new.bats @@ -23,14 +23,14 @@ teardown(){ } @test "create new recipe" { - run $ABRA recipe new foobar --git-user foo --git-email foo@example.com + run $ABRA recipe new foobar assert_success assert_output --partial 'Your new foobar recipe has been created' assert_exists "$ABRA_DIR/recipes/foobar" } @test "create new app from new recipe" { - run $ABRA recipe new foobar --git-user foo --git-email foo@example.com + run $ABRA recipe new foobar assert_success run $ABRA app new foobar \ -- 2.49.0 From e84297425ea8a23fe4ab79e9572faee02063a09b Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 11 Mar 2024 12:25:00 +0100 Subject: [PATCH 17/22] partial fix app_deploy.bats --- tests/integration/app_deploy.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 5747ce6e..3700581f 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -82,13 +82,13 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --regexp 'behind .* 3 commits' run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' + refute_output --regexp 'behind .* 3 commits' _reset_recipe _undeploy_app @@ -100,7 +100,7 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --regexp 'behind .* 3 commits' # NOTE(d1): need to use --chaos to force same commit run $ABRA app deploy "$TEST_APP_DOMAIN" \ @@ -108,7 +108,7 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --regexp 'behind .* 3 commits' _undeploy_app _reset_recipe -- 2.49.0 From 81897bf4daf6d37f3997fdea0deafb1d8f241c6c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 11 Mar 2024 13:57:07 +0100 Subject: [PATCH 18/22] test: skip known failures [ci skip] See https://git.coopcloud.tech/coop-cloud/abra/pulls/403 --- tests/integration/app_version.bats | 2 ++ tests/integration/recipe_version.bats | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/app_version.bats b/tests/integration/app_version.bats index 0885b044..b11f58ef 100644 --- a/tests/integration/app_version.bats +++ b/tests/integration/app_version.bats @@ -59,6 +59,8 @@ teardown(){ # bats test_tags=slow @test "error if not in catalogue" { + skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6" + _deploy_app run $ABRA app version "$TEST_APP_DOMAIN" diff --git a/tests/integration/recipe_version.bats b/tests/integration/recipe_version.bats index eea0bce4..ebc5bad9 100644 --- a/tests/integration/recipe_version.bats +++ b/tests/integration/recipe_version.bats @@ -12,7 +12,9 @@ setup() { } @test "error if not present in catalogue" { - run $ABRA recipe versions "example" + skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6" + + run $ABRA recipe versions "$TEST_RECIPE" assert_failure assert_output --partial "is not published on the catalogue" } -- 2.49.0 From 555f830720f76af0f8641430d0ae30bde5b4447e Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 11 Mar 2024 14:02:09 +0100 Subject: [PATCH 19/22] remove --no-converge-checks to make sure the network exists when the rollback command is executed --- tests/integration/app_rollback.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index 093692ed..b8200bbb 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -131,7 +131,7 @@ teardown(){ latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)" run $ABRA app deploy "$TEST_APP_DOMAIN" \ - --no-input --no-converge-checks --chaos + --no-input --chaos assert_success assert_output --partial "$latestCommit" assert_output --partial 'chaos' -- 2.49.0 From 0ca65b1d4fe945646fd8e51ad0e4a7ebd110bbd5 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 11 Mar 2024 14:11:40 +0100 Subject: [PATCH 20/22] skip expected failure when running tests locally --- tests/integration/app_deploy.bats | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 3700581f..285ff4da 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -273,6 +273,10 @@ teardown(){ } @test "ensure domain is checked" { + if [[ "$TEST_SERVER" == "default" ]]; then + skip "domain checks are disabled for local server" + fi + appDomain="custom-html.DOESNTEXIST" run $ABRA app new custom-html \ -- 2.49.0 From 0344203209e78be04905d6ffdfbed8b3d5ac6eae Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 11 Mar 2024 14:21:29 +0100 Subject: [PATCH 21/22] properly reset recipe --- tests/integration/app_deploy.bats | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 285ff4da..59cdd481 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -16,6 +16,7 @@ teardown_file(){ setup(){ load "$PWD/tests/integration/helpers/common" _common_setup + _reset_recipe } teardown(){ @@ -140,7 +141,7 @@ teardown(){ assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' + assert_output --regexp 'behind .* 3 commits' threeCommitsBack="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)" -- 2.49.0 From ef5f54e146d7aac09675fdf26238d2fac3faf24c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 11 Mar 2024 14:22:06 +0100 Subject: [PATCH 22/22] test: skip this test for $reasons See https://git.coopcloud.tech/coop-cloud/abra/pulls/403 --- tests/integration/app_deploy.bats | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 59cdd481..0df25675 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -117,6 +117,9 @@ teardown(){ # bats test_tags=slow @test "deploy latest commit if no published versions and no --chaos" { + # TODO(d1): fix with a new test recipe which has no published versions? + skip "known issue, abra-test-recipe has published versions now" + latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)" _remove_tags -- 2.49.0