diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml new file mode 100644 index 0000000..b48dd9e --- /dev/null +++ b/.github/workflows/api.yaml @@ -0,0 +1,24 @@ +name: api + +on: + pull_request: + +jobs: + mage: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22 + - + name: Run Mage + uses: magefile/mage-action@v3 + with: + version: latest + workdir: api + args: -v test diff --git a/.github/workflows/git.yaml b/.github/workflows/git.yaml new file mode 100644 index 0000000..5a69884 --- /dev/null +++ b/.github/workflows/git.yaml @@ -0,0 +1,24 @@ +name: git + +on: + pull_request: + +jobs: + mage: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22 + - + name: Run Mage + uses: magefile/mage-action@v3 + with: + version: latest + workdir: git + args: -v build test diff --git a/.github/workflows/tmux-vcs-sync.yaml b/.github/workflows/tmux-vcs-sync.yaml new file mode 100644 index 0000000..8ff4f88 --- /dev/null +++ b/.github/workflows/tmux-vcs-sync.yaml @@ -0,0 +1,23 @@ +name: tmux-vcs-sync + +on: + pull_request: + +jobs: + mage: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22 + - + name: Run Mage + uses: magefile/mage-action@v3 + with: + version: latest + args: -v build test diff --git a/api/magefiles/magefile.go b/api/magefiles/magefile.go new file mode 100644 index 0000000..4c1736b --- /dev/null +++ b/api/magefiles/magefile.go @@ -0,0 +1,14 @@ +//go:build mage +// +build mage + +package main + +import ( + "github.com/magefile/mage/sh" +) + +var Default = Test + +func Test() error { + return sh.Run("go", "test", "./...") +} diff --git a/git/go.mod b/git/go.mod index d5c8632..94dadd5 100644 --- a/git/go.mod +++ b/git/go.mod @@ -2,7 +2,7 @@ module github.com/JeffFaer/tmux-vcs-sync/git go 1.22.0 -require github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e +require github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e require ( github.com/adrg/xdg v0.4.0 // indirect diff --git a/git/go.sum b/git/go.sum index 053fc90..16ed135 100644 --- a/git/go.sum +++ b/git/go.sum @@ -1,5 +1,5 @@ -github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e h1:4JLG9FSywRxaUi8c1wuefaYONpeuYM/IpKLH2S3EbEc= -github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e/go.mod h1:jN9qfsBwxfLdhUbwSIFbM+izWRtPz0kbYyf3/197PH8= +github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e h1:62QDhCvRRyGUb8AM1jMzprNomC4RZU3cEjMvLaWzXRw= +github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e/go.mod h1:jN9qfsBwxfLdhUbwSIFbM+izWRtPz0kbYyf3/197PH8= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= diff --git a/go.mod b/go.mod index c6e1119..e9264f4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/JeffFaer/tmux-vcs-sync go 1.22.0 require ( - github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e + github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e github.com/adrg/xdg v0.4.0 github.com/avast/retry-go/v4 v4.5.1 github.com/creack/pty v1.1.21 diff --git a/go.sum b/go.sum index 003f17e..419b5fe 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e h1:4JLG9FSywRxaUi8c1wuefaYONpeuYM/IpKLH2S3EbEc= -github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213043525-82bc554b024e/go.mod h1:jN9qfsBwxfLdhUbwSIFbM+izWRtPz0kbYyf3/197PH8= +github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e h1:62QDhCvRRyGUb8AM1jMzprNomC4RZU3cEjMvLaWzXRw= +github.com/JeffFaer/tmux-vcs-sync/api v0.0.0-20240213050937-27e0ee44149e/go.mod h1:jN9qfsBwxfLdhUbwSIFbM+izWRtPz0kbYyf3/197PH8= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o= diff --git a/tmux/tmux_test.go b/tmux/tmux_test.go index 98ed2de..ee38a82 100644 --- a/tmux/tmux_test.go +++ b/tmux/tmux_test.go @@ -151,6 +151,9 @@ func RunInTTY(t *testing.T, cmd *exec.Command) *os.File { cmd.Stdin = tty cmd.Stdout = tty cmd.Stderr = tty + // tmux needs TERM to be set, and it isn't inherited from the parent process + // in GitHub Actions. + cmd.Env = append(cmd.Environ(), "TERM=xterm-256color") t.Logf("Running command in tty %s: %v", tty.Name(), cmd) if err := cmd.Start(); err != nil { @@ -158,7 +161,7 @@ func RunInTTY(t *testing.T, cmd *exec.Command) *os.File { } t.Cleanup(func() { if err := cmd.Process.Kill(); err != nil { - t.Logf("Could not kill process %v", cmd.Process) + t.Logf("Could not kill process %d: %v", cmd.Process.Pid, err) } }) return pty @@ -213,9 +216,8 @@ func TestServer_AttachOrSwitch(t *testing.T) { return nil }, retry.Delay(10*time.Millisecond), retry.Context(ctx)) if err != nil { - t.Error(err) + t.Fatal(err) } - if id := client.MustProperties(ClientProperty(SessionID))[ClientProperty(SessionID)]; id != a.ID { t.Errorf("Client is connected to %q, expected %q", id, a.ID) }