mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
v10.49 printed the listing the previous fix added, and it settles two releases of guessing: 7z t: archive is intact. 7z l -ba listed 51850 entries; the first five: 2026-07-28 21:58:39 D.... 0 0 bundle 2026-07-28 21:52:07 ..... 9 9 bundle\.node_version.txt 2026-07-28 21:58:36 ....A 8828928 3365469 bundle\bsondump.exe 2026-07-28 21:58:39 ....A 55313920 26791675 bundle\ferretdb.exe 2026-07-28 21:52:07 ..... 243 168 bundle\main.js ##[error]Process completed with exit code 141 bundle\main.js is right there, and the step still failed - with 141, which is 128+13, SIGPIPE. `printf '%s\n' "$listing" | head -5`: head has its five lines and exits, printf is killed writing to a closed pipe, `set -o pipefail` (which GitHub's bash sets) makes that the pipeline's status, and `set -e` ends the step. The evidence printed, then killed the job. The same mechanism is the ORIGINAL v10.48 failure, and this is the part worth keeping: `printf '%s' "$listing" | grep -qF -e "bundle\main.js"` - grep -q exits the instant it MATCHES, printf dies of SIGPIPE, pipefail reports 141, and `if !` reads that as "not found". So "wekan-10.48-win64.zip has no bundle/main.js" was printed BECAUSE the file was found. Reproduced both, exactly, in bash. Every listing now goes through a file and every reader reads the file: the win64 verify, the four `unzip -l "$zip" | grep -q " $want$"` checks on the other platforms (same trap, only luckier about the pipe buffer so far), and the five `gh release view ... | grep -qxF` asset checks. No pipe, no SIGPIPE, no pipefail verdict on a command that did its job. tests/releaseWin64AndVariants.test.cjs pins that nothing in the workflow pipes a listing into grep or head, and that the win64 verify reads its listing from a file. Thanks to xet7 !
149 lines
7.0 KiB
JavaScript
149 lines
7.0 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node guard for two release-all.yml jobs that failed v10.48 for reasons
|
|
// that were not what the log said. Run: node tests/releaseWin64AndVariants.test.cjs
|
|
//
|
|
// build-win64: the zip was verified by listing it with `7z l -ba` INTO A VARIABLE
|
|
// and grepping that. When the grep found nothing the log had the verdict — "has
|
|
// no bundle/main.js" — and not one line of the listing it judged, so a broken zip
|
|
// and a broken grep looked exactly alike. Two releases were failed on it. What
|
|
// can be verified robustly is verified robustly (the files are there before
|
|
// zipping; the archive passes `7z t`), and the listing is now printed as evidence
|
|
// rather than used as a hidden verdict.
|
|
//
|
|
// snap-variants: the pre-flight asked GitHub for `.permissions.push` on the
|
|
// variant repository, which describes the authenticated USER's role rather than
|
|
// what the TOKEN may do — it answered `true`, and the push one step later was
|
|
// refused with "Permission to wekan/wekan-gantt-gpl.git denied to xet7". The
|
|
// pre-flight now asks the receive-pack endpoint, which is the thing that refuses.
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
const workflow = fs.readFileSync(
|
|
path.join(repoRoot, '.github/workflows/release-all.yml'), 'utf8',
|
|
);
|
|
|
|
// A comment inside a `run:` block is text the shell never sees. These files keep
|
|
// the OLD broken line in a comment on purpose, so assertions about behaviour must
|
|
// read the code only.
|
|
const code = text => text.split('\n').filter(l => !/^\s*#/.test(l)).join('\n');
|
|
|
|
function job(name) {
|
|
const start = workflow.indexOf(`\n ${name}:\n`);
|
|
assert.notStrictEqual(start, -1, `release-all.yml has no ${name} job`);
|
|
const rest = workflow.slice(start + 1);
|
|
const next = rest.search(/\n [a-z0-9-]+:\n/);
|
|
return next === -1 ? rest : rest.slice(0, next);
|
|
}
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
try {
|
|
fn();
|
|
passed++;
|
|
console.log(' ok -', name);
|
|
} catch (err) {
|
|
console.error(` FAIL - ${name}\n ${err.message}`);
|
|
process.exitCode = 1;
|
|
}
|
|
}
|
|
|
|
console.log('releaseWin64AndVariants:');
|
|
|
|
const win = code(job('build-win64'));
|
|
|
|
test('the bundle is checked BEFORE it is zipped', () => {
|
|
const embed = win.slice(0, win.indexOf('Create win64 zip'));
|
|
for (const want of ['main.js', 'node.exe', 'start-wekan.bat']) {
|
|
assert.ok(embed.includes(want), `${want} is named in the embed step`);
|
|
}
|
|
assert.ok(/\[ ! -s "bundle\/\$want" \]/.test(embed),
|
|
'each one must be present and non-empty in the directory - that is where '
|
|
+ '"can this zip start WeKan" is actually decided, with no archive format in the way');
|
|
assert.ok(/exit 1/.test(embed), 'and a missing one fails the job there');
|
|
});
|
|
|
|
test('no listing anywhere in the workflow is piped into grep', () => {
|
|
// Same trap, four more times: `unzip -l "$zip" | grep -q " $want$"` reports a
|
|
// present file as missing whenever grep matches before unzip has finished
|
|
// writing - which depends only on how big the listing is and how early the
|
|
// match falls, i.e. on luck.
|
|
const piped = workflow.split('\n')
|
|
.filter(l => !/^\s*#/.test(l))
|
|
.filter(l => /(unzip -l|7z l|release view).*\|\s*(grep|head)/.test(l));
|
|
assert.deepStrictEqual(piped, [],
|
|
'list to a file, then grep the file');
|
|
});
|
|
|
|
test('the archive is verified by an integrity test, not by grepping a listing', () => {
|
|
const verify = win.slice(win.indexOf('Verify the win64 zip'));
|
|
assert.ok(/7z t "\$zip"/.test(verify),
|
|
'`7z t` reads every entry and is what catches a truncated or corrupt zip');
|
|
assert.ok(/did not pass 7z t/.test(verify), 'and says so when it fails');
|
|
});
|
|
|
|
test('nothing in the verify step reads a listing through a PIPE', () => {
|
|
// This is the whole win64 story, twice over. `cmd | head` and `cmd | grep -q`
|
|
// end the reader as soon as it has what it needs, the writer gets SIGPIPE, and
|
|
// `set -o pipefail` - which GitHub's bash sets - makes the pipeline's status
|
|
// 141. Under `set -e` that fails the step. v10.48 read "$zip has no
|
|
// bundle/main.js" because grep -q MATCHED and killed printf; v10.49 died with
|
|
// exit code 141 at `printf | head -5` after printing the listing that shows
|
|
// bundle\main.js five lines in. The listing goes to a file now, and every
|
|
// reader reads the file.
|
|
const from = win.indexOf('Verify the win64 zip');
|
|
const verify = win.slice(from, win.indexOf('- uses: actions/upload-artifact', from));
|
|
assert.ok(/7z l -ba "\$zip" > zip-listing\.txt/.test(verify),
|
|
'the listing is written to a file');
|
|
assert.ok(!/\|\s*(head|grep|tail|wc)\b/.test(verify),
|
|
'and nothing pipes into head/grep/tail/wc, which is what SIGPIPE turns into a '
|
|
+ 'failed step:\n' + verify.split('\n').filter(l => /\|\s*(head|grep|tail|wc)\b/.test(l)).join('\n'));
|
|
assert.ok(/head -5 zip-listing\.txt/.test(verify),
|
|
'the listing must still appear in the log; judging it invisibly was the first bug');
|
|
assert.ok(/entries matching bundle\/\$want/.test(verify),
|
|
'with the match count for each wanted file');
|
|
const missing = verify.slice(verify.indexOf('if [ "${n:-0}" -eq 0 ]'));
|
|
assert.ok(/::warning::/.test(missing.slice(0, 400)),
|
|
'a zero count is a WARNING: the file was verified in the directory and the '
|
|
+ 'archive passed 7z t, so a zero count says something about 7-Zip output, '
|
|
+ 'not about the bundle');
|
|
assert.ok(!/::error::[\s\S]{0,200}has no bundle/.test(verify),
|
|
'and it must not fail the release on the listing format again');
|
|
});
|
|
|
|
const variants = code(job('snap-variants'));
|
|
|
|
test('the push pre-flight asks the endpoint that refuses a push', () => {
|
|
assert.ok(/service=git-receive-pack/.test(variants),
|
|
'the receive-pack advertisement is the first thing a real push requests, and '
|
|
+ 'is what GitHub answers 403 to for a token without write access');
|
|
assert.ok(!/permissions\.push/.test(variants),
|
|
'the repos API permissions block describes the USER, not the token - it said '
|
|
+ 'push=true for a token that was then refused');
|
|
});
|
|
|
|
test('the pre-flight cannot leak the token, and needs no checkout', () => {
|
|
const guard = variants.slice(0, variants.indexOf('- name: Checkout wekan'));
|
|
assert.ok(/-u "x-access-token:\$REPO_TOKEN"/.test(guard),
|
|
'the token goes in -u, never in a URL that could be echoed');
|
|
assert.ok(!/https:\/\/x-access-token:\$\{?REPO_TOKEN/.test(guard),
|
|
'no token-in-URL in the pre-flight');
|
|
assert.ok(!/git (clone|push|ls-remote)/.test(guard),
|
|
'and no git command: this step runs BEFORE actions/checkout, so there is no '
|
|
+ 'local repository for git to work in');
|
|
});
|
|
|
|
test('a refusal and a broken pre-flight are told apart', () => {
|
|
assert.ok(/"\$rp" = "403"/.test(variants) && /"\$rp" = "401"/.test(variants),
|
|
'403/401 is "the token may not push"');
|
|
assert.ok(/neither a yes nor a permission refusal/.test(variants),
|
|
'anything else says it is something else, instead of blaming the token');
|
|
assert.ok(/Contents: Read and write/.test(variants),
|
|
'and the refusal message says exactly what to change');
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|