Streaming the log output from Ruby processes

I’m migrating a series of Ruby on Rails applications across to use GitHub Actions instead of Codeship.

This has been pretty easy, but I’m struggling to understand how I can get the output from my RSpec and Capistrano processes to be shown immediately in the log output; the logs are only available once the processes have completed, which is far from ideal.

I’ve tried adding STDOUT.sync = true to my RSpec spec_helper.rb file, but that hasn’t helped; I haven’t tried adding the same to Capistrano yet.

Has anyone got any advice on how to solve this? I’m sure it’s something obvious. I have the same problem with my PHP applications running PHPUnit.

I should note that this works fine under Codeship without having to add any special code, so it’s probably something GitHub Actions does differently.

Hi @stevehill1981,

Glad to see you in Github Community Forum!

What if you use $stdout.flush to send the output to $stdout? ‘STDOUT.sync = true’ should autoflush but let’s check with flush firstly.

If possible please share your repo/sample repo for further investigation.

Thanks

Hi! Sorry it took me a while to sort this; the project I was working on was a client project which I can’t share, so I made a sample: https://github.com/stevehill1981/test-app

There are fewer tests here, but it still exhibits the same basic problem.

Github actions would show the logs as long as the tool outputs something to stdout.
What happens if you run the tool (rspec/capistrano) locally? Do they spit some output as things progress or only after it’s done it’s process?
If you run locally and see output, but don’t see anything on actions let us know.
Actions should simulate what you see on your local commandline/dev flow.

Locally I get output continually as the tool runs - a . every time a test passes, or an F when one fails.

This works correctly on Codeship, but I assume they’re doing something different around how output is buffered.

So I tried enabling rails logging

It worked for me (just the rails logging)

If rspec is also outputting to stdout, it should have worked… not sure why it isn’t?

Ok, just learnt that rspec streaming is in basically in “characters”.
Github actions supports streaming lines but not characters…
So if there is any customer rspec logger that could spit out in lines, that would have worked.
If you would like to get fast feedback, please add --fast option for rspec so that it quits as soon as something fails.

Thanks for reporting this, we acknowledge the gap in streaming with github actions, we will consider this as a feature request.