feat(ci-list): display running pipelines in blue, use light/dark 24-bit colors when able

Description

glab, when running ci list command, only distinguishes pipelines in the success and failed states by using green and red, respectively. Everything else is displayed in uniform gray.

I find this to be slightly unhelpful, since in the web UI, color gray is used for pipelines & jobs that didn't run - either yet (e.g. waiting for manual action), or because they were cancelled. It's especially jarring for running pipelines, because:

  1. they typically appear on top of ci list, and I expect to see them displayed prominently, not in "background gray",
  2. web UI uses distinctive blue for them,
  3. blue is very commonly used for "in progress" items; I don't have an exact Nielsen link, but I think it's pretty widely accepted 😄

So, as a tiny QoL improvement, I added a third color, blue, to DisplayMultiplePipelines.

I was tempted to also color created and pending, but I hesitated; my instincts (and experience with various applications currently available) tells me a lighter color (cyan, or at worst white) would be good here. However, GitLab's web UI uses gray for created (same as cancelled 😅 ), and yellow for pending...which feels very "warning" (and indeed is also used for pipelines in "warning" state, due to jobs that failed, but were allowed to). So I find it difficult to be consistent with both widespread usage and GitLab's web UI here. Skipping for now, unless advised to make a judgement call ;)

Update

Discussion in the issue led to adding a few more commits for a thematically-related change - support for light/dark color variants in 24-bit terminals, depending on detected luminance of background. @phikai noted that blue text on (default) black background has low contrast, and proposed this as a solution - together with mostly-implemented code ;)

Implements #8236 (closed) and inspired #8239

How has this been tested?

I found DisplayMultiplePipelines to be lacking in test coverage - it was integration-tested a bit higher, in internal/commands/ci/list TestCiList, but that didn't cover the scenarios I was interested in.

I don't really have experience with Golang (I'm a Ruby developer mainly), so I asked Duo to generate them. That went poorly :D - mostly because the proposed tests didn't match implementation in some critical aspects, and all failed. Erased that and wrote a few tests based on prevalent style.

Temporarily added a commit breaking DisplayMultiplePipelines to demonstrate new tests going from red to green.

Update for testing

Similarly, the 24-bit color support was TDD'd. There's at least one pipeline failing unit tests (and linting, due to unused parameter for dark variant).

Screenshots (if appropriate):

image

Edited by Emil Chludziński

Merge request reports

Loading