Skip to content

Commit

Permalink
Fix wrapping issue on GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
ichard26 committed Dec 21, 2021
1 parent 184cd7d commit 1350578
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,18 @@ Black-primer eventually spawned the creation of [mypy-primer], a black-primer
equivalent for mypy. Many features present in diff-shades come from
black-primer and mypy-primer.

______________________________________________________________________

## Changelog

### 21.12a5

- When running on GitHub Actions, `--force-colors` and the width will be
forcefully set for you.

### 21.12a4

First public release, enjoy the alpha quality software :)

[black-primer]: https://github.com/psf/black/tree/main/src/black_primer
[mypy-primer]: https://github.com/hauntsaninja/mypy_primer/
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dynamic = ["version", "description"]
diff-shades = "diff_shades.cli:main"

[project.urls]
Home = "https://github.com/ichard26/diff-shades"
Repository = "https://github.com/ichard26/diff-shades"

[tool.flit.module]
name = "diff_shades"
Expand Down
7 changes: 6 additions & 1 deletion src/diff_shades/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ def main(
rich.traceback.install(suppress=[click], show_locals=show_locals)
color_mode_key = {True: None, None: "auto", False: "truecolor"}
color_mode = color_mode_key[no_color]
width: Optional[int] = None
if os.getenv("GITHUB_ACTIONS") == "true":
# Force colors when running on GitHub Actions.
color_mode = "truecolor"
# Annoyingly enough rich autodetects the width to be far too small on GHA.
width = 115
# fmt: off
theme = Theme({
"error": "bold red",
Expand All @@ -163,7 +166,9 @@ def main(
**RESULT_COLORS
})
# fmt: on
rich.reconfigure(log_path=False, record=dump_html, color_system=color_mode, theme=theme)
rich.reconfigure(
log_path=False, record=dump_html, color_system=color_mode, theme=theme, width=width
)
if clear_cache:
shutil.rmtree(diff_shades.results.CACHE_DIR)
diff_shades.results.CACHE_DIR.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 1350578

Please sign in to comment.