diff --git a/README.md b/README.md index 385f9f4..889fe40 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,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 @@ -46,6 +51,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 diff --git a/action.yml b/action.yml index 667223d..d7d4ce0 100644 --- a/action.yml +++ b/action.yml @@ -367,12 +367,20 @@ runs: or ($gh_action_debug == true) or ($gh_action_debug == 'true') ) + let color_enabled = ( + $env + | get --optional 'CPP_LINTER_COLOR' + | ($in == true or $in == 'true' or $in == 1 or $in == '1' or $in == 'on') + ) print $"\n(ansi purple)Installing workflow dependencies(ansi reset)" mut uv_args = [sync --project $action_path --group action --no-dev --link-mode=copy] if $verbosity { $uv_args = $uv_args | append '-v' } + if $color_enabled { + $uv_args = $uv_args | append [--extra color] + } ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)" @@ -437,5 +445,14 @@ runs: $env.PATH = $env.PATH | append $local_bin } + let color_enabled = ( + $env + | get --optional 'CPP_LINTER_COLOR' + | ($in == true or $in == 'true' or $in == 1 or $in == '1' or $in == 'on') + ) + if $color_enabled { + $env.FORCE_COLOR = 1 + } + print $"\n(ansi purple)Running cpp-linter(ansi reset)" ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args cpp-linter ...$args diff --git a/pyproject.toml b/pyproject.toml index efcf4c8..2c85691 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,11 @@ version = "0.0.0+private_virtual" requires-python = ">=3.9" dependencies = [] +[project.optional-dependencies] +color = [ + "rich==14.1.0" +] + [dependency-groups] action = [ "clang-tools==0.15.2", diff --git a/uv.lock b/uv.lock index 92b784b..a74f172 100644 --- a/uv.lock +++ b/uv.lock @@ -266,6 +266,11 @@ name = "cpp-linter-action" version = "0.0.0+private.virtual" source = { virtual = "." } +[package.optional-dependencies] +color = [ + { name = "rich" }, +] + [package.dev-dependencies] action = [ { name = "clang-tools" }, @@ -286,6 +291,8 @@ docs = [ ] [package.metadata] +requires-dist = [{ name = "rich", marker = "extra == 'color'", specifier = "==14.1.0" }] +provides-extras = ["color"] [package.metadata.requires-dev] action = [ @@ -402,6 +409,36 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/62/fe/e7ccdd9e542afebf61e95f0a0ce0557c494e798d8ca39903a7f9bd83bdca/markdown_gfm_admonition-0.1.1-py3-none-any.whl", hash = "sha256:f6626287a34adf0cdc44f953086fcb9aaaf0cb698f01f3a36b46758c30f7d701", size = 8740, upload-time = "2024-08-01T10:42:40.035Z" }, ] +[[package]] +name = "markdown-it-py" +version = "3.0.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.10'", +] +dependencies = [ + { name = "mdurl", marker = "python_full_version < '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596, upload-time = "2023-06-03T06:41:14.443Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528, upload-time = "2023-06-03T06:41:11.019Z" }, +] + +[[package]] +name = "markdown-it-py" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.10'", +] +dependencies = [ + { name = "mdurl", marker = "python_full_version >= '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3", size = 73070, upload-time = "2025-08-11T12:57:52.854Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147", size = 87321, upload-time = "2025-08-11T12:57:51.923Z" }, +] + [[package]] name = "markupsafe" version = "3.0.2" @@ -470,6 +507,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b3/73/085399401383ce949f727afec55ec3abd76648d04b9f22e1c0e99cb4bec3/MarkupSafe-3.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a", size = 15506, upload-time = "2024-10-18T15:21:52.974Z" }, ] +[[package]] +name = "mdurl" +version = "0.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, +] + [[package]] name = "mergedeep" version = "1.3.4" @@ -910,6 +956,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7c/e4/56027c4a6b4ae70ca9de302488c5ca95ad4a39e190093d6c1a8ace08341b/requests-2.32.4-py3-none-any.whl", hash = "sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c", size = 64847, upload-time = "2025-06-09T16:43:05.728Z" }, ] +[[package]] +name = "rich" +version = "14.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py", version = "3.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "markdown-it-py", version = "4.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fe/75/af448d8e52bf1d8fa6a9d089ca6c07ff4453d86c65c145d0a300bb073b9b/rich-14.1.0.tar.gz", hash = "sha256:e497a48b844b0320d45007cdebfeaeed8db2a4f4bcf49f15e455cfc4af11eaa8", size = 224441, upload-time = "2025-07-25T07:32:58.125Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e3/30/3c4d035596d3cf444529e0b2953ad0466f6049528a879d27534700580395/rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f", size = 243368, upload-time = "2025-07-25T07:32:56.73Z" }, +] + [[package]] name = "ruff" version = "0.12.10"