Files
harbor-net/test/version-script.test.js
dokril 34d8b681ad
Build and Deploy Gateway / build-and-push (push) Failing after 2s
Build and Deploy Gateway / deploy (push) Has been skipped
Refactor VPN proxy client implementation
2026-08-09 00:41:52 +03:00

83 lines
3.1 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import {
affectedComponents,
bumpVersions,
parseVersion as parseToolVersion,
versionCompatibility as toolCompatibility,
versionsFromSource,
} from '../scripts/harbor-version.mjs';
import {
HARBOR_VERSIONS,
parseVersion as parseRuntimeVersion,
versionCompatibility as runtimeCompatibility,
} from '../dist/shared/versions.js';
const versions = {
macClient: '2.4.3',
gatewayClient: '2.7.1',
gatewayBackend: '2.7.8',
};
const versionScript = fs.readFileSync(
path.resolve(import.meta.dirname, '../scripts/harbor-version.mjs'),
'utf8',
);
test('version paths map to the components actually shipped by this repository', () => {
assert.match(versionScript, /git\(\['diff', '--no-renames', '--name-only'/);
assert.deepEqual(affectedComponents(['src/web/App.tsx']), ['macClient', 'gatewayClient']);
assert.deepEqual(affectedComponents(['vite.config.ts']), ['macClient', 'gatewayClient']);
assert.deepEqual(affectedComponents(['tsconfig.web.json']), ['macClient', 'gatewayClient']);
assert.deepEqual(affectedComponents(['src/server/index.ts']), ['macClient', 'gatewayBackend']);
assert.deepEqual(affectedComponents(['tsconfig.server.json']), ['macClient', 'gatewayBackend']);
assert.deepEqual(affectedComponents(['docker-compose.client.local.yml']), ['macClient']);
assert.deepEqual(affectedComponents(['install.sh']), ['macClient']);
assert.deepEqual(affectedComponents(['package-lock.json']), [
'macClient',
'gatewayClient',
'gatewayBackend',
]);
assert.deepEqual(affectedComponents(['package.json', 'tsconfig.base.json', '.dockerignore']), [
'macClient',
'gatewayClient',
'gatewayBackend',
]);
assert.deepEqual(affectedComponents(['scripts/runtime-impact.mjs']), ['gatewayBackend']);
assert.deepEqual(affectedComponents(['README.md', 'test/server/version.test.js']), []);
});
test('text-owned version tooling stays in parity with the compiled runtime contract', () => {
const source = fs.readFileSync(
path.resolve(import.meta.dirname, '../src/shared/versions.ts'),
'utf8',
);
assert.deepEqual(versionsFromSource(source), HARBOR_VERSIONS);
for (const value of ['0.21.20', '1.0.0', '', '1.2', '1.2.3.4']) {
assert.deepEqual(parseToolVersion(value), parseRuntimeVersion(value));
}
for (const sample of [versions, HARBOR_VERSIONS, { ...versions, gatewayBackend: '2.8.0' }]) {
assert.deepEqual(toolCompatibility(sample), runtimeCompatibility(sample));
}
});
test('version bumps follow ecosystem, linked-component and local scopes', () => {
assert.deepEqual(bumpVersions(versions, 'major'), {
macClient: '3.0.0',
gatewayClient: '3.0.0',
gatewayBackend: '3.0.0',
});
assert.deepEqual(bumpVersions(versions, 'minor', ['gateway-backend']), {
macClient: '2.4.3',
gatewayClient: '2.8.0',
gatewayBackend: '2.8.0',
});
assert.deepEqual(bumpVersions(versions, 'hotfix', ['mac']), {
macClient: '2.4.4',
gatewayClient: '2.7.1',
gatewayBackend: '2.7.8',
});
});