Skip to content

Commit

Permalink
chore: Add GitHub workflows to exercise mage. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFaer committed Feb 13, 2024
1 parent 27e0ee4 commit d716d83
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 9 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/workflows/git.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/workflows/tmux-vcs-sync.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions api/magefiles/magefile.go
Original file line number Diff line number Diff line change
@@ -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", "./...")
}
2 changes: 1 addition & 1 deletion git/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions git/go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
8 changes: 5 additions & 3 deletions tmux/tmux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ 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 {
t.Fatalf("Could not start command: %v", err)
}
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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit d716d83

Please sign in to comment.