From 956399a1ea3806e70f33a6b36a6e670c94999e2e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 2 Jul 2023 11:31:06 +0200 Subject: [PATCH 01/11] Add script to run integration tests --- scripts/run_integration_tests.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/run_integration_tests.sh diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh new file mode 100755 index 000000000..d09bd21e7 --- /dev/null +++ b/scripts/run_integration_tests.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is ugly, but older versions of git don't support the GIT_CONFIG_GLOBAL +# env var; the only way to run tests for these old versions is to copy our test +# config file to the actual global location. Move an existing file out of the +# way so that we can restore it at the end. +if test -f ~/.gitconfig; then + mv ~/.gitconfig ~/.gitconfig.lazygit.bak +fi + +cp test/global_git_config ~/.gitconfig + +go test pkg/integration/clients/*.go +EXITCODE=$? + +if test -f ~/.gitconfig.lazygit.bak; then + mv ~/.gitconfig.lazygit.bak ~/.gitconfig +fi + +exit $EXITCODE From f4ada537d2f92c52264afe89769acbcb9a9f643f Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 15:48:43 +0200 Subject: [PATCH 02/11] Remove mainBranch parameter from Shell.Init() For older git versions we won't be able to support any other main branch than "master", so hard-code that in Init. This doesn't fix anything for older versions yet; see the next commit for that. --- pkg/integration/components/runner.go | 2 +- pkg/integration/components/shell.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index 9a787c864..40921fee9 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -141,7 +141,7 @@ func buildLazygit() error { func createFixture(test *IntegrationTest, paths Paths, rootDir string) error { shell := NewShell(paths.ActualRepo(), func(errorMsg string) { panic(errorMsg) }) - shell.Init("master") + shell.Init() os.Setenv(GIT_CONFIG_GLOBAL_ENV_VAR, globalGitConfigPath(rootDir)) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 03bd747e2..847e7bd70 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -254,8 +254,8 @@ func (self *Shell) StartBisect(good string, bad string) *Shell { return self } -func (self *Shell) Init(mainBranch string) *Shell { - self.RunCommand([]string{"git", "init", "-b", mainBranch}) +func (self *Shell) Init() *Shell { + self.RunCommand([]string{"git", "init", "-b", "master"}) return self } From 82b3803164395e34e0f57c0ce2930350adc578d1 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 15:50:50 +0200 Subject: [PATCH 03/11] Use -c init.defaultBranch=master to pass the desired main branch to git init Older versions of git don't support the -b option yet. However, no version of git complains about the -c option, even when the init.defaultBranch config is not supported. --- pkg/integration/components/shell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 847e7bd70..cb21c0c01 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -255,7 +255,7 @@ func (self *Shell) StartBisect(good string, bad string) *Shell { } func (self *Shell) Init() *Shell { - self.RunCommand([]string{"git", "init", "-b", "master"}) + self.RunCommand([]string{"git", "-c", "init.defaultBranch=master", "init"}) return self } From 1d96ade0ba832ad80e266d511d6b355b2cbddc9f Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 15:56:08 +0200 Subject: [PATCH 04/11] Remove StashWithMessage function It's identical to Stash(), so use that. --- pkg/integration/components/shell.go | 5 ----- pkg/integration/tests/stash/rename.go | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index cb21c0c01..6ff7dac34 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -196,11 +196,6 @@ func (self *Shell) CreateNCommitsStartingAt(n, startIndex int) *Shell { return self } -func (self *Shell) StashWithMessage(message string) *Shell { - self.RunCommand([]string{"git", "stash", "-m", message}) - return self -} - func (self *Shell) SetConfig(key string, value string) *Shell { self.RunCommand([]string{"git", "config", "--local", key, value}) return self diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go index 9a079c9db..eb57fa654 100644 --- a/pkg/integration/tests/stash/rename.go +++ b/pkg/integration/tests/stash/rename.go @@ -14,9 +14,9 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{ shell. EmptyCommit("blah"). CreateFileAndAdd("file-1", "change to stash1"). - StashWithMessage("foo"). + Stash("foo"). CreateFileAndAdd("file-2", "change to stash2"). - StashWithMessage("bar") + Stash("bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Stash(). From ea0baf58e6b4b819117a859e06e82c3cef1aaf0d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 16:00:16 +0200 Subject: [PATCH 05/11] Fix Shell.Stash() for older versions of git Older versions need an explicit "push" subcommand for the -m option to be recognized. --- pkg/integration/components/shell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 6ff7dac34..decb748da 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -240,7 +240,7 @@ func (self *Shell) HardReset(ref string) *Shell { } func (self *Shell) Stash(message string) *Shell { - self.RunCommand([]string{"git", "stash", "-m", message}) + self.RunCommand([]string{"git", "stash", "push", "-m", message}) return self } From 1827380c69f00288fe3c8e6dfb91775c6be4ffa9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 16:18:38 +0200 Subject: [PATCH 06/11] Fix git stash calls for older git versions Older git versions are pickier about parameter order: for "store", the sha argument must come last, and for "save", the message must come last. --- pkg/commands/git_commands/stash.go | 7 ++++--- pkg/commands/git_commands/stash_test.go | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/commands/git_commands/stash.go b/pkg/commands/git_commands/stash.go index 86018fd8d..a9e2d67e5 100644 --- a/pkg/commands/git_commands/stash.go +++ b/pkg/commands/git_commands/stash.go @@ -63,8 +63,9 @@ func (self *StashCommands) Save(message string) error { func (self *StashCommands) Store(sha string, message string) error { trimmedMessage := strings.Trim(message, " \t") - cmdArgs := NewGitCmd("stash").Arg("store", sha). + cmdArgs := NewGitCmd("stash").Arg("store"). ArgIf(trimmedMessage != "", "-m", trimmedMessage). + Arg(sha). ToArgv() return self.cmd.New(cmdArgs).Run() @@ -93,7 +94,7 @@ func (self *StashCommands) ShowStashEntryCmdObj(index int, ignoreWhitespace bool } func (self *StashCommands) StashAndKeepIndex(message string) error { - cmdArgs := NewGitCmd("stash").Arg("save", message, "--keep-index"). + cmdArgs := NewGitCmd("stash").Arg("save", "--keep-index", message). ToArgv() return self.cmd.New(cmdArgs).Run() @@ -171,7 +172,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error { func (self *StashCommands) StashIncludeUntrackedChanges(message string) error { return self.cmd.New( - NewGitCmd("stash").Arg("save", message, "--include-untracked"). + NewGitCmd("stash").Arg("save", "--include-untracked", message). ToArgv(), ).Run() } diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go index d19c0a519..f1a151cd8 100644 --- a/pkg/commands/git_commands/stash_test.go +++ b/pkg/commands/git_commands/stash_test.go @@ -57,7 +57,7 @@ func TestStashStore(t *testing.T) { testName: "Non-empty message", sha: "0123456789abcdef", message: "New stash name", - expected: []string{"stash", "store", "0123456789abcdef", "-m", "New stash name"}, + expected: []string{"stash", "store", "-m", "New stash name", "0123456789abcdef"}, }, { testName: "Empty message", @@ -162,7 +162,7 @@ func TestStashRename(t *testing.T) { expectedShaCmd: []string{"rev-parse", "refs/stash@{3}"}, shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n", expectedDropCmd: []string{"stash", "drop", "stash@{3}"}, - expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd", "-m", "New message"}, + expectedStoreCmd: []string{"stash", "store", "-m", "New message", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"}, }, { testName: "Empty message", From 30ce7c8085b0ca67d84451ad8607116c9e038fae Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 16:22:32 +0200 Subject: [PATCH 07/11] Replace uses of "git stash save" with "git stash push" Save has been deprecated for a while, push is the recommended way to save a stash. Push has been available since 2.13, so we can use it without problems. --- pkg/commands/git_commands/patch.go | 2 +- pkg/commands/git_commands/stash.go | 14 +++++++------- pkg/commands/git_commands/stash_test.go | 4 ++-- pkg/gui/controllers/files_controller.go | 6 +++--- pkg/gui/controllers/helpers/refs_helper.go | 2 +- pkg/gui/controllers/undo_controller.go | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/commands/git_commands/patch.go b/pkg/commands/git_commands/patch.go index 942785314..3159ff31d 100644 --- a/pkg/commands/git_commands/patch.go +++ b/pkg/commands/git_commands/patch.go @@ -221,7 +221,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s func (self *PatchCommands) MovePatchIntoIndex(commits []*models.Commit, commitIdx int, stash bool) error { if stash { - if err := self.stash.Save(self.Tr.StashPrefix + commits[commitIdx].Sha); err != nil { + if err := self.stash.Push(self.Tr.StashPrefix + commits[commitIdx].Sha); err != nil { return err } } diff --git a/pkg/commands/git_commands/stash.go b/pkg/commands/git_commands/stash.go index a9e2d67e5..562e7b97d 100644 --- a/pkg/commands/git_commands/stash.go +++ b/pkg/commands/git_commands/stash.go @@ -52,9 +52,9 @@ func (self *StashCommands) Apply(index int) error { return self.cmd.New(cmdArgs).Run() } -// Save save stash -func (self *StashCommands) Save(message string) error { - cmdArgs := NewGitCmd("stash").Arg("save", message). +// Push push stash +func (self *StashCommands) Push(message string) error { + cmdArgs := NewGitCmd("stash").Arg("push", "-m", message). ToArgv() return self.cmd.New(cmdArgs).Run() @@ -94,7 +94,7 @@ func (self *StashCommands) ShowStashEntryCmdObj(index int, ignoreWhitespace bool } func (self *StashCommands) StashAndKeepIndex(message string) error { - cmdArgs := NewGitCmd("stash").Arg("save", "--keep-index", message). + cmdArgs := NewGitCmd("stash").Arg("push", "--keep-index", "-m", message). ToArgv() return self.cmd.New(cmdArgs).Run() @@ -108,7 +108,7 @@ func (self *StashCommands) StashUnstagedChanges(message string) error { ).Run(); err != nil { return err } - if err := self.Save(message); err != nil { + if err := self.Push(message); err != nil { return err } @@ -130,7 +130,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error { return err } - if err := self.Save(message); err != nil { + if err := self.Push(message); err != nil { return err } @@ -172,7 +172,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error { func (self *StashCommands) StashIncludeUntrackedChanges(message string) error { return self.cmd.New( - NewGitCmd("stash").Arg("save", "--include-untracked", message). + NewGitCmd("stash").Arg("push", "--include-untracked", "-m", message). ToArgv(), ).Run() } diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go index f1a151cd8..1c8976c6d 100644 --- a/pkg/commands/git_commands/stash_test.go +++ b/pkg/commands/git_commands/stash_test.go @@ -37,10 +37,10 @@ func TestStashPop(t *testing.T) { func TestStashSave(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectGitArgs([]string{"stash", "save", "A stash message"}, "", nil) + ExpectGitArgs([]string{"stash", "push", "-m", "A stash message"}, "", nil) instance := buildStashCommands(commonDeps{runner: runner}) - assert.NoError(t, instance.Save("A stash message")) + assert.NoError(t, instance.Push("A stash message")) runner.CheckForMissingCalls() } diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 6d4647e01..1b5d44080 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -697,7 +697,7 @@ func (self *FilesController) createStashMenu() error { if !self.c.Helpers().WorkingTree.IsWorkingTreeDirty() { return self.c.ErrorMsg(self.c.Tr.NoFilesToStash) } - return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashAllChanges) + return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashAllChanges) }, Key: 'a', }, @@ -740,7 +740,7 @@ func (self *FilesController) createStashMenu() error { return self.handleStashSave(self.c.Git().Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges) } // ordinary stash - return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashUnstagedChanges) + return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashUnstagedChanges) }, Key: 'u', }, @@ -749,7 +749,7 @@ func (self *FilesController) createStashMenu() error { } func (self *FilesController) stash() error { - return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashAllChanges) + return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashAllChanges) } func (self *FilesController) createResetToUpstreamMenu() error { diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index af3a0875f..3c96add84 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -65,7 +65,7 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { - if err := self.c.Git().Stash.Save(self.c.Tr.StashPrefix + ref); err != nil { + if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + ref); err != nil { return self.c.Error(err) } if err := self.c.Git().Branch.Checkout(ref, cmdOptions); err != nil { diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index 60eff1888..1546d0c46 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -249,7 +249,7 @@ func (self *UndoController) hardResetWithAutoStash(commitSha string, options har Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error { - if err := self.c.Git().Stash.Save(self.c.Tr.StashPrefix + commitSha); err != nil { + if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitSha); err != nil { return self.c.Error(err) } if err := reset(); err != nil { From 85f7aa9d7bef5f3a82be38e1decf345049aa7bb6 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Wed, 22 Mar 2023 23:02:32 +0900 Subject: [PATCH 08/11] Fix conflict test The test apply_in_reverse_with_conflict.go fails in git versions 2.30.8 and earlier. Apparently the output "Applied patch to 'file2' cleanly" was only added more recently. It's not essential that we check this output. --- .../tests/patch_building/apply_in_reverse_with_conflict.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go index f767ba3a0..74dd34b3e 100644 --- a/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go +++ b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go @@ -55,8 +55,7 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Alert(). Title(Equals("Error")). - Content(Contains("Applied patch to 'file1' with conflicts."). - Contains("Applied patch to 'file2' cleanly.")). + Content(Contains("Applied patch to 'file1' with conflicts.")). Confirm() t.Views().Files(). From 62ab41c310124e5df210a4a4460b356ab6d0f73b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jul 2023 17:44:14 +0200 Subject: [PATCH 09/11] Fix pull rebase tests It seems that older git versions would drop empty commits when rebasing. Since this aspect is not relevant to what we're testing here, fix this by simply avoiding empty commits in these tests. --- pkg/integration/tests/sync/pull_rebase.go | 6 ++++-- .../tests/sync/pull_rebase_interactive_conflict.go | 6 ++++-- .../tests/sync/pull_rebase_interactive_conflict_drop.go | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/integration/tests/sync/pull_rebase.go b/pkg/integration/tests/sync/pull_rebase.go index 41ca82436..77810426e 100644 --- a/pkg/integration/tests/sync/pull_rebase.go +++ b/pkg/integration/tests/sync/pull_rebase.go @@ -15,14 +15,16 @@ var PullRebase = NewIntegrationTest(NewIntegrationTestArgs{ shell.Commit("one") shell.UpdateFileAndAdd("file", "content2") shell.Commit("two") - shell.EmptyCommit("three") + shell.CreateFileAndAdd("file3", "content3") + shell.Commit("three") shell.CloneIntoRemote("origin") shell.SetBranchUpstream("master", "origin/master") shell.HardReset("HEAD^^") - shell.EmptyCommit("four") + shell.CreateFileAndAdd("file4", "content4") + shell.Commit("four") shell.SetConfig("pull.rebase", "true") }, diff --git a/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go b/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go index 9e66f3bcd..a6a3f5356 100644 --- a/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go +++ b/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go @@ -15,7 +15,8 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{ shell.Commit("one") shell.UpdateFileAndAdd("file", "content2") shell.Commit("two") - shell.EmptyCommit("three") + shell.CreateFileAndAdd("file3", "content3") + shell.Commit("three") shell.CloneIntoRemote("origin") @@ -24,7 +25,8 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{ shell.HardReset("HEAD^^") shell.UpdateFileAndAdd("file", "content4") shell.Commit("four") - shell.EmptyCommit("five") + shell.CreateFileAndAdd("file5", "content5") + shell.Commit("five") shell.SetConfig("pull.rebase", "interactive") }, diff --git a/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go b/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go index 9ca3a0ebe..b53790964 100644 --- a/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go +++ b/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go @@ -15,7 +15,8 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg shell.Commit("one") shell.UpdateFileAndAdd("file", "content2") shell.Commit("two") - shell.EmptyCommit("three") + shell.CreateFileAndAdd("file3", "content3") + shell.Commit("three") shell.CloneIntoRemote("origin") @@ -24,7 +25,8 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg shell.HardReset("HEAD^^") shell.UpdateFileAndAdd("file", "content4") shell.Commit("four") - shell.EmptyCommit("five") + shell.CreateFileAndAdd("fil5", "content5") + shell.Commit("five") shell.SetConfig("pull.rebase", "interactive") }, From adce8ad398892c997b77475ce31d01ab2a4a80b5 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 2 Jul 2023 20:07:26 +0200 Subject: [PATCH 10/11] Update checkout and cache action versions --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 10 +++++----- .github/workflows/sponsors.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 49fad7731..398fd1ede 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Unshallow repo run: git fetch --prune --unshallow - name: Setup Go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3494e6a40..ffa788d99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: GOFLAGS: -mod=vendor steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v1 with: @@ -53,7 +53,7 @@ jobs: GOFLAGS: -mod=vendor steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v1 with: @@ -77,7 +77,7 @@ jobs: GOARCH: amd64 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v1 with: @@ -113,7 +113,7 @@ jobs: GOARCH: amd64 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v1 with: @@ -147,7 +147,7 @@ jobs: GOFLAGS: -mod=vendor steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v1 with: diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml index e4c780445..cdf328a73 100644 --- a/.github/workflows/sponsors.yml +++ b/.github/workflows/sponsors.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout 🛎️ - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Generate Sponsors 💖 uses: JamesIves/github-sponsors-readme-action@v1.0.8 From d71f5d951eb7bb69cd894750347002bed8416998 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 2 Jul 2023 20:17:18 +0200 Subject: [PATCH 11/11] Run integration tests with various git versions We pick a few interesting ones in the range of supported versions. Based on work by Ryooooooga . --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffa788d99..9326ca103 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,13 +47,47 @@ jobs: run: | go test ./... -short integration-tests: + strategy: + fail-fast: false + matrix: + git-version: + - 2.20.0 # oldest supported version + - 2.22.5 + - 2.23.0 + - 2.25.1 + - 2.30.8 + - latest # We rely on github to have the latest version installed on their VMs runs-on: ubuntu-latest - name: "Integration Tests" + name: "Integration Tests - git ${{matrix.git-version}}" env: GOFLAGS: -mod=vendor steps: - name: Checkout code uses: actions/checkout@v3 + - name: Restore Git cache + if: matrix.git-version != 'latest' + id: cache-git-restore + uses: actions/cache/restore@v3 + with: + path: ~/git-${{matrix.git-version}} + key: ${{runner.os}}-git-${{matrix.git-version}} + - name: Build Git ${{matrix.git-version}} + if: steps.cache-git-restore.outputs.cache-hit != 'true' && matrix.git-version != 'latest' + run: > + sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential ca-certificates curl gettext libexpat1-dev libssl-dev libz-dev openssl + && curl -sL "https://mirrors.edge.kernel.org/pub/software/scm/git/git-${{matrix.git-version}}.tar.xz" -o - | tar xJ -C "$HOME" + && cd "$HOME/git-${{matrix.git-version}}" + && ./configure + && make -j + - name: Install Git ${{matrix.git-version}} + if: matrix.git-version != 'latest' + run: sudo make -C "$HOME/git-${{matrix.git-version}}" -j install + - name: Save Git cache + if: steps.cache-git-restore.outputs.cache-hit != 'true' && matrix.git-version != 'latest' + uses: actions/cache/save@v3 + with: + path: ~/git-${{matrix.git-version}} + key: ${{runner.os}}-git-${{matrix.git-version}} - name: Setup Go uses: actions/setup-go@v1 with: @@ -67,9 +101,11 @@ jobs: key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test restore-keys: | ${{runner.os}}-go- + - name: Print git version + run: git --version - name: Test code run: | - go test pkg/integration/clients/*.go + ./scripts/run_integration_tests.sh build: runs-on: ubuntu-latest env: