Skip to content

Commit c153d96

Browse files
committed
add: opt in color log output
resolves #275
1 parent b533471 commit c153d96

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ workflow [`step-summary`][step-summary], and Pull Request reviews (with
3737

3838
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)
3939

40+
> [!TIP]
41+
> To enable color output in the workflow logs,
42+
> set the environment variable `CPP_LINTER_COLOR` to a
43+
> value of `on`, `true`, or `1`.
44+
4045
The content of the file should be in the following format.
4146

4247
```yaml
@@ -46,6 +51,7 @@ The content of the file should be in the following format.
4651
id: linter
4752
env:
4853
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
CPP_LINTER_COLOR: on # off by default
4955
with:
5056
style: 'file' # Use .clang-format config file
5157
tidy-checks: '' # Use .clang-tidy config file

action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,20 @@ runs:
367367
or ($gh_action_debug == true)
368368
or ($gh_action_debug == 'true')
369369
)
370+
let color_enabled = (
371+
$env
372+
| get --optional 'CPP_LINTER_COLOR'
373+
| ($in == true or $in == 'true' or $in == 1 or $in == '1' or $in == 'on')
374+
)
370375
371376
print $"\n(ansi purple)Installing workflow dependencies(ansi reset)"
372377
mut uv_args = [sync --project $action_path --group action --no-dev --link-mode=copy]
373378
if $verbosity {
374379
$uv_args = $uv_args | append '-v'
375380
}
381+
if $color_enabled {
382+
$uv_args = $uv_args | append [--extra color]
383+
}
376384
^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args
377385
378386
print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)"
@@ -437,5 +445,14 @@ runs:
437445
$env.PATH = $env.PATH | append $local_bin
438446
}
439447
448+
let color_enabled = (
449+
$env
450+
| get --optional 'CPP_LINTER_COLOR'
451+
| ($in == true or $in == 'true' or $in == 1 or $in == '1' or $in == 'on')
452+
)
453+
if $color_enabled {
454+
$env.FORCE_COLOR = 1
455+
}
456+
440457
print $"\n(ansi purple)Running cpp-linter(ansi reset)"
441458
^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args cpp-linter ...$args

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ version = "0.0.0+private_virtual"
44
requires-python = ">=3.9"
55
dependencies = []
66

7+
[project.optional-dependencies]
8+
color = [
9+
"rich==14.1.0"
10+
]
11+
712
[dependency-groups]
813
action = [
914
"clang-tools==0.15.2",

uv.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)