mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
misattributing the failures.
Every one of these made a release job report the wrong cause, which is worse
than the failure itself: two of them sent the last round of work after the
wrong problem.
1. snap-launchpad never checked whether a .snap existed. In three steps it did
snaps=( wekan_${VERSION}_<arch>.snap )
and then counted the array. That string has no wildcard, so it is a literal
filename, `shopt -s nullglob` cannot empty a literal, and the count was
ALWAYS 1 whether or not the file was there. So s390x logged an empty
`Artifacts:` list, then "Remote build s390x succeeded", then
'wekan_10.48_s390x.snap' is not a valid file
##[error]SNAP_AUTH did not work: the Snap Store refused the upload
The Snap Store never saw an upload. It is a real glob now, the first match
must also be non-empty, and the upload step says "the Launchpad build
produced no artifact - this is NOT a SNAP_AUTH problem" for a missing file
and keeps the credential advice for a refusal by the store.
2. The Launchpad build log was downloaded and thrown away. It is the only thing
that says why a build ends as "Stopped", and the job printed it only when
snapcraft's exit code was non-zero - which, after (1), it was not. It is now
printed whenever there is no snap, along with `ls -la`, and the "exit 0 but
nothing built" case says so in words.
3. build-win64 verified the zip by listing it into a variable and grepping that,
so a failure printed the verdict and none of the evidence: "has no
bundle/main.js" with no way to tell a bad zip from a bad grep. What can be
checked robustly now is: bundle/main.js, bundle/node.exe and
bundle/start-wekan.bat exist and are non-empty BEFORE zipping, and the
archive passes `7z t`. The listing is printed - five lines and a match count
per file - and a zero count is a warning naming both facts that contradict
it, not a failed release.
4. The snap-variants pre-flight asked GitHub for `.permissions.push` on the
variant repository. That field is the authenticated USER's role, not what the
token may do: it answered true, and the push one step later got
remote: Permission to wekan/wekan-gantt-gpl.git denied to xet7
It now asks the receive-pack advertisement - the first thing a real push
requests, and what GitHub answers 403 to for a token without Contents:write -
with the token in curl's -u rather than in a URL, and no git command, since
this step runs before actions/checkout.
What still needs a person is unchanged and written up in ../log/workflow/TODO.txt:
why Launchpad stops the ppc64el and s390x builds after ~20 minutes, and giving
WEKAN_REPO_TOKEN write access to the two variant repositories.
tests/releaseWin64AndVariants.test.cjs is new and pins (3) and (4);
tests/releaseSnapArches.test.cjs gains "every snaps=() must be a real glob" and
"the build log is printed whenever there is no snap", and its
"SNAP_AUTH did not work" assertion is replaced by the two messages that took its
place, with a note saying why. Both read the workflow with comments stripped -
the comments quote the broken lines on purpose.
Thanks to xet7 !
123 lines
5.5 KiB
JavaScript
123 lines
5.5 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('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('the listing is PRINTED, and a missing match is a warning, not a failure', () => {
|
|
const verify = win.slice(win.indexOf('Verify the win64 zip'));
|
|
assert.ok(/printf '%s\\n' "\$listing" \| head -5/.test(verify),
|
|
'the listing must appear in the log; judging it invisibly is the bug this fixes');
|
|
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`);
|