From ffacfb75effa0c79eb341a0abf0100a1de41b1d5 Mon Sep 17 00:00:00 2001 From: w3cj Date: Tue, 1 Dec 2026 09:13:04 -0700 Subject: [PATCH] fix(bump): e2e-tools reads mise's 404 when mise prints in color On CI mise prints its log in color, so unpublished's ^mise ERROR match missed the 404 and the run failed with "mise lock failed" instead of waiting for upstream. mise lock now runs with MISE_COLOR=0, and unpublished strips SGR escapes before it reads the errors and the Processing line. bump.txtar: a stub log with CI's colored lines, and the stub records the MISE_COLOR it was run with. Co-Authored-By: Claude Opus 5.5 --- scripts/bump.sh | 15 +++++++++------ testdata/script/bump.txtar | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/scripts/bump.sh b/scripts/bump.sh index 02ce664d..ce6754bc 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -523,10 +523,12 @@ not_yet() { # says musl): a release whose files aren't all out yet. Else false, as # for a 404 of a version the lock already has, which upstream published. The 404 must be mise's only # error but its trailer (its Version: and Run with --verbose lines), never a WARN mise went on after, -# so a checksum mismatch or any other error beside it fails the run. +# so a checksum mismatch or any other error beside it fails the run. The log is read without its +# color codes, should mise print them anyway. unpublished() { - local errs url file p tv tvs=() tool="" ver="" - errs=$(grep '^mise ERROR ' "$1" | grep -v -e '^mise ERROR Version: ' -e '^mise ERROR Run with --verbose ' || true) + local log errs url file p tv tvs=() tool="" ver="" + log=$(sed $'s/\e\\[[0-9;]*m//g' "$1") + errs=$(grep '^mise ERROR ' <<<"$log" | grep -v -e '^mise ERROR Version: ' -e '^mise ERROR Run with --verbose ' || true) [[ -n $errs && $errs != *$'\n'* ]] || return 1 url=$(sed -n 's/^mise ERROR HTTP status client error (404 Not Found) for url (\(https:\/\/[^ ()]*\))$/\1/p' <<<"$errs") file=${url##*/} @@ -534,7 +536,7 @@ unpublished() { [[ $file != *musl* ]] || p+=-musl # mise's "Processing 13 tool(s): node@24.23.0, pnpm@12.25.1, …": the one whose version is in the # URL, between a v, -, _ or / and a ., -, _ or /. - read -ra tvs <<<"$(sed -n 's/.*Processing [0-9]* tool(s): //p' "$1" | head -1 | tr -d ',')" + read -ra tvs <<<"$(sed -n 's/.*Processing [0-9]* tool(s): //p' <<<"$log" | head -1 | tr -d ',')" for tv in ${tvs[@]+"${tvs[@]}"}; do [[ $tv =~ ^[a-z0-9_-]+@[0-9A-Za-z][0-9A-Za-z.+~_-]*$ && $url == *[-v/_]"${tv#*@}"[-./_]* ]] || continue [[ -z $tool ]] || return 1 # two tools' versions in it: which one is unclear @@ -614,9 +616,10 @@ bump_e2e-tools() { mkdir -p "$tmp/e2e-tools/config"; d=$(cd "$tmp/e2e-tools" && pwd -P) cp "$root/assets/shared-tools/mise.toml" "$d/mise.toml" # A 404 wait under --check holds that tool back and resolves again, so the other tools' failures - # still show. Each tool is held back once at most. + # still show. Each tool is held back once at most. mise runs without color, which it turns on + # in CI, so unpublished reads its errors as plain mise ERROR lines. waited=" " - until (cd "$d" && MISE_DATA_DIR=$d/data MISE_CACHE_DIR=$d/cache MISE_STATE_DIR=$d/state MISE_CONFIG_DIR=$d/config \ + until (cd "$d" && MISE_COLOR=0 MISE_DATA_DIR=$d/data MISE_CACHE_DIR=$d/cache MISE_STATE_DIR=$d/state MISE_CONFIG_DIR=$d/config \ MISE_GLOBAL_CONFIG_FILE=$d/config/none.toml MISE_TRUSTED_CONFIG_PATHS=$d MISE_CEILING_PATHS=$(dirname "$d") \ "$tmp/host-mise/mise/bin/mise" lock --platform "$(tr ' ' ',' <<<"$platforms")") >"$tmp/mise-lock.log" 2>&1; do # A tool held back already that 404s again is a real failure, so the loop ends. diff --git a/testdata/script/bump.txtar b/testdata/script/bump.txtar index 7c90a77a..c4012d8b 100644 --- a/testdata/script/bump.txtar +++ b/testdata/script/bump.txtar @@ -158,6 +158,14 @@ stdout '^ crane ' ! stdout 'e2e lock' ! stderr . ! grep '^node' host-mise.toml +# mise runs with MISE_COLOR=0, and a log in color, as mise prints on CI +# without it, is read as if it had none. +grep '^0$' host-mise.color +exec bash -c 'printf ''%b\n'' "$(cat mise-lock-404-musl-color)" > host-mise.out' +exec repo/scripts/bump.sh --check e2e-tools +stdout '^ e2e node +none +waiting for upstream: 24\.23\.0 isn''t published for linux-arm64-musl yet$' +! stderr . +cp mise-lock-404-musl host-mise.out ! exec repo/scripts/bump.sh e2e-tools stderr '404 Not Found\) for url \(https://unofficial-builds\.nodejs\.org/' stderr '^bump: node 24\.23\.0 isn''t published for linux-arm64-musl yet: try again later$' @@ -657,9 +665,10 @@ done # it runs, or with $WORK/host-mise.out, while the mise.toml it resolves is # still the repo's (no tool held back), prints it and fails; with # $WORK/host-mise.always, it does so on every call. Every call goes in -# $WORK/host-mise.calls, and the mise.toml it resolved last in -# $WORK/host-mise.toml. +# $WORK/host-mise.calls, the mise.toml it resolved last in +# $WORK/host-mise.toml, and its MISE_COLOR in $WORK/host-mise.color. echo "host mise $*" >> "$WORK/host-mise.calls" +echo "${MISE_COLOR-unset}" > "$WORK/host-mise.color" if [[ -f mise.toml ]]; then cp mise.toml "$WORK/host-mise.toml"; fi if [[ -f $WORK/host-mise.always ]]; then cat "$WORK/host-mise.always"; exit 1; fi if [[ -f $WORK/host-mise.out ]] && cmp -s mise.toml "$WORK/repo/assets/shared-tools/mise.toml"; then @@ -777,6 +786,12 @@ mise lock node@24.23.0 linux-arm64-musl mise ERROR HTTP status client error (404 Not Found) for url (https://unofficial-builds.nodejs.org/download/release/v24.23.0/node-v24.23.0-linux-arm64-musl.tar.gz) mise ERROR Version: 2026.11.14 macos-arm64 (2026-11-24) mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information +-- mise-lock-404-musl-color -- +→ Targeting 4 platform(s) for /tmp/e2e-tools/mise.lock: linux-arm64, linux-arm64-musl, linux-x64, linux-x64-musl +→ Processing 2 tool(s): \033[2mnode@24.23.0\033[0m, \033[2mdotnet@11.0.100\033[0m +\033[31mmise\033[0m \033[31mERROR\033[0m HTTP status client error (404 Not Found) for url (https://unofficial-builds.nodejs.org/download/release/v24.23.0/node-v24.23.0-linux-arm64-musl.tar.gz) +\033[31mmise\033[0m \033[31mERROR\033[0m Version: 2026.11.14 linux-x64 (2026-11-24) +\033[31mmise\033[0m \033[31mERROR\033[0m \033[2mRun with --verbose or MISE_VERBOSE=1 for more information\033[0m -- mise-lock-404-locked -- → Processing 1 tool(s): dotnet@11.0.100 mise ERROR HTTP status client error (404 Not Found) for url (https://builds.dotnet.microsoft.com/dotnet/Sdk/11.0.100/dotnet-sdk-11.0.100-linux-musl-x64.tar.gz)