mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Import -> GitHub -> Import a whole GitHub organization makes every repository of an organization or user its own board, opening in Board View / Version Control. Issues go through the ordinary importBoard, as the person who started the job, with their comments, labels and files. Releases are cards in a Releases list, their files attached only when chosen. Each .github/workflows file becomes Rules. The wiki is read from its git repository with isomorphic-git (1.42.4, pinned), every request through the SSRF guard and only to github.com: a page is a card in the Wiki list, its [[links]] point at and are attached to the linked pages' cards, and each commit that changed it is a dated edit in the card's history, so Restore brings back an older version. The job shows progress, can be cancelled, pauses on a restart and stops at a rate limit; the token is kept in memory only. Version Control gains Releases and Wiki tabs: the wiki as GitHub shows it, with the page list, _Sidebar and _Footer, links that stay in the tab, and each page's history with Restore. GitHub Actions workflows map to Rules: issue events to triggers, label, close, reopen, comment, assign and create steps to actions, actions/stale to an aging rule. Code - builds, tests, scripts - is never run: such a workflow is a disabled rule with its YAML as the description. WeKan's Rules gain what they lacked for it: a "commented on" trigger, an "add comment" action written as the person whose change ran the rule and only where they may comment, cron schedules in UTC, and a rule description shown on the rule. A disabled rule no longer fires on a schedule or from its button, which it did. The new strings are translated in every locale. Thanks to xet7 !
43 lines
1.9 KiB
JavaScript
43 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
// Guard: cron schedules for rules (models/lib/cronSchedule.js) - an imported
|
|
// GitHub Actions `schedule:` keeps its exact times.
|
|
// Run: node tests/cronSchedule.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const c = require('../models/lib/cronSchedule.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(`ok - ${name}`); }
|
|
const at = s => new Date(`${s}Z`);
|
|
|
|
test('fields, ranges, lists, steps and names (UTC)', () => {
|
|
assert.ok(c.cronMatches('30 5 * * 1-5', at('2026-10-14T05:30:00')), 'Wednesday 05:30');
|
|
assert.ok(!c.cronMatches('30 5 * * 1-5', at('2026-10-18T05:30:00')), 'not Sunday');
|
|
assert.ok(c.cronMatches('*/15 * * * *', at('2026-10-14T11:45:00')));
|
|
assert.ok(!c.cronMatches('*/15 * * * *', at('2026-10-14T11:46:00')));
|
|
assert.ok(c.cronMatches('0 0 1,15 * *', at('2026-10-15T00:00:00')));
|
|
assert.ok(c.cronMatches('0 12 * JAN-MAR MON', at('2026-02-02T12:00:00')));
|
|
assert.ok(c.cronMatches('0 0 * * 7', at('2026-10-18T00:00:00')), '7 is Sunday too');
|
|
});
|
|
|
|
test('both day fields restricted: either matches, as in cron', () => {
|
|
assert.ok(c.cronMatches('0 9 1 * MON', at('2026-10-01T09:00:00')), 'the 1st (a Thursday)');
|
|
assert.ok(c.cronMatches('0 9 1 * MON', at('2026-10-05T09:00:00')), 'a Monday');
|
|
assert.ok(!c.cronMatches('0 9 1 * MON', at('2026-10-06T09:00:00')));
|
|
});
|
|
|
|
test('next run', () => {
|
|
assert.deepStrictEqual(c.nextCronRun('0 3 * * *', at('2026-10-14T05:00:00')), at('2026-10-15T03:00:00'));
|
|
assert.strictEqual(c.nextCronRun('0 0 30 2 *', at('2026-01-01T00:00:00')), null, 'February 30th never comes');
|
|
});
|
|
|
|
test('negative: wrong field count, out of range, backwards, bad step, words', () => {
|
|
for (const bad of ['* * * *', '60 * * * *', '* 24 * * *', '* * 0 * *', '* * * 13 *', '5-1 * * * *', '*/0 * * * *', 'every day']) {
|
|
assert.throws(() => c.parseCron(bad), c.CronError, bad);
|
|
assert.strictEqual(c.isValidCron(bad), false);
|
|
}
|
|
});
|
|
|
|
console.log(`# ${passed} passed`);
|