Skip to content

Commit

Permalink
chore(script): fix no tty err for bubbletea in gh-actions (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Feb 12, 2024
1 parent df3b51f commit 8607bef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- name: Set terminal environment
run: export TERM=xterm

- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

Expand Down
36 changes: 30 additions & 6 deletions src/app/proxy/pixa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxy_test

import (
"fmt"
"os"
"path/filepath"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -18,6 +19,15 @@ import (
"github.com/snivilised/pixa/src/internal/matchers"
)

func openInputTTY() (*os.File, error) {
f, err := os.Open("/dev/tty")
if err != nil {
return nil, fmt.Errorf("could not open a new TTY: %w", err)
}

return f, nil
}

const (
BackyardWorldsPlanet9Scan01 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-01"
BackyardWorldsPlanet9Scan02 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-02"
Expand Down Expand Up @@ -98,17 +108,28 @@ func assertInFs(entry *samplerTE, bs *command.Bootstrap, directory string) {

var _ = Describe("pixa", Ordered, func() {
var (
repo string
l10nPath string
configPath string
root string
vfs storage.VirtualFS
repo string
l10nPath string
configPath string
root string
vfs storage.VirtualFS
withoutRenderer bool
)

BeforeAll(func() {
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
configPath = helpers.Path(repo, "test/data/configuration")

var (
err error
f *os.File
)

if f, err = openInputTTY(); err != nil {
withoutRenderer = true
}
f.Close()
})

BeforeEach(func() {
Expand All @@ -130,12 +151,15 @@ var _ = Describe("pixa", Ordered, func() {
bootstrap := command.Bootstrap{
Vfs: vfs,
Presentation: common.PresentationOptions{
WithoutRenderer: true,
WithoutRenderer: withoutRenderer,
},
}

if !entry.isTui {
args = append(args, "--no-tui")
} else {
xterm := os.Getenv("XTERM")
fmt.Printf("===> ❤️‍🔥❤️‍🔥❤️‍🔥 XTERM: '%v'", xterm)

Check failure on line 162 in src/app/proxy/pixa_test.go

View workflow job for this annotation

GitHub Actions / lint

ST1018: string literal contains Unicode format characters, consider using escape sequences instead (stylecheck)
}

tester := helpers.CommandTester{
Expand Down

0 comments on commit 8607bef

Please sign in to comment.