Skip to content
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

add: opt in color log output #276

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ workflow [`step-summary`][step-summary], and Pull Request reviews (with

Create a new GitHub Actions workflow in your project, e.g. at [.github/workflows/cpp-linter.yml](https://github.com/cpp-linter/cpp-linter-action/blob/main/.github/workflows/cpp-linter.yml)

> [!TIP]
> To enable color output in the workflow logs,
> set the environment variable `CPP_LINTER_COLOR` to a
> value of `on`, `true`, or `1`.

The content of the file should be in the following format.

```yaml
Expand All @@ -56,6 +61,7 @@ The content of the file should be in the following format.
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CPP_LINTER_COLOR: on # off by default
with:
style: 'file' # Use .clang-format config file
tidy-checks: '' # Use .clang-tidy config file
Expand Down
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ runs:
pip install -r "$GITHUB_ACTION_PATH/requirements.txt"
clang-tools -i ${{ inputs.version }} -b

# Install color output requirements if enabled
case "$CPP_LINTER_COLOR" in
"true" | "on" | "1")
pip install -r "$GITHUB_ACTION_PATH/color-requirements.txt"
echo "FORCE_COLOR=1" >> $GITHUB_ENV
;;
esac

- name: Run cpp-linter (Unix)
id: cpp-linter-unix
if: runner.os == 'Linux' || runner.os == 'macOS'
Expand Down Expand Up @@ -309,6 +317,14 @@ runs:
pip install -r "$env:GITHUB_ACTION_PATH/requirements.txt"
clang-tools -i ${{ inputs.version }} -b

# Install color output requirements if enabled
$colorEnabled = "true","on","1"
if ( $colorEnabled.contains("$env:CPP_LINTER_COLOR") )
{
pip install -r "$env:GITHUB_ACTION_PATH/color-requirements.txt"
echo "FORCE_COLOR=1" >> $env.GITHUB_ENV
}

- name: Run cpp-linter (Windows)
id: cpp-linter-windows
if: runner.os == 'Windows'
Expand Down
1 change: 1 addition & 0 deletions color-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rich==13.9.2
Loading