mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
v12.73 was prepared on a main that origin had moved past: the release bot's v12.72 version bump had landed meanwhile. release-all.sh renamed Upcoming and committed "Prepare v12.73 release", its bare git push was refused, and set -e stopped it before gh workflow run - so no release ran, and no tag was made, while the CHANGELOG already said v12.73. release-all.sh now runs build.sh's git pull right after its checks, before it chooses the version or renames anything, and checks the Upcoming section again after it; and it pushes with build.sh's git push, which repairs moved CHANGELOG links and pulls and pushes once more when origin moved meanwhile. If the push still does not finish, it says that the workflow was NOT dispatched, and the command to dispatch it. releaseUpcomingPreflight pins the order - the pull before the version and the rename, the push before the dispatch - and fails on a bare git push; releaseTelemetry and the version-selection fixture follow. Thanks to xet7 !
91 lines
5.4 KiB
JavaScript
91 lines
5.4 KiB
JavaScript
'use strict';
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { spawnSync } = require('node:child_process');
|
|
const root = path.resolve(__dirname, '..');
|
|
const tmpRoot = path.join(root, '.tools/tmp');
|
|
fs.mkdirSync(tmpRoot, { recursive: true });
|
|
const checker = path.join(root, 'releases/check-upcoming-release.sh');
|
|
const entry = '<details>\n<summary><a href="https://github.com/wekan/wekan/commit/1234567">Fix build</a></summary>\n</details>\n';
|
|
const upcoming = '# Upcoming WeKan ® release\n\n**In short:** Fix build preparation.\n\n';
|
|
|
|
// Only the Upcoming heading is required - release-all.sh renames it to the new
|
|
// version. What is under it (entries, In short, Languages updated) is optional:
|
|
// a missing part is a warning, never a stop.
|
|
test('release preflight requires one Upcoming heading, and only warns about its content', () => {
|
|
const dir = fs.mkdtempSync(path.join(tmpRoot, 'release-preflight-'));
|
|
try {
|
|
for (const [text, valid, warning] of [
|
|
[upcoming + entry + '# v11.75 2026-09-14 WeKan ® release\n', true, null],
|
|
[upcoming.replace('**In short:** Fix build preparation.', '') + entry, true, /no \*\*In short:\*\* summary/],
|
|
[upcoming.replace('Fix build preparation.', ' ') + entry, true, /no \*\*In short:\*\* summary/],
|
|
['# Upcoming WeKan ® release\n' + entry + '# v11.75 date\n**In short:** Older summary.\n', true, /no \*\*In short:\*\* summary/],
|
|
[upcoming + '\n# v11.75 2026-09-14 WeKan ® release\n' + entry, true, /no entries/],
|
|
['# Upcoming WeKan ® release\n\n# v11.75 2026-09-14 WeKan ® release\n', true, /no entries[\s\S]*no \*\*In short/],
|
|
// Negative: without exactly one Upcoming heading there is no release to make.
|
|
['# v11.75 2026-09-14 WeKan ® release\n' + entry, false, null],
|
|
[upcoming + entry + upcoming + entry, false, null],
|
|
['# Upcoming WeKan unrelated heading\n' + entry, false, null],
|
|
]) {
|
|
const file = path.join(dir, 'CHANGELOG.md');
|
|
fs.writeFileSync(file, text);
|
|
const result = spawnSync('bash', [checker, file], { encoding: 'utf8', env: { ...process.env, TMPDIR: tmpRoot } });
|
|
assert.equal(result.status, valid ? 0 : 1, result.stderr);
|
|
if (!valid) assert.match(result.stderr, /Error:.*Upcoming/);
|
|
if (warning) assert.match(result.stderr, warning);
|
|
if (valid && !warning) assert.equal(result.stderr, '');
|
|
assert.equal(fs.readFileSync(file, 'utf8'), text, 'preflight is read-only');
|
|
}
|
|
const absent = spawnSync('bash', [checker, path.join(dir, 'absent.md')], { encoding: 'utf8' });
|
|
assert.equal(absent.status, 1);
|
|
assert.match(absent.stderr, /changelog not found/);
|
|
} finally {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test('release preflight accepts a Translations group without its language list, with a warning', () => {
|
|
const dir = fs.mkdtempSync(path.join(tmpRoot, 'release-language-preflight-'));
|
|
try {
|
|
const file = path.join(dir, 'CHANGELOG.md');
|
|
const group = '**Translations** - Locale repairs.\n\n';
|
|
for (const [notes, warns] of [
|
|
[upcoming + group + entry, true],
|
|
[upcoming + group + '**Languages updated:** Veps, Tigre\n\n' + entry, false],
|
|
[upcoming + group + entry + '\n**Languages updated:** Veps\n', true],
|
|
]) {
|
|
fs.writeFileSync(file, notes);
|
|
const result = spawnSync('bash', [checker, file], { encoding: 'utf8' });
|
|
assert.equal(result.status, 0, result.stderr);
|
|
if (warns) assert.match(result.stderr, /Warning:.*Languages updated/);
|
|
else assert.equal(result.stderr, '');
|
|
assert.equal(fs.readFileSync(file, 'utf8'), notes);
|
|
}
|
|
} finally {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test('release notes are checked before tools, hash repairs, version overrides or remote commands', () => {
|
|
const source = fs.readFileSync(path.join(root, 'releases/release-all.sh'), 'utf8');
|
|
const guard = source.indexOf('bash "$REPO_DIR/releases/check-upcoming-release.sh"');
|
|
assert.ok(guard > 0);
|
|
for (const later of ['ensure_tools git gh', '"$REPO_DIR/build.sh" git-pull', 'bash "$(dirname "$0")/fix-changelog-hashes.sh"',
|
|
'if [ -n "${1:-}" ]', 'git add --all', '"$REPO_DIR/build.sh" git-push', 'gh workflow run']) {
|
|
assert.ok(source.indexOf(later) > guard, `${later} must follow successful preflight`);
|
|
}
|
|
// v12.73: origin had moved, the bare push was refused and the workflow was
|
|
// never dispatched. The release pulls first, before the version is chosen,
|
|
// and pushes with build.sh's push, which pulls and retries once when refused.
|
|
const pull = source.indexOf('"$REPO_DIR/build.sh" git-pull');
|
|
assert.ok(pull < source.indexOf('LATEST="$(bash "$REPO_DIR/releases/latest-release-version.sh")"'), 'pull before choosing the version');
|
|
assert.ok(pull < source.indexOf('sed "s|^# Upcoming WeKan'), 'pull before renaming Upcoming');
|
|
assert.ok(source.indexOf('"$REPO_DIR/build.sh" git-push') < source.indexOf('gh workflow run'), 'pushed before dispatching');
|
|
assert.doesNotMatch(source.replace(/^\s*#.*$/gm, '').replace(/echo "[^"\n]*"/g, ''), /^\s*git push\b/m, 'no bare git push left');
|
|
assert.match(fs.readFileSync(path.join(root, 'build.sh'), 'utf8'), /"Git and repo\|git pull[^"]*\|!git_pull\|\|\|git-pull"/);
|
|
assert.match(fs.readFileSync(path.join(root, 'build.sh'), 'utf8'), /"Git and repo\|git push[^"]*\|!git_push\|\|\|git-push"/);
|
|
assert.doesNotMatch(source, /NEW="\$\{RELEASED\[0\]/);
|
|
});
|