Avoid GitHub action buffering

I have a Github repo that contains some Linux utilites.

To run test I use GitHub actions and some simple custom workflow that runs on a remote Linux server using self-hosted runner:

name: CMake
on: [push]
  BUILD_TYPE: Release
    runs-on: self-hosted
    - uses: actions/checkout@v2
    - name: Build
      working-directory: ${{runner.workspace}}/Utils
      shell: bash
      run: cmake --build . --config $BUILD_TYPE

    - name: Run test
      working-directory: ${{runner.workspace}}/Utils
      shell: bash
      run: ./testing/test.sh

The workflow is very simple - I compile the source using cmake and then run a script from the same repo to test the build. The test script is a bash script and looks as following:


export LD_LIBRARY_PATH=/path/to/bin

cd /path/to/bin

echo -e "Starting the tests"

./run_server &

if [ $? -eq 0 ]; then
    echo "successful"
    echo "failed"
    exit 1

Here the scripts starts up an compiled application from my code (run_server) and then run the testing utility that communicates with it and prints a result.

Actually I use C printf() inside run_tests to print the output strings. If I run that on a local machine I get output like the following:

Starting the tests
test1 executed Ok
test2 executed Ok
test3 executed Ok

Each test takes about 1 sec. so I the application prints a line like testX executed Ok one per second.

But if it runs using Github actions the output looks a bit different (copied from the Github actions console):

  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
    BUILD_TYPE: Release
Starting the tests   

And even in this case the output from the bash script printed out only after the script has finished. So I have 2 problems:

  • no printf() output from the test application
  • the script output (printed using echo ) come only after the script has finished

I expected the same behavior from the Github action as I get on a local machine i.e. I see a lines printed ~ 1/sec. immediately.

It looks like Github action buffers all the output until a step executed and ignores all the print from the application that run inside the bash script.

Is there a way to get all the output in real time while a step executes?


I tested on the GitHub-hosted runners, and the output of printf() in the C file can be displayed normally in the logs of the step.

You can try to upgrade or install Git and GCC with the latest version on your Linux machine, then try the workflow again to see if the problem still exists.

Ok, I see that your workflow is almost the same as mine. For some reason I see no output from the application. I see output from the bash echo but not from the C printf. Currently I’ve found the following workaround:
in the bash:

./run_tests > test_result

in the workflow:

- name: Get result
      working-directory: ${{runner.workspace}}/Utils
      id: results
      if: ${{ failure() }}
      run: echo ::set-output name=result::$(cat ./test_result)

    - name: Test output
      run: echo "${{ steps.results.outputs.result }}"

It prints the application’s output but only after the step has finished. I want to see the output in the realtime but as I understand currently it’s impossible. And for some reason I see the output as one line. replacing \n with \r\n takes no effect.


Which version of the GCC are you using in your Linux machine?
As I suggested above, please try to install the GCC with the latest version on your machine to see if the problems can be solved.

The problems may be caused by the older version of GCC (may also include the Git Bash version).