Skip to content

Fix Jekyll exit status for Travis #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2016
Merged

Conversation

ashawley
Copy link
Member

@ashawley ashawley commented Nov 16, 2016

Grep the output of Jekyll for errors since it returns zero exits with
YAML errors. See jekyll/jekyll#5257.

- bundle exec jekyll build
- bundle exec jekyll build 2> error.log
- cat >&2 error.log
- grep -qie Error error.log && false || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should I read this line? Just from reading it it seems like:

true && false || true ==
(true && false) || true ==
false || true ==
true

and

false && false || true ==
(false && false) || true ==
false || true ==
true

So either way it will return true.
I fully admit I maybe missing something here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. (http://stackoverflow.com/questions/17203122/bash-if-else-statement-in-one-line#comment33428887_17203203)

I recommend instead using:

[ "$(grep -cie Error error.log)" -eq 0 ]

@ashawley
Copy link
Member Author

Agreed, it might not be obvious right away what this means in shell:

grep -qie Error error.log && false || true

This would be the simplest thing:

! grep -qie Error error.log

Less cryptic than the previous?

I assume putting a bang there is supported by Travis, but I didn't check

@jarrodu
Copy link
Member

jarrodu commented Nov 17, 2016

It is not really about being cryptic. It is about having the intended behavior. I don't think the two code snips do the same thing. I suspect that your second version will work.

Are you interested in testing it out and updating the PR? You could play around with Travis on your fork and then when it all works you could push the changes into this PR.

Thanks for your work on this. :-)

@ashawley ashawley force-pushed the jekyll-zero-exit branch 3 times, most recently from 4133c05 to 5d24ebb Compare November 17, 2016 13:34
@ashawley
Copy link
Member Author

You're right. Thanks for catching this.

Looks like a bare exclamation point won't work, but I can use bang in parens:

( ! grep -qie Error error.log )

@ashawley
Copy link
Member Author

Introducing Seth's broken patch in 748c635 causes Travis to fail.

Grep the output of Jekyll for errors since it returns zero exits with
YAML errors.  See jekyll issue 5257.
@ashawley
Copy link
Member Author

The errors are produced by the cat command, so they show up out of order, but it works.

$ bundle exec jekyll build 2> error.log
Configuration file: /home/travis/build/scala/scala-lang/_config.yml
            Source: /home/travis/build/scala/scala-lang
       Destination: /home/travis/build/scala/scala-lang/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 12.212 seconds.
 Auto-regeneration: disabled. Use --watch to enable.
The command "bundle exec jekyll build 2> error.log" exited with 0.
$ cat >&2 error.log
Error reading file /home/travis/build/scala/scala-lang/download/index.md: (<unknown>): did not find expected ',' or ']' while parsing a flow sequence at line 7 column 17 
The command "cat >&2 error.log" exited with 0.
$ ( ! grep -qie Error error.log )
The command "( ! grep -qie Error error.log )" exited with 1.

@@ -16,4 +16,6 @@ install:
- bundle install

script:
- bundle exec jekyll build
- bundle exec jekyll build 2> error.log
- cat >&2 error.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what conditions will this line exit with a non-zero status?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I am getting at is I don't understand what the >&2 is for.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2> pipes stderr to error.log

The >&2 pipes stdout to stderr

I guess what I am getting at is I don't understand what the >&2 is for.

It makes the font of the error message "Yellow" in Travis?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay >&2 is starting to make more sense.

But why cat >&2 error.log instead of cat error.log >&2.

Thanks for your time. I know your job is not to spend all day educating me. ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no difference. Let me know if >&2 at the end is clearer.

Thank you for the careful review!

@jarrodu jarrodu merged commit b033461 into scala:master Nov 17, 2016
@SethTisue
Copy link
Member

wonderful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants