mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 20:45:07 -05:00
releases/release-all.sh stopped when the Upcoming section had no entries, no **In short:** summary, or a Translations group without its **Languages updated:** line, and releases/release-notes.sh failed on the same in the workflow. Now only the "# Upcoming WeKan ® release" heading is required - it is what becomes the new version. A missing part is a warning, and the release notes leave it out: no In short section without a summary, no language list without one (the translators are still thanked), and an empty section still gets the thanks and the ChangeLog link. Thanks to xet7 !
81 lines
4.3 KiB
JavaScript
81 lines
4.3 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', 'bash "$(dirname "$0")/fix-changelog-hashes.sh"',
|
|
'if [ -n "${1:-}" ]', 'git add --all', '\n git push', 'gh workflow run']) {
|
|
assert.ok(source.indexOf(later) > guard, `${later} must follow successful preflight`);
|
|
}
|
|
assert.doesNotMatch(source, /NEW="\$\{RELEASED\[0\]/);
|
|
});
|