Skip to content

Commit

Permalink
add: opt in color log output
Browse files Browse the repository at this point in the history
resolves #275
  • Loading branch information
2bndy5 committed Oct 18, 2024
1 parent fc3e8f8 commit 5f14ac8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ 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` or `true` or `1`.
The content of the file should be in the following format.

```yaml
Expand All @@ -56,6 +59,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
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ runs:
source "$GITHUB_ACTION_PATH/venv/bin/activate"
pip install -r "$GITHUB_ACTION_PATH/requirements.txt"
clang-tools -i ${{ inputs.version }} -b
case "${{ env.CPP_LINTER_COLOR }}" in
"true" | "on" | "1")
pip install -r "$GITHUB_ACTION_PATH/color-requirements.txt"
;;
esac
- name: Run cpp-linter (Unix)
id: cpp-linter-unix
Expand Down Expand Up @@ -308,6 +313,11 @@ runs:
Invoke-Expression -Command "$env:GITHUB_ACTION_PATH/venv/Scripts/Activate.ps1"
pip install -r "$env:GITHUB_ACTION_PATH/requirements.txt"
clang-tools -i ${{ inputs.version }} -b
$colorEnabled = "true","on","1"
if ( $colorEnabled.contains("${{ env.CPP_LINTER_COLOR }}") )
{
pip install -r "$GITHUB_ACTION_PATH/color-requirements.txt"
}
- name: Run cpp-linter (Windows)
id: cpp-linter-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

0 comments on commit 5f14ac8

Please sign in to comment.