diff --git a/README.md b/README.md index 8b608b8..c0a71bf 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/action.yml b/action.yml index a676f41..a329809 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -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' diff --git a/color-requirements.txt b/color-requirements.txt new file mode 100644 index 0000000..3bdf75a --- /dev/null +++ b/color-requirements.txt @@ -0,0 +1 @@ +rich==13.9.2