-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
Though github actions typically don't have a colored output by default (see #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:
- Run the action below.
- Examine the output.
-
Note that
Hello Worldproduced bypython -c "print('\033[33mHello, \nworld!\033[0m')"have only the first line colored.
Same forCMake Warning at CMakeLists.txt:3 (message): A colored warning message from CMake. -
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 �[33mHello,
2025-12-19T06:26:02.6569492Z world!�[0m
2025-12-19T06:26:03.1327967Z �[33mCMake 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 �[0m
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