diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 843b2cac..fb5fad23 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -27,6 +27,14 @@ jobs: with: path-to-profile: coverage-all.out + - name: Cross-compile for all release targets + run: | + GOOS=linux GOARCH=amd64 go build ./... + GOOS=darwin GOARCH=amd64 go build ./... + GOOS=darwin GOARCH=arm64 go build ./... + GOOS=windows GOARCH=amd64 go build ./... + GOOS=windows GOARCH=arm64 go build ./... + - name: Build the TTPForge Binary run: | go build -o ttpforge diff --git a/pkg/blocks/expectstep.go b/pkg/blocks/expectstep.go index a66bf55f..0e943535 100644 --- a/pkg/blocks/expectstep.go +++ b/pkg/blocks/expectstep.go @@ -214,7 +214,8 @@ func (s *ExpectStep) Execute(execCtx TTPExecutionContext) (*ActResult, error) { if s.TerminalWidth > 0 { termWidth = s.TerminalWidth } - if err := pty.Setsize(console.Tty(), &pty.Winsize{Rows: 24, Cols: uint16(termWidth)}); err != nil { + ws := newWinsize(24, termWidth) + if err := pty.Setsize(console.Tty(), &ws); err != nil { logging.L().Warnf("failed to set terminal width: %v", err) } diff --git a/pkg/blocks/winsize_unix.go b/pkg/blocks/winsize_unix.go new file mode 100644 index 00000000..29845862 --- /dev/null +++ b/pkg/blocks/winsize_unix.go @@ -0,0 +1,28 @@ +//go:build unix + +/* +Copyright © 2024-present, Meta Platforms, Inc. and affiliates +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +package blocks + +import "github.com/creack/pty" + +func newWinsize(rows, cols int) pty.Winsize { + return pty.Winsize{Rows: uint16(rows), Cols: uint16(cols)} +} diff --git a/pkg/blocks/winsize_windows.go b/pkg/blocks/winsize_windows.go new file mode 100644 index 00000000..cdafc05b --- /dev/null +++ b/pkg/blocks/winsize_windows.go @@ -0,0 +1,28 @@ +//go:build windows + +/* +Copyright © 2024-present, Meta Platforms, Inc. and affiliates +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +package blocks + +import "github.com/creack/pty" + +func newWinsize(rows, cols int) pty.Winsize { + return pty.Winsize{Rows: uint(rows), Cols: uint(cols)} +}