goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.6k stars 473 forks source link

Windows alpha support doesn't use native tools (cmd/powershell) to execute commands #632

Closed jsturtevant closed 4 years ago

jsturtevant commented 4 years ago

Describe the bug

Windows support doesn't use native tools to execute commands. The current windows support expects "sh" to be installed on the PATH. While on a developer machine these tools might be available via git tooling such as git for windows (which installs git bash and other binaries), on a system server these will likely not be available:

PS C:\projects\goss\goss-alpha-windows-amd64.exe --use-alpha=1 -g="integration-tests/goss/windows/tests/command.goss.yaml" validate                                                                                                          
2020/10/12 09:05:31 WARNING: goss for this platform ("Windows") is alpha-quality, work-in-progress, and not yet exercised within continuous integration.       

You should not expect everything to work. Treat linux as the canonical behaviour to expect.          

Please see https://github.com/aelsabbahy/goss/tree/master/docs/platform-feature-parity.md to set your expectations and see progress.                                                                                                           
Please file issues via https://github.com/aelsabbahy/goss/issues/new/choose                                            
Pull requests and bug reports very welcome.                                                                             
FF                       

Failures/Skipped:                                                                                                                                                                                                                    
hello world: exit-status: Error: exec: "sh": executable file not found in %PATH%
hello world: stdout: Error: exec: "sh": executable file not found in %PATH%  

How To Reproduce

  1. Open Powershell prompt on a Windows 10 or Windows Server that doesn't have git installed or any other similar tooling.
  2. curl.exe -LO https://github.com/aelsabbahy/goss/releases/download/v0.3.13/goss-alpha-windows-amd64.exe
  3. curl.exe -LO https://raw.githubusercontent.com/aelsabbahy/goss/master/integration-tests/goss/windows/tests/command.goss.yaml
  4. .\goss-alpha-windows-amd64.exe --use-alpha=1 -g="command.goss.yaml" validate

Expected Behavior

The command should pass and use cmd or powershell to execute the command with out any third party tooling required.

Actual Behavior

goss uses sh which is only installed via third party tooling such as git for windows.

Other info The tests are passing in CI because it looks like TravisCI adds these tools to the PATH which includessh binary:

export PATH="/c/Users/travis/gopath/bin:/c/Users/travis/.gimme/versions/go1.13.15.windows.amd64/bin:/c/Users/travis/bin:/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin"

Environment: