Closed zjp-CN closed 11 months ago
--color always
CI demo: https://github.com/zjp-CN/torrust-tracker/actions/runs/6315151297/job/17147036800
Hi @zjp-CN, It's nice to have the feature to enable/disable color. I'll have to use the colourless version when I show the report in the markdown summary:
I'll have to use the colourless version when I show the report in the markdown summary:
You've set CARGO_TERM_COLOR: always
, so the summary is in color. In your case, you can override the env by --color never
:
-cargo pretty-test --lib --bins >> $GITHUB_STEP_SUMMARY
+cargo pretty-test --lib --bins --color=never >> $GITHUB_STEP_SUMMARY
The indent in the summary is parsed as gfm (markdown). I guess to keep raw text, you could do this (not tested)
echo -n "<pre>" >> $GITHUB_STEP_SUMMARY
echo -n "$(cargo pretty-test --color=never)" >> $GITHUB_STEP_SUMMARY
echo -n "</pre>" >> $GITHUB_STEP_SUMMARY
The indent in the summary is parsed as gfm (markdown). I guess to keep raw text, you could do this (not tested)
echo -n "<pre>" >> $GITHUB_STEP_SUMMARY echo -n "$(cargo pretty-test --color=never)" >> $GITHUB_STEP_SUMMARY echo -n "</pre>" >> $GITHUB_STEP_SUMMARY
It seems the output is pretty similar (with "pre" and "backticks"):
So that's to say the <pre>
trick doesn't work here?
So that's to say the
\<pre\>
trick doesn't work here?
It works but produces almost the same output as backticks. You can see here:
Generated by cargo-pretty-test └── (OK) torrust_tracker ... (265 tests in 0.56s: ✅ 265) └── (OK) src/lib.rs ... (265 tests in 0.56s: ✅ 265) ├── bootstrap │ └── config │ └── tests │ └─ ✅ it_should_load_with_default_config ├── servers │ ├── apis │ │ ├── server │ │ │ └── tests │ │ │ └─ ✅ it_should_be_able_to_start_from_stopped_state_and_then_stop_again │ │ └── v1 │ │ └── context │ │ ├── auth_key │ │ │ └── resources │ │ │ └── tests │ │ │ ├─ ✅ it_should_be_convertible_from_an_auth_key │ │ │ ├─ ✅ it_should_be_convertible_into_an_auth_key │ │ │ └─ ✅ it_should_be_convertible_into_json
Generated by cargo-pretty-test
└── (OK) torrust_tracker ... (265 tests in 0.56s: ✅ 265)
└── (OK) src/lib.rs ... (265 tests in 0.56s: ✅ 265)
├── bootstrap
│ └── config
│ └── tests
│ └─ ✅ it_should_load_with_default_config
├── servers
│ ├── apis
│ │ ├── server
│ │ │ └── tests
│ │ │ └─ ✅ it_should_be_able_to_start_from_stopped_state_and_then_stop_again
│ │ └── v1
│ │ └── context
│ │ ├── auth_key
│ │ │ └── resources
│ │ │ └── tests
│ │ │ ├─ ✅ it_should_be_convertible_from_an_auth_key
│ │ │ ├─ ✅ it_should_be_convertible_into_an_auth_key
│ │ │ └─ ✅ it_should_be_convertible_into_json
Accepts one of always,never,auto. And support environment variable
CARGO_TERM_COLOR
from cargoe.g.
--color=never
--color never
CARGO_TERM_COLOR=never