Skip to content

Commit 2d26285

Browse files
tend-agentclaude
andcommitted
fix(token-report): set CLICOLOR_FORCE=0 instead of stripping ANSI
PRQL/prql's .github/actions/tend-setup/action.yaml sets CLICOLOR_FORCE=1 via $GITHUB_ENV to force cargo/clippy colors. gh treats CLICOLOR_FORCE as higher priority than NO_COLOR, so NO_COLOR=1 alone didn't suppress colors in --json output. Setting CLICOLOR_FORCE=0 in the script overrides the inherited value and addresses the root cause directly — simpler and more transparent than the sed-based strip_ansi approach. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 6578b92 commit 2d26285

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

‎plugins/tend-ci-runner/scripts/token-report.sh‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
# Requires: gh, jq, GNU coreutils (date -d)
2121

2222
set -euo pipefail
23+
# Disable gh's colored JSON output. NO_COLOR=1 alone is insufficient when the
24+
# environment sets CLICOLOR_FORCE=1 (e.g. PRQL/prql's tend-setup action sets
25+
# it in $GITHUB_ENV to force cargo/clippy colors), because gh treats
26+
# CLICOLOR_FORCE as higher priority than NO_COLOR — resulting in ANSI codes
27+
# in --json output that break downstream jq parsing.
2328
export NO_COLOR=1
29+
export CLICOLOR_FORCE=0
2430

2531
HOURS=${1:-168}
2632
SINCE=$(date -u -d "$HOURS hours ago" +%Y-%m-%dT%H:%M:%SZ)
@@ -43,20 +49,11 @@ if [ ${#WORKFLOWS[@]} -eq 0 ]; then
4349
exit 0
4450
fi
4551

46-
# Strips ANSI color escape sequences. In some CI environments (observed on
47-
# PRQL/prql, gh 2.89.0) `gh run list --json` emits ANSI color codes even with
48-
# NO_COLOR=1/CLICOLOR=0/GH_FORCE_TTY="" set, breaking downstream jq parsing.
49-
# We strip defensively so the script is robust regardless of what the
50-
# environment does. The sed expression is a no-op when no codes are present.
51-
strip_ansi() {
52-
sed -E $'s/\x1b\\[[0-9;]*[A-Za-z]//g'
53-
}
54-
5552
# Collect all completed runs across workflows
5653
ALL_RUNS="[]"
5754
for wf in "${WORKFLOWS[@]}"; do
5855
runs=$(gh run list "${repo_args[@]}" --workflow "$wf" --created ">=$SINCE" --status completed \
59-
--json databaseId,conclusion,createdAt,name --limit 100 2>/dev/null | strip_ansi || echo "[]")
56+
--json databaseId,conclusion,createdAt,name --limit 100 2>/dev/null || echo "[]")
6057
ALL_RUNS=$(echo "$ALL_RUNS" "$runs" | jq -s 'add | unique_by(.databaseId)')
6158
done
6259

0 commit comments

Comments
 (0)