Skip to content

Commit a09b891

Browse files
ci: xlings by GLOBAL, then by CN, then the release itself, for the bootstrap mcpp and the e2e mtest
A job's cached xlings index can predate a published pin, and xlings keeps it when its anonymous refresh fails (GitHub's 2026-11-09 incident, "timeouts due to surge in anonymous users"). install_pinned_mcpp.sh tries the configured mirror, refreshed; then CN (GitCode first), refreshed, the last by git; then the release (install.sh, GitHub then GitCode, sha256 checked; on Windows the zip through fetch_release.sh). e2e-mtest does the same for xim:mtest, with the release bundle checked against its pinned sha256. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 77de8a4 commit a09b891

2 files changed

Lines changed: 68 additions & 27 deletions

File tree

‎.github/actions/e2e-mtest/action.yml‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: the mtest release, an xlings package (xim:mtest), whose sha256 the index states
1616
required: false
1717
default: '0.5.2'
18+
sha256:
19+
description: sha256 of mtest-<version>-openkal-bundle-all.tar.gz, for the release taken when xlings cannot install it
20+
required: false
21+
default: 'be443f8c546b3f4628dcd3f1eb6f45b4d698a7f805232f966349faf8250863c6'
1822
token:
1923
description: a token that reads this repository's actions
2024
required: false
@@ -23,25 +27,41 @@ inputs:
2327
runs:
2428
using: composite
2529
steps:
26-
# THE ENGINE IS AN XLINGS PACKAGE (xim:mtest): installed as the job installs
27-
# mcpp and its toolchains, verified by the index's sha256, from the mirror
28-
# xlings is configured for, and kept in the job's xlings cache.
30+
# THE ENGINE IS AN XLINGS PACKAGE (xim:mtest), installed as the job installs
31+
# mcpp, verified by the index's sha256, and kept in the job's xlings cache:
32+
# by the configured mirror (GLOBAL), then by CN (GitCode first), each with a
33+
# refreshed index; else the release bundle itself (fetch_release.sh: the
34+
# web address, then the API's), checked against the pinned sha256.
2935
- name: mtest
3036
shell: bash
3137
env:
3238
MTEST_VERSION: ${{ inputs.version }}
39+
MTEST_SHA256: ${{ inputs.sha256 }}
40+
GITHUB_TOKEN: ${{ inputs.token }}
3341
run: |
3442
set -euo pipefail
35-
# An attempt refreshes the index first: a job's cached index can predate the release.
36-
for attempt in 1 2 3 4 5; do
43+
launcher=""
44+
for mirror in GLOBAL CN; do
45+
xlings config --mirror "$mirror" > /dev/null 2>&1 || true
3746
xlings update > /dev/null 2>&1 || true
38-
if xlings install "mtest@$MTEST_VERSION" -y; then break; fi
39-
[ "$attempt" = 5 ] && { echo "::error::mtest@$MTEST_VERSION could not be installed"; exit 1; }
40-
sleep 30
47+
if xlings install "mtest@$MTEST_VERSION" -y; then launcher=$(command -v mtest); break; fi
4148
done
42-
launcher=$(command -v mtest)
49+
xlings config --mirror GLOBAL > /dev/null 2>&1 || true
50+
if [ -z "$launcher" ]; then
51+
echo "::warning::xlings could not install mtest $MTEST_VERSION; taking the release itself"
52+
archive="mtest-$MTEST_VERSION-openkal-bundle-all.tar.gz"
53+
temp="$RUNNER_TEMP"; python=python3
54+
if [ "$RUNNER_OS" = Windows ]; then temp=$(cygpath -u "$RUNNER_TEMP"); python=python; fi
55+
bash "$GITHUB_WORKSPACE/.github/tools/fetch_release.sh" \
56+
"https://github.com/mcpp-community/mtest/releases/download/v$MTEST_VERSION/$archive" "$temp/$archive"
57+
actual=$("$python" -c "import hashlib,sys; print(hashlib.sha256(open(sys.argv[1],'rb').read()).hexdigest())" "$temp/$archive")
58+
[ "$actual" = "$MTEST_SHA256" ] || { echo "::error::$archive: sha256 $actual, the action pins $MTEST_SHA256"; exit 1; }
59+
mkdir -p "$temp/mtest" && tar xzf "$temp/$archive" -C "$temp/mtest"
60+
launcher="$temp/mtest/mtest-$MTEST_VERSION-openkal-bundle-all/bin/mtest"
61+
[ "$RUNNER_OS" = Windows ] && launcher="$launcher.exe"
62+
fi
4363
"$launcher" --version | grep -qF "$MTEST_VERSION" \
44-
|| { echo "::error::xlings's mtest is not $MTEST_VERSION: $("$launcher" --version)"; exit 1; }
64+
|| { echo "::error::the mtest at $launcher is not $MTEST_VERSION: $("$launcher" --version)"; exit 1; }
4565
echo "E2E_MTEST=$launcher" >> "$GITHUB_ENV"
4666
# The pull request's change, for the `pr` set: the base's tip and HEAD's
4767
# parents, so that `git diff <base>...HEAD` has its merge base. When they

‎.github/tools/install_pinned_mcpp.sh‎

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,46 @@ XL="$XL_HOME/.xlings/subos/default/bin/xlings${EXE}"
6464
echo "FAIL: no xlings at $XL_HOME/.xlings/subos/default/bin nor on PATH" >&2
6565
exit 1; }
6666

67-
# THE INDEX MAY BE OLDER THAN THE PIN. A job's xlings comes from the cache with
68-
# the index of when the cache was saved, and xlings keeps that index when its
69-
# refresh fails: an anonymous download of the index from GitHub answered 504
70-
# during GitHub's incident of 2026-11-09 ("timeouts due to surge in anonymous
71-
# users"), and the pin, published after the cache, was "not found". Each failed
72-
# attempt refreshes the index and waits; the last two take it by git, which
73-
# xlings otherwise declines for an index its release artifact manages.
74-
for attempt in 1 2 3 4 5; do
75-
if "$XL" install -y -u -g >&2; then break; fi
76-
[ "$attempt" = 5 ] && { echo "FAIL: the pinned mcpp could not be installed" >&2; exit 1; }
77-
sleep $(( attempt * 15 ))
78-
if [ "$attempt" -ge 3 ]; then XLINGS_INDEX_SOURCE=git "$XL" update >&2 || true
79-
else "$XL" update >&2 || true
80-
fi
81-
done
67+
PIN=$(grep -oE '"mcpp"[[:space:]]*:[[:space:]]*"[^"]+"' "$REPO_DIR/.xlings.json" \
68+
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1 || true)
8269

70+
# XLINGS FIRST, ITS MIRRORS IN TURN, THE RELEASE LAST. A job's xlings comes from
71+
# the cache with the index of when the cache was saved, and xlings keeps that
72+
# index when its refresh fails: during GitHub's incident of 2026-11-09
73+
# ("timeouts due to surge in anonymous users") the anonymous download of the
74+
# index answered 504 and a pin published after the cache was "not found".
75+
# 1-2 the configured mirror (GLOBAL), the index refreshed before the second;
76+
# 3-4 the CN mirror (GitCode first, GitHub after), refreshed; the fourth by
77+
# git, which xlings otherwise declines for an artifact-managed index;
78+
# then the release itself (install.sh: GitHub, then GitCode, sha256 checked).
8379
MCPP="$XL_HOME/.xlings/subos/default/bin/mcpp${EXE}"
80+
installed=no
81+
for attempt in 1 2 3 4; do
82+
case "$attempt" in
83+
2) "$XL" update >&2 || true ;;
84+
3) "$XL" config --mirror CN >&2 || true; "$XL" update >&2 || true ;;
85+
4) XLINGS_INDEX_SOURCE=git "$XL" update >&2 || true ;;
86+
esac
87+
if "$XL" install -y -u -g >&2; then installed=yes; break; fi
88+
sleep $(( attempt * 10 ))
89+
done
90+
"$XL" config --mirror GLOBAL >&2 || true
91+
if [ "$installed" = no ]; then
92+
echo "::warning::xlings could not install mcpp $PIN; taking the release itself" >&2
93+
prefix="${RUNNER_TEMP:-$(mktemp -d)}/mcpp-release-$PIN"
94+
if [ -n "$EXE" ]; then
95+
zip="mcpp-$PIN-windows-x86_64.zip"
96+
mkdir -p "$prefix"
97+
bash "$REPO_DIR/.github/tools/fetch_release.sh" \
98+
"https://github.com/mcpp-community/mcpp/releases/download/v$PIN/$zip" "$prefix/$zip" >&2
99+
(cd "$prefix" && unzip -qo "$zip" && rm -f "$zip")
100+
MCPP=$(find "$prefix" -type f -name "mcpp.exe" -path '*/bin/*' | head -1)
101+
else
102+
MCPP_VERSION="$PIN" MCPP_PREFIX="$prefix" MCPP_NO_PATH=1 bash "$REPO_DIR/install.sh" >&2
103+
MCPP="$prefix/bin/mcpp"
104+
fi
105+
[ -z "${GITHUB_PATH:-}" ] || dirname "$MCPP" >> "$GITHUB_PATH"
106+
fi
84107
[ -x "$MCPP" ] || { echo "FAIL: no mcpp at $MCPP after install" >&2; exit 1; }
85108

86109
# Assert the outcome rather than trust it. This is the ONLY place the pin is
@@ -98,8 +121,6 @@ MCPP="$XL_HOME/.xlings/subos/default/bin/mcpp${EXE}"
98121
# — it just silently truncates it to "2026.7.27" on both sides, so the
99122
# comparison below would accept any release of that day and this guard would
100123
# quietly stop guarding.
101-
PIN=$(grep -oE '"mcpp"[[:space:]]*:[[:space:]]*"[^"]+"' "$REPO_DIR/.xlings.json" \
102-
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1 || true)
103124
GOT=$("$MCPP" --version 2>/dev/null | head -1 \
104125
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1 || true)
105126
# Exact comparison: a substring match would let a pin of 0.0.10 be satisfied by

0 commit comments

Comments
 (0)