actions / actions/runner

colored output breaks if output sequence has a newline

Open
#4,165 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug
Though github actions typically don't have a colored output by default (see https://github.com/actions/runner/issues/750), it's still usually possible to set some environment variable/provide some flag to force program to output colored.

But the problem is, if output has newlines, then it seems to be splitted by them and then color codes have no effect - effectively they color only the first line.

To Reproduce
Steps to reproduce the behavior:

  1. Run the action below.
  2. Examine the output.
Image
  1. Note that Hello World produced by python -c "print('\033[33mHello, \nworld!\033[0m')" have only the first line colored.
    Same for CMake Warning at CMakeLists.txt:3 (message): A colored warning message from CMake.

  2. If we examine the logs, we can also note that message is splitted by different lines, which is probably what leads to this.

2025-12-19T06:26:02.6569047Z Hello, 
2025-12-19T06:26:02.6569492Z world!
2025-12-19T06:26:03.1327967Z CMake Warning at CMakeLists.txt:3 (message):
2025-12-19T06:26:03.1328514Z   A colored warning message from CMake
2025-12-19T06:26:03.1328916Z 
2025-12-19T06:26:03.1329067Z 

Expected behavior

Output to be properly colored.

Example action to run

Can be forked from https://github.com/Andrej730/cmake-color-test

All cmake related stuff is optional, it can be reproduced with just python -c "print('\033[33mHello, \nworld!\033[0m')".
Adding cmake for a reference of real-life application of this.

Attach .yml code below, in case repo will be removed in the future.

name: test-makefile-logs

on:
  workflow_dispatch:

jobs:
  test-makefile-logs:
    runs-on: ubuntu-24.04
    env:
      CLICOLOR_FORCE: "1"
      CMAKE_COLOR_DIAGNOSTICS: "ON"

    steps:
    - name: Checkout code
      uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8  # v5.0.0

    - uses: astral-sh/setup-uv@v7

    - name: Run cmake
      run: |
        env
        uv tool install cmake
        cmake --version
        python -c "print('\033[33mHello, \nworld!\033[0m')"
        echo "cmake_minimum_required(VERSION 3.21)" > CMakeLists.txt
        echo "project(test-package)" >> CMakeLists.txt
        echo "message(WARNING \"A colored warning message from CMake\")" >> CMakeLists.txt
        cmake .
        make -j VERBOSE=1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in a GitHub Actions workflow with the provided Python command and forced color settings. Trace how the runner splits command output into log lines and handles ANSI color sequences across newlines; done means multi-line output remains colored throughout, including the CMake warning example.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.