fix: support colour output in CI via FORCE_COLOR/CLICOLOR_FORCE - #622
Open
NickJosevski wants to merge 4 commits into
Open
fix: support colour output in CI via FORCE_COLOR/CLICOLOR_FORCE#622NickJosevski wants to merge 4 commits into
NickJosevski wants to merge 4 commits into
Conversation
Colour was gated solely on term.IsTerminal(stdout), which never resolves to true in a CI job, so CI systems that do render ANSI codes (GitHub Actions, GitLab CI) could never show coloured output. Honour the conventional CLICOLOR_FORCE and FORCE_COLOR opt-ins, keeping NO_COLOR as the highest-precedence override. Terminal detection remains the default so existing non-CI behaviour is unchanged, and CI output stays plain unless explicitly opted in. Fixes #506 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NickJosevski
marked this pull request as ready for review
August 4, 2026 07:48
YuKitsune
requested changes
Aug 5, 2026
YuKitsune
left a comment
Contributor
There was a problem hiding this comment.
I ran this locally and noticed the Octopus logo was still appearing in cyan. Taking a look at color.go, many of the functions there ignore the IsColorEnabled flag. Is this intentional?
Setting one of the force variables to 0 fell through to terminal detection, so `FORCE_COLOR=0 octopus --help` in a terminal still printed the cyan Octopus logo. Both bixense.com/clicolors and the de facto FORCE_COLOR convention treat 0 as an instruction to disable colour, so an explicitly set force variable now overrides terminal detection in both directions. CLICOLOR=0 is honoured for the same reason. Terminal detection is now injected into the decision function so the table can be tested with and without a TTY, and tests assert that every exported helper in color.go honours IsColorEnabled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I'm still testing this myself... |
Builds the CLI at main, at the PR as reviewed, and at the PR with the review fix, then prints `octopus --help` under a matrix of colour environment variables so the before/after can be seen in a real CI log. GitHub Actions renders ANSI colour but attaches no TTY, which is exactly the situation issue #506 describes. A second job re-runs the cases that only apply to a terminal under a pty allocated with `script`, covering the FORCE_COLOR=0 case raised in review. Both jobs assert the expected outcomes rather than only printing them. Demo only: runs on this branch and manual dispatch, and can be dropped before merge. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Colour was applied by wrapping a whole string in a single escape and a single reset. A terminal renders that correctly, but log viewers are less forgiving: GitHub Actions resets SGR state at every line break, so the 18-line Octopus logo carried one escape at the top and rendered entirely plain. Colour reached CI but could not be seen there, which is most of the point of #506. Wrap each line separately instead. Terminal output is unchanged, blank lines are left alone so they do not collect stray escapes, and the logo now renders in GitHub Actions and GitLab CI logs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@YuKitsune i's about colours being displayed on build agents/CI/etc, but then it became very obvious I shouldn't trust claude to verify how it looks. So yes found more issues, so got it to write Actions to prove it to me:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #506
Problem
Colour was gated solely on
term.IsTerminal(os.Stdout.Fd()), which never resolves to true inside a CI job. CI systems that do render ANSI codes — GitHub Actions, GitLab CI — could therefore never show coloured output.Change
pkg/output/color.gonow follows the conventions from no-color.org and bixense.com/clicolors:NO_COLORset to anything non-emptyCLICOLOR_FORCEorFORCE_COLORset to anything but0This is opt-in, so CI output stays plain unless asked for. Auto-enabling on a
CIenv var would inject escape codes into the logs of systems that don't render them, and would break anyone currently parsing CLI output in a pipeline.Verification
Unit tests cover the precedence matrix. Manually against a build:
README documents the variables under Getting Started.
🤖 Generated with Claude Code