ci: install jq for the shell tests, and probe for it explicitly
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run

The claude_usage i3blocks tests failed on CI while passing locally.
archlinux:base-devel ships no jq, and claude_usage.sh parses its cache
with it, so the block degraded to its "no data" path and every
percentage assertion failed. That degradation is correct at runtime —
the bar should not break because a tool is missing — but it made a
missing dependency look like a logic bug.

Install jq alongside git and strace, and probe for it at the top of the
section so the failure names its own cause. The probe runs jq rather
than calling `command -v`: a jq that exists but cannot execute produces
exactly the same "no data" output as an absent one, and `command -v`
passes in that case — verified by stubbing a jq that exits 127.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YQLwdquDCNmWtvgi3Lk72J
This commit is contained in:
Krzysztof Rudnicki 2026-08-10 15:40:42 +02:00
parent 91061edc14
commit 590bc2004d
3 changed files with 50 additions and 2 deletions

View File

@ -60,9 +60,12 @@ jobs:
# ptrace. Without these the trace file is never produced.
options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined
steps:
# base-devel ships neither git (actions/checkout needs it) nor strace.
# base-devel ships none of these: git (actions/checkout needs it), strace
# (execve counting), or jq (the claude_usage block parses its cache with
# it, and without jq that block degrades to "no data" and its assertions
# fail).
- name: Install dependencies
run: pacman -Sy --noconfirm --needed git strace
run: pacman -Sy --noconfirm --needed git strace jq
- uses: actions/checkout@v4

View File

@ -0,0 +1,37 @@
{
"intent": "Make the claude_usage i3blocks tests pass on CI, where they failed because the Arch container had no jq.",
"scope": [
".github/workflows/shell-tests.yml (arch-tests container dependencies)",
"linux_configuration/tests/test_i3blocks_efficiency.sh (dependency probe)",
"Non-goal: changing claude_usage.sh runtime behaviour — degrading to 'no data' without jq is correct"
],
"changes": [
"Install jq in the arch-tests container. archlinux:base-devel ships neither git, strace nor jq; the first two were already installed, and claude_usage.sh parses its cache with jq.",
"Guard the claude_usage test section on a working jq. The probe runs `printf '{}' | jq -e .` rather than `command -v jq`, because a jq that exists but cannot execute produces exactly the same 'no data' output as an absent one, and `command -v` would pass in that case."
],
"verification": [
{
"command": "bash linux_configuration/tests/test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "EXIT=0 with jq present."
},
{
"command": "PATH=<stub-with-failing-jq> bash linux_configuration/tests/test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "Reports 'FAIL: a working jq is required for the claude_usage tests (pacman -S jq)' instead of the previous misleading \"expected '🤖 5h 34% · 7d 55%', actual: '🤖 no data'\" — the failure now names its real cause. Confirmed the earlier `command -v jq` form did NOT catch this case."
},
{
"command": "reproduce CI failure locally",
"result": "pass",
"evidence": "Running claude_usage.sh with a failing jq on PATH reproduced the exact CI output '🤖 no data', confirming the missing dependency rather than a logic defect."
}
],
"risks": [
"Adds one package to the CI container install step, marginally increasing job setup time.",
"The guard makes a missing dependency a hard failure rather than a skip; that is intended, since silently skipping would hide the block's assertions entirely."
],
"rollback": [
"git revert the commit; CI returns to failing on the claude_usage assertions until jq is installed another way.",
"Validate with: gh run list --limit 3 after the next push."
]
}

View File

@ -192,6 +192,14 @@ grep -Fq 'iface_path}/device' "$I3BLOCKS_DIR/ethernet.sh" \
|| fail 'ethernet script should require a real device to skip virtual interfaces'
printf 'Checking Claude usage block behavior and fork count...\n'
# claude_usage.sh parses its cache with jq and degrades to "no data" when jq is
# missing. That is the right runtime behaviour, but it would make every
# assertion below fail with a misleading message about percentages, so name the
# real cause instead of letting a missing tool look like a logic bug.
# Probe by running jq, not with `command -v`: a jq that exists but cannot
# execute produces exactly the same "no data" output as one that is absent.
printf '{}' | jq -e . >/dev/null 2>&1 \
|| fail 'a working jq is required for the claude_usage tests (pacman -S jq)'
CLAUDE_STATE_DIR="$TMP_DIR/limit-state"
mkdir -p "$CLAUDE_STATE_DIR"
claude_now=1786366861