@ship.zone/runner 1.1.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.smartconfig.json +2 -1
- package/changelog.md +40 -0
- package/deno.json +13 -13
- package/deno.lock +227 -494
- package/dist_npm/mod.d.ts +3 -12
- package/dist_npm/mod.js +40 -64
- package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +5 -5
- package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +5 -5
- package/package.json +4 -3
- package/readme.md +14 -12
- package/rust/Cargo.lock +43 -0
- package/rust/Cargo.toml +3 -0
- package/rust/src/main.rs +4 -0
- package/third-party-licenses.md +92 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/cli.ts +2 -7
- package/ts/interfaces.ts +3 -3
- package/ts/oci-executor.ts +11 -10
- package/ts/plugins.ts +4 -4
- package/ts/protocol-validator.ts +5 -5
- package/ts/runner.ts +2 -39
- package/ts/spec-version.ts +0 -11
- package/ts/wire-schema.ts +8 -7
package/third-party-licenses.md
CHANGED
|
@@ -37,6 +37,8 @@ targets. They also include:
|
|
|
37
37
|
| serde | 1.0.229 | MIT |
|
|
38
38
|
| serde_core | 1.0.229 | MIT |
|
|
39
39
|
| serde_json | 1.0.151 | MIT |
|
|
40
|
+
| tikv-jemalloc-sys | 0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8 | MIT |
|
|
41
|
+
| tikv-jemallocator | 0.7.0 | MIT |
|
|
40
42
|
| zmij | 1.0.23 | MIT |
|
|
41
43
|
|
|
42
44
|
Upstream copyright notices supplied with these crates include:
|
|
@@ -93,3 +95,93 @@ OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWAR
|
|
|
93
95
|
Except as contained in this notice, the name of a copyright holder shall not be used in advertising
|
|
94
96
|
or otherwise to promote the sale, use or other dealings in these Data Files or Software without
|
|
95
97
|
prior written authorization of the copyright holder.
|
|
98
|
+
|
|
99
|
+
## Allocator Dependency Notices
|
|
100
|
+
|
|
101
|
+
The binary uses `tikv-jemallocator` 0.7.0 and `tikv-jemalloc-sys` 0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8 under their MIT license option. The latter compiles in jemalloc 5.3.1 under BSD-2-Clause. Their upstream license texts follow verbatim.
|
|
102
|
+
|
|
103
|
+
### tikv-jemallocator 0.7.0 — MIT
|
|
104
|
+
|
|
105
|
+
Copyright (c) 2014 Alex Crichton
|
|
106
|
+
|
|
107
|
+
Permission is hereby granted, free of charge, to any
|
|
108
|
+
person obtaining a copy of this software and associated
|
|
109
|
+
documentation files (the "Software"), to deal in the
|
|
110
|
+
Software without restriction, including without
|
|
111
|
+
limitation the rights to use, copy, modify, merge,
|
|
112
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
113
|
+
the Software, and to permit persons to whom the Software
|
|
114
|
+
is furnished to do so, subject to the following
|
|
115
|
+
conditions:
|
|
116
|
+
|
|
117
|
+
The above copyright notice and this permission notice
|
|
118
|
+
shall be included in all copies or substantial portions
|
|
119
|
+
of the Software.
|
|
120
|
+
|
|
121
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
122
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
123
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
124
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
125
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
126
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
127
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
128
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
129
|
+
DEALINGS IN THE SOFTWARE.
|
|
130
|
+
|
|
131
|
+
### tikv-jemalloc-sys 0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8 — MIT
|
|
132
|
+
|
|
133
|
+
Copyright (c) 2014 Alex Crichton
|
|
134
|
+
|
|
135
|
+
Permission is hereby granted, free of charge, to any
|
|
136
|
+
person obtaining a copy of this software and associated
|
|
137
|
+
documentation files (the "Software"), to deal in the
|
|
138
|
+
Software without restriction, including without
|
|
139
|
+
limitation the rights to use, copy, modify, merge,
|
|
140
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
141
|
+
the Software, and to permit persons to whom the Software
|
|
142
|
+
is furnished to do so, subject to the following
|
|
143
|
+
conditions:
|
|
144
|
+
|
|
145
|
+
The above copyright notice and this permission notice
|
|
146
|
+
shall be included in all copies or substantial portions
|
|
147
|
+
of the Software.
|
|
148
|
+
|
|
149
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
150
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
151
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
153
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
154
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
155
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
156
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
157
|
+
DEALINGS IN THE SOFTWARE.
|
|
158
|
+
|
|
159
|
+
### jemalloc 5.3.1 — BSD-2-Clause
|
|
160
|
+
|
|
161
|
+
Unless otherwise specified, files in the jemalloc source distribution are
|
|
162
|
+
subject to the following license:
|
|
163
|
+
--------------------------------------------------------------------------------
|
|
164
|
+
Copyright (C) 2002-present Jason Evans <jasone@canonware.com>.
|
|
165
|
+
All rights reserved.
|
|
166
|
+
Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
|
|
167
|
+
Copyright (C) 2009-present Facebook, Inc. All rights reserved.
|
|
168
|
+
|
|
169
|
+
Redistribution and use in source and binary forms, with or without
|
|
170
|
+
modification, are permitted provided that the following conditions are met:
|
|
171
|
+
1. Redistributions of source code must retain the above copyright notice(s),
|
|
172
|
+
this list of conditions and the following disclaimer.
|
|
173
|
+
2. Redistributions in binary form must reproduce the above copyright notice(s),
|
|
174
|
+
this list of conditions and the following disclaimer in the documentation
|
|
175
|
+
and/or other materials provided with the distribution.
|
|
176
|
+
|
|
177
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
|
|
178
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
179
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
180
|
+
EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
181
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
182
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
183
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
184
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
185
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
186
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
187
|
+
--------------------------------------------------------------------------------
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/cli.ts
CHANGED
|
@@ -19,12 +19,7 @@ import type {
|
|
|
19
19
|
import { runnerVersion } from './interfaces.ts';
|
|
20
20
|
import { OciExecutor } from './oci-executor.ts';
|
|
21
21
|
import { RegistrationStateStore } from './registration-state.ts';
|
|
22
|
-
import {
|
|
23
|
-
capabilitiesForCoordinator,
|
|
24
|
-
reconcileProtocolLimits,
|
|
25
|
-
runnerCapabilities,
|
|
26
|
-
ShipRunner,
|
|
27
|
-
} from './runner.ts';
|
|
22
|
+
import { reconcileProtocolLimits, runnerCapabilities, ShipRunner } from './runner.ts';
|
|
28
23
|
import { runnerSpecVersion } from './spec-version.ts';
|
|
29
24
|
import { SourceWorkspaceManager } from './source-workspace.ts';
|
|
30
25
|
|
|
@@ -156,7 +151,7 @@ const runRegister = async (options: Map<string, string | true>): Promise<void> =
|
|
|
156
151
|
const executor = new OciExecutor(config);
|
|
157
152
|
const runtime = await executor.verifyRuntime();
|
|
158
153
|
const discovery = await api.discover();
|
|
159
|
-
const capabilities =
|
|
154
|
+
const capabilities = runnerCapabilities(config, runtime);
|
|
160
155
|
reconcileProtocolLimits(config, discovery, capabilities);
|
|
161
156
|
const registered = await registerRunnerDurably({
|
|
162
157
|
configPath: path,
|
package/ts/interfaces.ts
CHANGED
|
@@ -90,11 +90,11 @@ export interface IRunnerCapabilities {
|
|
|
90
90
|
networks: TNetworkMode[];
|
|
91
91
|
sourceFormats: TSourceFormat[];
|
|
92
92
|
limits: ITransferLimits;
|
|
93
|
-
/**
|
|
93
|
+
/** The largest resource ceilings the runner enforces per attempt. */
|
|
94
94
|
resources?: IResourceLimits;
|
|
95
|
-
/**
|
|
95
|
+
/** The lease contents the runner uses. */
|
|
96
96
|
leaseFeatures?: TLeaseFeature[];
|
|
97
|
-
/**
|
|
97
|
+
/** The largest job `timeoutMs` the runner executes. */
|
|
98
98
|
maximumTimeoutMs?: number;
|
|
99
99
|
}
|
|
100
100
|
|
package/ts/oci-executor.ts
CHANGED
|
@@ -56,8 +56,8 @@ const maximumWorkspaceHelperErrorBytes = 512;
|
|
|
56
56
|
const hostTmpfsProbeMaximumAgeMs = 60 * 60 * 1000;
|
|
57
57
|
const runtimeProbeVolumeMaximumAgeMs = 60 * 60 * 1000;
|
|
58
58
|
const runtimeProbeOwnerIdPattern = /^[a-f0-9]{32}$/;
|
|
59
|
-
const hostTmpfsProbeNamePattern = /^
|
|
60
|
-
const runtimeProbeVolumeNamePattern = /^
|
|
59
|
+
const hostTmpfsProbeNamePattern = /^shipzone-ci-probe-([a-f0-9]{32})-[a-f0-9]{16}$/;
|
|
60
|
+
const runtimeProbeVolumeNamePattern = /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
61
61
|
const workspaceHelperDirectoryName = 'workspace-helpers';
|
|
62
62
|
const workspaceHelperLockName = '.workspace-helper.lock';
|
|
63
63
|
const runtimeProbeOwnerMarkerPrefix = '.runtime-probe-owner_';
|
|
@@ -573,8 +573,8 @@ const validateStepCommand = (command: string[]): void => {
|
|
|
573
573
|
|
|
574
574
|
const validateGeneratedName = (value: string, kind: 'container' | 'volume'): string => {
|
|
575
575
|
const pattern = kind === 'container'
|
|
576
|
-
? /^
|
|
577
|
-
: /^
|
|
576
|
+
? /^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/
|
|
577
|
+
: /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
578
578
|
if (!pattern.test(value)) throw new ProtocolError(`Runner generated an invalid OCI ${kind} name`);
|
|
579
579
|
return value;
|
|
580
580
|
};
|
|
@@ -839,8 +839,8 @@ const validateLeasePolicy = (
|
|
|
839
839
|
sessionId: context.sessionId,
|
|
840
840
|
lease: context.lease,
|
|
841
841
|
step,
|
|
842
|
-
containerName: `
|
|
843
|
-
volumeName: `
|
|
842
|
+
containerName: `shipzone-ci-step-${'0'.repeat(32)}`,
|
|
843
|
+
volumeName: `shipzone-ci-volume-${'0'.repeat(32)}`,
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
};
|
|
@@ -1387,7 +1387,8 @@ export class OciExecutor implements IJobExecutor {
|
|
|
1387
1387
|
for (const line of decode(containers.stdout).split('\n').filter(Boolean)) {
|
|
1388
1388
|
const [name, sessionId] = line.split('|', 2);
|
|
1389
1389
|
if (
|
|
1390
|
-
/^
|
|
1390
|
+
/^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/.test(name) &&
|
|
1391
|
+
sessionId !== currentSessionId
|
|
1391
1392
|
) {
|
|
1392
1393
|
await this.stopAndRemoveContainer(name);
|
|
1393
1394
|
}
|
|
@@ -1405,7 +1406,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
1405
1406
|
requireSuccess(volumes, 'Unable to enumerate orphan OCI volumes');
|
|
1406
1407
|
for (const line of decode(volumes.stdout).split('\n').filter(Boolean)) {
|
|
1407
1408
|
const [name, sessionId] = line.split('|', 2);
|
|
1408
|
-
if (/^
|
|
1409
|
+
if (/^shipzone-ci-volume-[a-f0-9]{32}$/.test(name) && sessionId !== currentSessionId) {
|
|
1409
1410
|
await this.removeVolume(name);
|
|
1410
1411
|
}
|
|
1411
1412
|
}
|
|
@@ -2315,7 +2316,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
2315
2316
|
await scavengeHostTmpfsProbes('/dev/shm', {}, runtimeProbeOwnerId);
|
|
2316
2317
|
path = await Deno.makeTempDir({
|
|
2317
2318
|
dir: '/dev/shm',
|
|
2318
|
-
prefix: `
|
|
2319
|
+
prefix: `shipzone-ci-probe-${runtimeProbeOwnerId}-`,
|
|
2319
2320
|
});
|
|
2320
2321
|
const before = await this.readFilesystemProbe(helperPath, path);
|
|
2321
2322
|
const first = join(path, 'first');
|
|
@@ -3117,7 +3118,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
3117
3118
|
}
|
|
3118
3119
|
|
|
3119
3120
|
private createResourceName(kind: 'helper' | 'probe' | 'step' | 'volume'): string {
|
|
3120
|
-
const name = `
|
|
3121
|
+
const name = `shipzone-ci-${kind}-${this.randomHex()}`;
|
|
3121
3122
|
return validateGeneratedName(name, kind === 'volume' ? 'volume' : 'container');
|
|
3122
3123
|
}
|
|
3123
3124
|
|
package/ts/plugins.ts
CHANGED
|
@@ -4,16 +4,16 @@ export {
|
|
|
4
4
|
executionProfileIdentifiers,
|
|
5
5
|
maximumArchivePathMetadataBytes,
|
|
6
6
|
runnerProtocolBasePath,
|
|
7
|
-
} from '@
|
|
7
|
+
} from '@ship.zone/ci-spec';
|
|
8
8
|
|
|
9
9
|
export const loadCiSpecArchiveCases = async (): Promise<unknown> =>
|
|
10
|
-
(await import('@
|
|
10
|
+
(await import('@ship.zone/ci-spec/archive-cases.json', { with: { type: 'json' } })).default;
|
|
11
11
|
|
|
12
12
|
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
13
13
|
export { Ajv2020 };
|
|
14
14
|
|
|
15
|
-
import runnerJobSchema from '@
|
|
15
|
+
import runnerJobSchema from '@ship.zone/ci-spec/runner-job.schema.json' with { type: 'json' };
|
|
16
16
|
export { runnerJobSchema };
|
|
17
17
|
|
|
18
|
-
import runnerOpenApi from '@
|
|
18
|
+
import runnerOpenApi from '@ship.zone/ci-spec/runner.openapi.json' with { type: 'json' };
|
|
19
19
|
export { runnerOpenApi };
|
package/ts/protocol-validator.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { isRecord } from './validation.ts';
|
|
|
17
17
|
import { validateCompiledJobSchema, validateWireMessage } from './wire-schema.ts';
|
|
18
18
|
|
|
19
19
|
const sha256Pattern = /^[a-f0-9]{64}$/;
|
|
20
|
-
const reservedEnvironmentNames = ['
|
|
20
|
+
const reservedEnvironmentNames = ['SHIPZONE_CI_INPUTS_JSON', 'SHIPZONE_CI_MATRIX_JSON'] as const;
|
|
21
21
|
const npmUserConfigEnvironmentName = 'NPM_CONFIG_USERCONFIG';
|
|
22
22
|
const maximumCommandArgumentBytes = 16 * 1024;
|
|
23
23
|
const maximumCommandBytes = 128 * 1024;
|
|
@@ -331,8 +331,8 @@ const requireExecutionCoherence = (job: TCompiledRunnerJob): void => {
|
|
|
331
331
|
const secretTargets = Object.keys(job.secrets);
|
|
332
332
|
const npmRead = job.npmRead !== undefined;
|
|
333
333
|
for (const secretName of secretTargets) {
|
|
334
|
-
if (secretName.startsWith('
|
|
335
|
-
throw new ProtocolError('Secret targets may not use reserved
|
|
334
|
+
if (secretName.startsWith('SHIPZONE_CI_')) {
|
|
335
|
+
throw new ProtocolError('Secret targets may not use reserved SHIPZONE_CI names');
|
|
336
336
|
}
|
|
337
337
|
if (npmRead && secretName === npmUserConfigEnvironmentName) {
|
|
338
338
|
throw new ProtocolError(`Secret targets may not use the reserved ${secretName}`);
|
|
@@ -357,11 +357,11 @@ const requireExecutionCoherence = (job: TCompiledRunnerJob): void => {
|
|
|
357
357
|
const environmentNames = Object.keys(step.environment);
|
|
358
358
|
for (const name of environmentNames) {
|
|
359
359
|
if (
|
|
360
|
-
name.startsWith('
|
|
360
|
+
name.startsWith('SHIPZONE_CI_') && !reservedEnvironmentNames.includes(
|
|
361
361
|
name as (typeof reservedEnvironmentNames)[number],
|
|
362
362
|
)
|
|
363
363
|
) {
|
|
364
|
-
throw new ProtocolError('Step environment uses an unknown reserved
|
|
364
|
+
throw new ProtocolError('Step environment uses an unknown reserved SHIPZONE_CI name');
|
|
365
365
|
}
|
|
366
366
|
if (npmRead && name === npmUserConfigEnvironmentName) {
|
|
367
367
|
throw new ProtocolError(`Step environment may not define the reserved ${name}`);
|
package/ts/runner.ts
CHANGED
|
@@ -45,12 +45,7 @@ import { runnerVersion } from './interfaces.ts';
|
|
|
45
45
|
import { LogSender } from './log-sender.ts';
|
|
46
46
|
import { createRunnerCapabilitySnapshot, RunnerProtocolValidator } from './protocol-validator.ts';
|
|
47
47
|
import { SecretRedactionSet } from './redactor.ts';
|
|
48
|
-
import {
|
|
49
|
-
compareSpecVersions,
|
|
50
|
-
lowerSpecVersion,
|
|
51
|
-
runnerSpecVersion,
|
|
52
|
-
specMajorVersionsMatch,
|
|
53
|
-
} from './spec-version.ts';
|
|
48
|
+
import { runnerSpecVersion, specMajorVersionsMatch } from './spec-version.ts';
|
|
54
49
|
import { scavengeRunnerStaging } from './staging-scavenger.ts';
|
|
55
50
|
|
|
56
51
|
export interface IRunnerCoordinatorClient {
|
|
@@ -209,14 +204,6 @@ class LeaseGuard {
|
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
206
|
|
|
212
|
-
/**
|
|
213
|
-
* The first specification versions that define the optional capabilities: `resources` from
|
|
214
|
-
* 1.1.0, `leaseFeatures` and `maximumTimeoutMs` from 1.2.0. These are fixed facts of the
|
|
215
|
-
* specification history, not the version this runner implements.
|
|
216
|
-
*/
|
|
217
|
-
const resourceLimitsSpecVersion = '1.1.0';
|
|
218
|
-
const leaseMatchingSpecVersion = '1.2.0';
|
|
219
|
-
|
|
220
207
|
/**
|
|
221
208
|
* The capabilities this runner advertises: the `oci` profile in `container` isolation on the
|
|
222
209
|
* native linux platform of its verified OCI engine, the `none` network mode, the configured
|
|
@@ -271,27 +258,6 @@ export const runnerCapabilities = (
|
|
|
271
258
|
});
|
|
272
259
|
};
|
|
273
260
|
|
|
274
|
-
/**
|
|
275
|
-
* Restricts capabilities to the constructs defined at the lower of the coordinator and runner
|
|
276
|
-
* specification versions, the version every non-job message may use.
|
|
277
|
-
*/
|
|
278
|
-
export const capabilitiesForCoordinator = (
|
|
279
|
-
capabilities: IRunnerCapabilities,
|
|
280
|
-
discovery: Pick<IDiscoveryResponse, 'spec'>,
|
|
281
|
-
): IRunnerCapabilities => {
|
|
282
|
-
const messageSpec = lowerSpecVersion(discovery.spec, runnerSpecVersion);
|
|
283
|
-
const defines = (since: string): boolean => compareSpecVersions(messageSpec, since) >= 0;
|
|
284
|
-
const { resources, leaseFeatures, maximumTimeoutMs, ...defined } = capabilities;
|
|
285
|
-
return createRunnerCapabilitySnapshot({
|
|
286
|
-
...defined,
|
|
287
|
-
...(resources !== undefined && defines(resourceLimitsSpecVersion) ? { resources } : {}),
|
|
288
|
-
...(leaseFeatures !== undefined && defines(leaseMatchingSpecVersion) ? { leaseFeatures } : {}),
|
|
289
|
-
...(maximumTimeoutMs !== undefined && defines(leaseMatchingSpecVersion)
|
|
290
|
-
? { maximumTimeoutMs }
|
|
291
|
-
: {}),
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
|
|
295
261
|
export const reconcileProtocolLimits = (
|
|
296
262
|
config: IRunnerConfig,
|
|
297
263
|
discovery: IDiscoveryResponse,
|
|
@@ -356,10 +322,7 @@ export class ShipRunner {
|
|
|
356
322
|
|
|
357
323
|
const runtime = await this.dependencies.executor.verifyRuntime();
|
|
358
324
|
const discovery = await this.dependencies.api.discover(options.signal);
|
|
359
|
-
const capabilities =
|
|
360
|
-
runnerCapabilities(this.config, runtime),
|
|
361
|
-
discovery,
|
|
362
|
-
);
|
|
325
|
+
const capabilities = runnerCapabilities(this.config, runtime);
|
|
363
326
|
reconcileProtocolLimits(this.config, discovery, capabilities);
|
|
364
327
|
const validator = new RunnerProtocolValidator(capabilities);
|
|
365
328
|
const session = await this.dependencies.api.startSession({
|
package/ts/spec-version.ts
CHANGED
|
@@ -53,14 +53,3 @@ export const acceptSpecVersion = (implemented: string, declared: unknown): TSpec
|
|
|
53
53
|
export const specMajorVersionsMatch = (left: string, right: string): boolean =>
|
|
54
54
|
requireCanonical(left, 'Specification version').major ===
|
|
55
55
|
requireCanonical(right, 'Specification version').major;
|
|
56
|
-
|
|
57
|
-
/** Compares two canonical specification versions numerically. */
|
|
58
|
-
export const compareSpecVersions = (left: string, right: string): number =>
|
|
59
|
-
compareParts(
|
|
60
|
-
requireCanonical(left, 'Specification version'),
|
|
61
|
-
requireCanonical(right, 'Specification version'),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
/** The lower of two canonical versions: the version whose constructs a message may use. */
|
|
65
|
-
export const lowerSpecVersion = (left: string, right: string): string =>
|
|
66
|
-
compareSpecVersions(left, right) <= 0 ? left : right;
|
package/ts/wire-schema.ts
CHANGED
|
@@ -39,12 +39,13 @@ export const isWireSchemaName = (value: unknown): value is TWireSchemaName =>
|
|
|
39
39
|
typeof value === 'string' && (wireSchemaNames as readonly string[]).includes(value);
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* The document identifiers of the runner protocol (Document Identifiers): the compiled job schema
|
|
43
|
+
* carries its identifier as `$id`, and the OpenAPI components are registered under the
|
|
44
|
+
* description's identifier, against which its `../schemas/runner-job.schema.json` references
|
|
45
|
+
* resolve to that `$id`.
|
|
45
46
|
*/
|
|
46
|
-
const openApiSchemaId = 'https://
|
|
47
|
-
const
|
|
47
|
+
const openApiSchemaId = 'https://ship.zone/spec/ci/spec/runner.openapi.json';
|
|
48
|
+
const runnerJobSchemaId = 'https://ship.zone/spec/ci/schemas/runner-job.schema.json';
|
|
48
49
|
|
|
49
50
|
const rewriteComponentReferences = (value: unknown): unknown => {
|
|
50
51
|
if (Array.isArray(value)) return value.map(rewriteComponentReferences);
|
|
@@ -73,7 +74,7 @@ const componentSchemas = (): unknown => {
|
|
|
73
74
|
|
|
74
75
|
const ajv = new plugins.Ajv2020({ allErrors: true, strict: true });
|
|
75
76
|
ajv.addFormat('date-time', { type: 'string', validate: isProtocolTimestamp });
|
|
76
|
-
ajv.addSchema(plugins.runnerJobSchema
|
|
77
|
+
ajv.addSchema(plugins.runnerJobSchema);
|
|
77
78
|
ajv.addSchema({
|
|
78
79
|
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
79
80
|
$id: openApiSchemaId,
|
|
@@ -134,4 +135,4 @@ export const validateWireMessage = <T>(name: TWireSchemaName, value: unknown): T
|
|
|
134
135
|
|
|
135
136
|
/** Validates a compiled runner job against the published runner job schema. */
|
|
136
137
|
export const validateCompiledJobSchema = <T>(value: unknown): T =>
|
|
137
|
-
assertValid<T>(validatorFor(
|
|
138
|
+
assertValid<T>(validatorFor(runnerJobSchemaId), value, 'Compiled runner job');
|