mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The v13.18 release run: every wekan and wekan-gantt-gpl snap uploaded,
then sat in the Snap Store's "Status: processing" for hours. snapcraft
polls that with no limit, so GitHub cancelled the jobs at timeout-minutes
(2 h native, 6 h Launchpad). snap-upload-retry.sh now gives one upload
30 minutes (SNAP_UPLOAD_PROCESSING_BUDGET). A revision the store accepted
is left for the store to release to the channels sent with it, with a
warning, instead of uploading it again; an upload cut off before the
store accepted it is retried.
Bun android-arm64 died on a Termux mirror mid-sync ("File has unexpected
size ... Mirror sync in progress?") and Bun freebsd-x64 on an unreachable
FreeBSD package mirror. Termux installs (Bun, Android bundles) and the
i386 libraries of single-file now go through releases/apt-install.sh,
which learned Termux's prefix and lack of sudo. Every BSD VM prepare
retries its package install 5 times and says why when it gives up.
Thanks to xet7 !
172 lines
7.6 KiB
JavaScript
172 lines
7.6 KiB
JavaScript
'use strict';
|
|
|
|
// releases/apt-install.sh, and the rule that a release job installs packages
|
|
// through it. Run: node tests/releaseAptInstall.test.cjs
|
|
//
|
|
// The v10.87 `bump` job died on a repository the release does not use:
|
|
//
|
|
// E: Failed to fetch https://dl.google.com/linux/chrome-stable/deb/dists/stable/main/binary-amd64/Packages.gz
|
|
// Hash Sum mismatch
|
|
// E: Some index files failed to download.
|
|
// Error: Process completed with exit code 100.
|
|
//
|
|
// It was installing python3 and curl. A GitHub runner ships with google-chrome,
|
|
// microsoft-prod, azure-cli and docker repositories configured, and `apt-get
|
|
// update` fails as a WHOLE when any one of them serves an index that does not
|
|
// match its own hashes - which is what a mirror looks like mid-republish.
|
|
//
|
|
// Two ways out, in order: wait (it passes a minute later), then drop the
|
|
// third-party lists, because everything a release job installs comes from the
|
|
// distribution archive. Both are in the script; this pins them.
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
const script = path.join(repoRoot, 'releases/apt-install.sh');
|
|
const read = f => fs.readFileSync(path.join(repoRoot, f), 'utf8');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
console.log('releaseAptInstall:');
|
|
|
|
// A fake apt-get that fails `update` the first `failures` times, and a fake
|
|
// sudo that RECORDS what it was asked to do rather than doing it - these tests
|
|
// must not touch this machine's apt state.
|
|
function fakeApt(dir, failures) {
|
|
const counter = path.join(dir, 'updates');
|
|
const log = path.join(dir, 'sudo.log');
|
|
fs.writeFileSync(path.join(dir, 'apt-get'), [
|
|
'#!/bin/sh',
|
|
'if [ "$1" = update ]; then',
|
|
` n=$(cat "${counter}" 2>/dev/null || echo 0); n=$((n+1)); echo $n > "${counter}"`,
|
|
` if [ "$n" -le ${failures} ]; then`,
|
|
' echo "E: Failed to fetch https://dl.google.com/linux/chrome-stable/... Hash Sum mismatch" >&2',
|
|
' exit 100',
|
|
' fi',
|
|
' echo "Reading package lists... Done"; exit 0',
|
|
'fi',
|
|
'if [ "$1" = install ]; then echo "INSTALLED $*"; exit 0; fi',
|
|
].join('\n') + '\n', { mode: 0o755 });
|
|
fs.writeFileSync(path.join(dir, 'sudo'), [
|
|
'#!/bin/sh',
|
|
`echo "$@" >> "${log}"`,
|
|
'case "$1" in',
|
|
// Anything that would change this machine is recorded and not run; the
|
|
// apt-get calls go to the fake above.
|
|
' rm|mv|mkdir|sh) exit 0 ;;',
|
|
'esac',
|
|
'exec "$@"',
|
|
].join('\n') + '\n', { mode: 0o755 });
|
|
return {
|
|
updates: () => Number(fs.readFileSync(counter, 'utf8').trim()),
|
|
sudo: () => (fs.existsSync(log) ? fs.readFileSync(log, 'utf8') : ''),
|
|
};
|
|
}
|
|
|
|
function run(dir, packages, env) {
|
|
return spawnSync('bash', [script].concat(packages), {
|
|
encoding: 'utf8',
|
|
env: Object.assign({}, process.env, {
|
|
PATH: `${dir}:${process.env.PATH}`,
|
|
APT_SLEEPS: '0',
|
|
}, env || {}),
|
|
});
|
|
}
|
|
|
|
test('a Hash Sum mismatch is waited out, and the packages install', () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'apt-'));
|
|
const apt = fakeApt(dir, 2);
|
|
const r = run(dir, ['python3', 'curl']);
|
|
assert.strictEqual(r.status, 0, r.stderr);
|
|
assert.strictEqual(apt.updates(), 3, 'it retried twice and then succeeded');
|
|
assert.ok(/INSTALLED install -y python3 curl/.test(r.stdout),
|
|
'and installed exactly what it was asked for');
|
|
assert.ok(/::warning::/.test(r.stdout), 'the log says why the job paused');
|
|
});
|
|
|
|
test('the index is cleared between attempts, not just re-read', () => {
|
|
// A Hash Sum mismatch is a CACHED index that disagrees with the server; apt
|
|
// will keep reporting it until the stale lists are gone.
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'apt-'));
|
|
const apt = fakeApt(dir, 1);
|
|
run(dir, ['curl']);
|
|
assert.ok(/rm -rf \/var\/lib\/apt\/lists/.test(apt.sudo()),
|
|
'the stale lists are removed before retrying');
|
|
});
|
|
|
|
test('a repository the release does not use is dropped, not fatal', () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'apt-'));
|
|
const apt = fakeApt(dir, 3); // fails every attempt, succeeds after the drop
|
|
// Pointed at a temp directory: the real one belongs to whatever machine this
|
|
// suite runs on, and a test must not move its package sources.
|
|
const sources = path.join(dir, 'sources.list.d');
|
|
fs.mkdirSync(sources);
|
|
fs.writeFileSync(path.join(sources, 'google-chrome.list'), 'deb https://dl.google.com/... stable main\n');
|
|
const r = run(dir, ['python3'], { APT_ATTEMPTS: '3', APT_SOURCES_DIR: sources });
|
|
assert.strictEqual(r.status, 0, 'the packages still install');
|
|
assert.ok(/sources\.list\.d/.test(apt.sudo()),
|
|
'the third-party lists are moved aside');
|
|
assert.ok(/::warning::.*third-party/.test(r.stdout),
|
|
'and the log says so - a silent change of package sources would be worse');
|
|
});
|
|
|
|
test('a mirror that never comes back fails the job, saying so (negative)', () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'apt-'));
|
|
fakeApt(dir, 99);
|
|
const r = run(dir, ['python3'], { APT_ATTEMPTS: '2' });
|
|
assert.strictEqual(r.status, 100);
|
|
assert.ok(/::error::.*outage at the mirror, not WeKan/.test(r.stdout),
|
|
'the error must not read as a WeKan failure');
|
|
});
|
|
|
|
test('in Termux it runs apt as its own user and clears the lists under the prefix', () => {
|
|
// v13.18: Bun android-arm64 died on a Termux mirror mid-sync - "File has
|
|
// unexpected size (593235 != 593699). Mirror sync in progress?". Termux has
|
|
// no sudo, and its apt state is under $PREFIX, not /var/lib/apt.
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'apt-'));
|
|
const apt = fakeApt(dir, 1);
|
|
const prefix = path.join(dir, 'usr');
|
|
const lists = path.join(prefix, 'var/lib/apt/lists');
|
|
fs.mkdirSync(lists, { recursive: true });
|
|
fs.writeFileSync(path.join(lists, 'stale_Packages'), 'x');
|
|
const r = run(dir, ['nodejs-lts'], { APT_ROOT: prefix });
|
|
assert.strictEqual(r.status, 0, r.stderr);
|
|
assert.strictEqual(apt.updates(), 2, 'the mirror is waited out');
|
|
assert.strictEqual(apt.sudo(), '', 'no sudo: Termux has none');
|
|
assert.deepStrictEqual(fs.readdirSync(lists), [], 'its own stale lists are cleared');
|
|
assert.ok(/INSTALLED install -y nodejs-lts/.test(r.stdout));
|
|
// Negative: only Termux's prefix is taken as an apt root, not any directory
|
|
// an apt-get happens to be in.
|
|
assert.match(read('releases/apt-install.sh'), /\*\/com\.termux\/\*\/bin\/apt-get\)/);
|
|
});
|
|
|
|
test('every release job installs packages through it', () => {
|
|
const bare = [];
|
|
const workflows = fs.readdirSync(path.join(repoRoot, '.github/workflows'))
|
|
.filter(f => /\.ya?ml$/.test(f)).map(f => `.github/workflows/${f}`);
|
|
// Every workflow, so a new one cannot bring the bare call back: v13.18's
|
|
// Bun and Android Termux builds, and single-file's i386 libraries, were
|
|
// outside the list this used to check.
|
|
assert.ok(workflows.includes('.github/workflows/bun.yml'));
|
|
for (const file of workflows.concat(['releases/install-node-for-arch.sh'])) {
|
|
read(file).split('\n').forEach((line, i) => {
|
|
if (/^\s*#/.test(line.trim())) return;
|
|
if (!/apt-get (update|install)/.test(line)) return;
|
|
if (line.includes('apt-install.sh')) return;
|
|
// install-node-for-arch.sh probes for an optional qemu package and
|
|
// carries on without it; that one is allowed to fail.
|
|
if (/\|\| /.test(line) || /\/dev\/null/.test(line)) return;
|
|
bare.push(`${file}:${i + 1}: ${line.trim().slice(0, 70)}`);
|
|
});
|
|
}
|
|
assert.deepStrictEqual(bare, [],
|
|
'a bare apt-get update fails the job when any configured repository is mid-update');
|
|
});
|
|
|
|
console.log(`\nreleaseAptInstall: ${passed} tests passed`);
|