Tonkpils / snag

Automatic build tool for all your projects
MIT License
32 stars 4 forks source link

Problems executing shell scripts #40

Closed robertoandrade closed 8 years ago

robertoandrade commented 9 years ago

I'm having issues trying to execute shell scripts as a consequence of the build, it seems not to be able to find the scripts either if I execute them directly or via a shell:

script:
  - ./build.sh
  - ./deploy.sh
ignore:
  - .git
  - .snag.yml
verbose: true

or

script:
  - bash -c build.sh
  - bash -c deploy.sh
ignore:
  - .git
  - .snag.yml
verbose: true

don't work.

When I try by appending ./ as a prefix to the script name it seems to work but no output of the script is shown and I end up getting an error after a bit:

|In Progress| bash -c ./build.sh|In Progress| bash -c ./build.sh
|Failed     | bash -c ./build.sh
open /dev/null: too many open files
robertoandrade commented 9 years ago

Ok, I was able to workaround it like I mentioned in the description by appending ./ to the path of the script and had to add a folder to the ignore list that my script was modifying contents for. I guess this goes back to the known issue described in the README?

Additionally, is there a way to see the output of the shell script as it builds it instead of only after it's done executing? i.e.: one of my scripts executes: docker logs -f container

zabawaba99 commented 9 years ago

Ok, I was able to workaround it like I mentioned in the description by appending ./ to the path of the script and had to add a folder to the ignore list that my script was modifying contents for

This sounds like the endless loop caveat listed on the readme. If your script is modifying something in the path that snag is watching then it will trigger a rebuild and loop.

When I try by appending ./ as a prefix to the script name it seems to work but no output of the script is shown and I end up getting an error after a bit:

|In Progress| bash -c ./build.sh|In Progress| bash -c ./build.sh
|Failed     | bash -c ./build.sh
open /dev/null: too many open files

I've reproduced this a few times on OSX when using snag on a directly that has a large number of files. If you look at the known issues there's a link to bump up the number of files that your shell can have open to support projects with a lot of files.


Unfortunately, there is no way to see the progress of a command. We started off with an implementation that had streaming support but it ended up with some odd behavior at the time and decided to leave it on the back burner. @Tonkpils any thoughts on have a way to streaming command output?

zabawaba99 commented 9 years ago

Do you get the same error if you try and run a simple shell script like:

#!/bin/bash -ex

echo "Hello World

?

Tonkpils commented 9 years ago

Stream support would actually be very useful, however I do remember the issues we ran into when attempting to re-start the build. The process itself would keep writing to stdout. It might e good to re-visit this and attempt to find a fix for it. As for the shell script, I'll look into what might be the issue unless you get to it first @zabawaba99

zabawaba99 commented 9 years ago

Let's move the discussion of stream support over to https://github.com/Tonkpils/snag/issues/41.

As far as the shell scripting, have at it. I won't be able to get to it for a while.

zabawaba99 commented 9 years ago

@robertoandrade So what this issues related more to not being able to see the output of the script while it's running?

I ran the binary against this project and got a successful build. screen shot 2015-09-09 at 10 05 48 am

robertoandrade commented 8 years ago

It looks like it only works if you have the shebangs shenanigans on the shell script, otherwise it throws out an error:

|Failed     | ./deploy.sh
fork/exec ./deploy.sh: exec format error
zabawaba99 commented 8 years ago

I think I would consider more of a caveat than a bug itself. If you don't specify the shebang on a script then it would be the user's responsibility to make sure the file is being fed into the shell of choice.

script:
  - bash deploy.sh
Tonkpils commented 8 years ago

Let's go ahead and write a caveat section to mention these.