PEP-314: помощник проверяет, что Go распаковался; тест не привязан к Linux
Some checks are pending
peppa-ci / ci (pull_request) Waiting to run
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 51с
peppa/build build: success за 37с
peppa/bundle bundle: success за 0с

Приёмка координатора, полный локальный прогон на macOS: четыре теста «Go для проверок» ждали архив
для Linux, а помощник просит архив своей системы. Заодно нашёлся изъян самого помощника: когда
curl ничего не скачал, tar на macOS считает пустой поток пустым архивом — помощник сообщал об
успехе и ставил в PATH каталог без go. Теперь итог загрузки проверяется по самому файлу go.

Проверено: macOS — 13 из 13 (без правки скрипта «Go не скачался» падает); Linux, образ задания
проверок — обычная загрузка и отказ с кодом 1 при недоступном адресе.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-27 17:17:10 +05:00
parent 40eda2ea6f
commit 3a195f9980
2 changed files with 10 additions and 4 deletions

View File

@ -15,6 +15,9 @@ const ROOT = resolve(fileURLToPath(import.meta.url), "../../../..");
const TOOLS = join(ROOT, "template/.gitea/peppa-tools.sh");
const TMP = mkdtempSync(join(tmpdir(), "peppa-stack-tools-"));
const ARCH = ({ x64: "amd64", arm64: "arm64" } as Record<string, string>)[process.arch] ?? process.arch;
// The archive the helper asks for is named after the host (`uname -s`): linux in the checks job and at the
// agent, darwin on a developer's Mac — the tests run on both.
const OS = process.platform === "darwin" ? "darwin" : "linux";
// The user has a passwd entry (mock getent finds it) — the sandbox running these tests may have none;
// the case without one has its own describe below.
const HAS_USER = mkdtempSync(join(TMP, "mock-getent-ok-"));
@ -30,13 +33,13 @@ function exe(path: string, body: string) {
chmodSync(path, 0o755);
}
/** A mock go.dev/dl: go<ver>.linux-<arch>.tar.gz with go/bin/go answering `go version`. */
/** A mock go.dev/dl: go<ver>.<os>-<arch>.tar.gz with go/bin/go answering `go version`. */
function mockGoDl(version: string): string {
const dl = mkdtempSync(join(TMP, "mock-go-dl-"));
const src = join(dl, "src");
mkdirSync(join(src, "go/bin"), { recursive: true });
exe(join(src, "go/bin/go"), `echo "go version go${version} linux/${ARCH}"`);
execFileSync("tar", ["-czf", join(dl, `go${version}.linux-${ARCH}.tar.gz`), "-C", src, "go"]);
execFileSync("tar", ["-czf", join(dl, `go${version}.${OS}-${ARCH}.tar.gz`), "-C", src, "go"]);
return dl;
}
@ -76,7 +79,7 @@ describe("Go для проверок", () => {
const cache = join(work, "cache");
const r = source(["go"], { PEPPA_GO_DL_BASE: `file://${dl}`, PEPPA_TOOLS_CACHE: cache, GITHUB_PATH: ghPath }, work);
assert.equal(r.code, 0, r.err);
assert.match(r.err, new RegExp(`скачиваю go1\\.27\\.0\\.linux-${ARCH}\\.tar\\.gz`));
assert.match(r.err, new RegExp(`скачиваю go1\\.27\\.0\\.${OS}-${ARCH}\\.tar\\.gz`));
assert.equal(r.go, join(cache, "go/1.27.0/go/bin/go"));
assert.equal(readFileSync(ghPath, "utf8").trim(), join(cache, "go/1.27.0/go/bin"));
// the second call takes the cache, nothing is downloaded

View File

@ -48,7 +48,10 @@ _peppa_go() {
url="${PEPPA_GO_DL_BASE:-https://go.dev/dl}/$tgz"
_peppa_say "скачиваю $tgz"
mkdir -p "$dir" || return 1
if ! curl -fsSL --retry 3 "$url" | tar -xz -C "$dir"; then
# Итог проверяется по самому файлу go: tar на macOS считает пустой поток пустым архивом и
# отвечает успехом, когда curl ничего не скачал.
curl -fsSL --retry 3 "$url" | tar -xz -C "$dir"
if [[ ! -x "$dir/go/bin/go" ]]; then
_peppa_say "не удалось скачать Go $v ($url)"
rm -rf "$dir"
return 1