@platforma-sdk/package-builder-lib 1.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/assets/conda-dockerfile.template +45 -0
- package/assets/python-dockerfile.template +22 -0
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/core/archive.cjs +52 -0
- package/dist/core/archive.cjs.map +1 -0
- package/dist/core/archive.js +47 -0
- package/dist/core/archive.js.map +1 -0
- package/dist/core/conda/builder.cjs +226 -0
- package/dist/core/conda/builder.cjs.map +1 -0
- package/dist/core/conda/builder.js +220 -0
- package/dist/core/conda/builder.js.map +1 -0
- package/dist/core/conda/validate-spec.cjs +76 -0
- package/dist/core/conda/validate-spec.cjs.map +1 -0
- package/dist/core/conda/validate-spec.js +73 -0
- package/dist/core/conda/validate-spec.js.map +1 -0
- package/dist/core/core.cjs +403 -0
- package/dist/core/core.cjs.map +1 -0
- package/dist/core/core.d.ts +82 -0
- package/dist/core/core.d.ts.map +1 -0
- package/dist/core/core.js +397 -0
- package/dist/core/core.js.map +1 -0
- package/dist/core/docker-conda.cjs +75 -0
- package/dist/core/docker-conda.cjs.map +1 -0
- package/dist/core/docker-conda.js +71 -0
- package/dist/core/docker-conda.js.map +1 -0
- package/dist/core/docker-python.cjs +147 -0
- package/dist/core/docker-python.cjs.map +1 -0
- package/dist/core/docker-python.js +144 -0
- package/dist/core/docker-python.js.map +1 -0
- package/dist/core/docker.cjs +223 -0
- package/dist/core/docker.cjs.map +1 -0
- package/dist/core/docker.js +207 -0
- package/dist/core/docker.js.map +1 -0
- package/dist/core/envs.cjs +58 -0
- package/dist/core/envs.cjs.map +1 -0
- package/dist/core/envs.d.ts +26 -0
- package/dist/core/envs.d.ts.map +1 -0
- package/dist/core/envs.js +51 -0
- package/dist/core/envs.js.map +1 -0
- package/dist/core/package-info.cjs +450 -0
- package/dist/core/package-info.cjs.map +1 -0
- package/dist/core/package-info.d.ts +57 -0
- package/dist/core/package-info.d.ts.map +1 -0
- package/dist/core/package-info.js +447 -0
- package/dist/core/package-info.js.map +1 -0
- package/dist/core/paths.cjs +15 -0
- package/dist/core/paths.cjs.map +1 -0
- package/dist/core/paths.js +14 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/resolver.cjs +99 -0
- package/dist/core/resolver.cjs.map +1 -0
- package/dist/core/resolver.js +95 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/schemas/artifacts.cjs +136 -0
- package/dist/core/schemas/artifacts.cjs.map +1 -0
- package/dist/core/schemas/artifacts.d.ts +280 -0
- package/dist/core/schemas/artifacts.d.ts.map +1 -0
- package/dist/core/schemas/artifacts.js +122 -0
- package/dist/core/schemas/artifacts.js.map +1 -0
- package/dist/core/schemas/entrypoints.cjs +43 -0
- package/dist/core/schemas/entrypoints.cjs.map +1 -0
- package/dist/core/schemas/entrypoints.d.ts +32 -0
- package/dist/core/schemas/entrypoints.d.ts.map +1 -0
- package/dist/core/schemas/entrypoints.js +41 -0
- package/dist/core/schemas/entrypoints.js.map +1 -0
- package/dist/core/schemas/sw-json.cjs +111 -0
- package/dist/core/schemas/sw-json.cjs.map +1 -0
- package/dist/core/schemas/sw-json.js +110 -0
- package/dist/core/schemas/sw-json.js.map +1 -0
- package/dist/core/storage.cjs +86 -0
- package/dist/core/storage.cjs.map +1 -0
- package/dist/core/storage.js +83 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/sw-json-render.cjs +327 -0
- package/dist/core/sw-json-render.cjs.map +1 -0
- package/dist/core/sw-json-render.js +322 -0
- package/dist/core/sw-json-render.js.map +1 -0
- package/dist/core/util.cjs +313 -0
- package/dist/core/util.cjs.map +1 -0
- package/dist/core/util.d.ts +66 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +281 -0
- package/dist/core/util.js.map +1 -0
- package/dist/defaults.cjs +54 -0
- package/dist/defaults.cjs.map +1 -0
- package/dist/defaults.d.ts +21 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +37 -0
- package/dist/defaults.js.map +1 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/__test__/Dockerfile +1 -0
- package/src/__test__/docker.test.ts +67 -0
- package/src/__test__/package.json +39 -0
- package/src/__test__/python-example/main.py +1 -0
- package/src/__test__/python-example/requirements.txt +0 -0
- package/src/__test__/vite.config.mts +7 -0
- package/src/core/__tests__/docker-conda.test.ts +145 -0
- package/src/core/__tests__/docker-entrypoint-generation.test.ts +119 -0
- package/src/core/__tests__/docker-python.test.ts +374 -0
- package/src/core/__tests__/publish-docker-images.test.ts +309 -0
- package/src/core/archive.ts +102 -0
- package/src/core/conda/builder.test.ts +71 -0
- package/src/core/conda/builder.ts +384 -0
- package/src/core/conda/validate-spec.test.ts +213 -0
- package/src/core/conda/validate-spec.ts +107 -0
- package/src/core/core.ts +835 -0
- package/src/core/docker-conda.ts +149 -0
- package/src/core/docker-python.ts +283 -0
- package/src/core/docker.ts +300 -0
- package/src/core/envs.ts +31 -0
- package/src/core/package-info.test.ts +82 -0
- package/src/core/package-info.ts +843 -0
- package/src/core/paths.ts +16 -0
- package/src/core/resolver.ts +195 -0
- package/src/core/schemas/artifacts.test.ts +72 -0
- package/src/core/schemas/artifacts.ts +279 -0
- package/src/core/schemas/entrypoints.test.ts +171 -0
- package/src/core/schemas/entrypoints.ts +150 -0
- package/src/core/schemas/sw-json.ts +216 -0
- package/src/core/schemas/test-artifacts.ts +362 -0
- package/src/core/storage.ts +125 -0
- package/src/core/sw-json-render.test.ts +215 -0
- package/src/core/sw-json-render.ts +682 -0
- package/src/core/util.ts +390 -0
- package/src/defaults.ts +38 -0
- package/src/index.ts +31 -0
- package/src/requirements.txt +1 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import * as defaults from "../defaults";
|
|
3
|
+
import type * as artifacts from "./schemas/artifacts";
|
|
4
|
+
import * as util from "./util";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import * as os from "node:os";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* To allow entrypoint keep both docker and binary package at the same time, we create virtual entrypoint with ':docker' suffix,
|
|
11
|
+
* as entrypoints could not keep two different artifacts at the same time.
|
|
12
|
+
*/
|
|
13
|
+
export function entrypointName(name: string): string {
|
|
14
|
+
return name + ":docker";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isVirtualDockerEntrypointName(name: string): boolean {
|
|
18
|
+
return name.endsWith(":docker");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function entrypointNameToOrigin(name: string): string {
|
|
22
|
+
if (!isVirtualDockerEntrypointName(name)) {
|
|
23
|
+
return name;
|
|
24
|
+
}
|
|
25
|
+
return name.substring(0, name.length - ":docker".length);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getImageHash(tag: string): string {
|
|
29
|
+
const result = spawnSync(
|
|
30
|
+
"docker",
|
|
31
|
+
["image", "ls", "--filter=reference=" + tag, "--format={{.ID}}"],
|
|
32
|
+
{
|
|
33
|
+
stdio: "pipe",
|
|
34
|
+
env: {
|
|
35
|
+
...process.env, // PATH variable from parent process affects execution
|
|
36
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (result.error) {
|
|
42
|
+
throw result.error;
|
|
43
|
+
}
|
|
44
|
+
if (result.status !== 0) {
|
|
45
|
+
throw util.CLIError(`local docker image check failed with status ${result.status}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const output = result.stdout.toString().trim();
|
|
49
|
+
if (output.split("\n").length > 1) {
|
|
50
|
+
throw util.CLIError(
|
|
51
|
+
`package-builder internal logic error: more than one image found by exact tag match: ${output}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return output;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getImageEntrypoint(tag: string): string[] {
|
|
59
|
+
const result = spawnSync(
|
|
60
|
+
"docker",
|
|
61
|
+
["image", "inspect", tag, "--format", "{{ .Config.Entrypoint | json }}"],
|
|
62
|
+
{
|
|
63
|
+
stdio: "pipe",
|
|
64
|
+
env: {
|
|
65
|
+
...process.env, // PATH variable from parent process affects execution
|
|
66
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (result.error) {
|
|
72
|
+
throw result.error;
|
|
73
|
+
}
|
|
74
|
+
if (result.status !== 0) {
|
|
75
|
+
throw util.CLIError(`'docker image inspect' failed with status ${result.status}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const output = result.stdout.toString().trim(); // 'null' or '[<string>, ...]' in JSON format
|
|
79
|
+
return (JSON.parse(output) ?? []) as string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function localImageExists(tag: string): boolean {
|
|
83
|
+
return getImageHash(tag) !== "";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function remoteImageExists(tag: string): boolean {
|
|
87
|
+
const result = spawnSync("docker", ["manifest", "inspect", tag], {
|
|
88
|
+
stdio: "pipe",
|
|
89
|
+
env: {
|
|
90
|
+
...process.env, // PATH variable from parent process affects execution
|
|
91
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (result.error || result.status !== 0) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function build(
|
|
103
|
+
context: string,
|
|
104
|
+
dockerfile: string,
|
|
105
|
+
tag: string,
|
|
106
|
+
softwarePackage: string,
|
|
107
|
+
softwareVersion: string | undefined,
|
|
108
|
+
) {
|
|
109
|
+
const result = spawnSync(
|
|
110
|
+
"docker",
|
|
111
|
+
[
|
|
112
|
+
"build",
|
|
113
|
+
// Pin platform so Platforma's linux/amd64 K8s nodes can run the image
|
|
114
|
+
// regardless of host arch (cross-compile via qemu on non-x64 hosts).
|
|
115
|
+
"--platform",
|
|
116
|
+
defaults.DOCKER_BUILD_PLATFORM,
|
|
117
|
+
// Disable buildkit's SLSA provenance + SBOM attestations. They embed
|
|
118
|
+
// build-time timestamps into the manifest list, which produces a fresh
|
|
119
|
+
// image digest on every build of identical source. That breaks the
|
|
120
|
+
// content-addressable tag scheme (every dev rebuild re-pushes a new
|
|
121
|
+
// tag) and defeats publishDockerImage's `remoteImageExists` smart-skip.
|
|
122
|
+
"--provenance=false",
|
|
123
|
+
"--sbom=false",
|
|
124
|
+
"-t",
|
|
125
|
+
tag,
|
|
126
|
+
context,
|
|
127
|
+
"-f",
|
|
128
|
+
dockerfile,
|
|
129
|
+
"--label",
|
|
130
|
+
"com.milaboratories.package-builder.software=true",
|
|
131
|
+
"--label",
|
|
132
|
+
"com.milaboratories.package-builder.software.package=" + softwarePackage,
|
|
133
|
+
"--label",
|
|
134
|
+
"com.milaboratories.package-builder.software.version=" + softwareVersion,
|
|
135
|
+
],
|
|
136
|
+
{
|
|
137
|
+
stdio: "inherit",
|
|
138
|
+
env: {
|
|
139
|
+
...process.env, // PATH variable from parent process affects execution
|
|
140
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
if (result.error) {
|
|
145
|
+
throw result.error;
|
|
146
|
+
}
|
|
147
|
+
if (result.status !== 0) {
|
|
148
|
+
throw util.CLIError(`'docker build' failed with status ${result.status}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function push(tag: string) {
|
|
153
|
+
const result = spawnSync("docker", ["push", tag], {
|
|
154
|
+
stdio: "inherit",
|
|
155
|
+
env: {
|
|
156
|
+
...process.env, // PATH variable from parent process affects execution
|
|
157
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
if (result.error) {
|
|
161
|
+
throw result.error;
|
|
162
|
+
}
|
|
163
|
+
if (result.status !== 0) {
|
|
164
|
+
const registry = tag.split("/")[0];
|
|
165
|
+
throw util.CLIError(
|
|
166
|
+
`'docker push ${tag}' failed with status ${result.status}.\n` +
|
|
167
|
+
`If the error above mentions authentication or denied access, log in first:\n` +
|
|
168
|
+
` aws sso login --profile research-poweruser <YOUR_PROFILE:research-poweruser?> \n` +
|
|
169
|
+
`Then login in docker:` +
|
|
170
|
+
` aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${registry}\n` +
|
|
171
|
+
`(for a private ECR use 'aws ecr' and your region instead of 'ecr-public'/us-east-1).`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function addTag(imageIdOrTag: string, newTag: string) {
|
|
177
|
+
const result = spawnSync("docker", ["image", "tag", imageIdOrTag, newTag], {
|
|
178
|
+
stdio: "inherit",
|
|
179
|
+
env: {
|
|
180
|
+
...process.env, // PATH variable from parent process affects execution
|
|
181
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
if (result.error) {
|
|
185
|
+
throw result.error;
|
|
186
|
+
}
|
|
187
|
+
if (result.status !== 0) {
|
|
188
|
+
throw util.CLIError(`'docker tag' failed with status ${result.status}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function removeTag(imageTag: string) {
|
|
193
|
+
const result = spawnSync("docker", ["image", "rm", imageTag], {
|
|
194
|
+
stdio: "inherit",
|
|
195
|
+
env: {
|
|
196
|
+
...process.env, // PATH variable from parent process affects execution
|
|
197
|
+
HOME: process.env.HOME || os.homedir(), // Ensure HOME is set
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
if (result.error) {
|
|
201
|
+
throw result.error;
|
|
202
|
+
}
|
|
203
|
+
if (result.status !== 0) {
|
|
204
|
+
throw util.CLIError(`'docker image rm' failed with status ${result.status}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Generate unique content-addressable image tag
|
|
210
|
+
* @param artifactName: artifact name generated from package name and artifact ID (or explicitly set for artifact in .name field)
|
|
211
|
+
* @param imageID: unique image content hash (docker image ID in docker ls)
|
|
212
|
+
* @param registry: custom registry and repository to use for this image
|
|
213
|
+
* @returns full image tag in format: <registry>/repository:<artifactName>.<imageID>
|
|
214
|
+
*/
|
|
215
|
+
export function generateRemoteTagName(
|
|
216
|
+
artifactName: string,
|
|
217
|
+
imageID: string,
|
|
218
|
+
registry?: string,
|
|
219
|
+
): string {
|
|
220
|
+
return dockerTag(artifactName, imageID, registry);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Generate unique content-addressable image tag out of directories and Dockerfile.
|
|
225
|
+
* @param packageRoot: package root path from where to resolve artifact's paths (context, Dockerfile, ...)
|
|
226
|
+
* @param artifact: docker artifact configuration
|
|
227
|
+
* @returns full image tag in format: <registry>/repository:<artifactName>.<contentHash>
|
|
228
|
+
*/
|
|
229
|
+
export function generateLocalTagName(packageRoot: string, artifact: artifacts.dockerType): string {
|
|
230
|
+
const dockerfile = dockerfileAbsPath(packageRoot, artifact);
|
|
231
|
+
const context = contextAbsPath(packageRoot, artifact);
|
|
232
|
+
const hash = contentHash(context, dockerfile);
|
|
233
|
+
|
|
234
|
+
return dockerTag("local-image", hash);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Absolute path to autogenerated Dockerfile for given artifact.
|
|
239
|
+
* @param packageRoot: package root path from where to resolve artifact's paths (context, Dockerfile, ...)
|
|
240
|
+
* @param artifactID: artifact ID
|
|
241
|
+
* @returns absolute path to autogenerated Dockerfile
|
|
242
|
+
*/
|
|
243
|
+
export function dockerfileAutogenPath(packageRoot: string, artifactID: string): string {
|
|
244
|
+
return path.resolve(packageRoot, "dist", "docker", `Dockerfile-${artifactID}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Resolve path to Dockerfile.
|
|
249
|
+
* @param packageRoot: package root path from where to resolve artifact's paths (context, Dockerfile, ...)
|
|
250
|
+
* @param artifact: docker artifact configuration
|
|
251
|
+
* @returns absolute path to Dockerfile
|
|
252
|
+
*/
|
|
253
|
+
function dockerfileAbsPath(packageRoot: string, artifact: artifacts.dockerType): string {
|
|
254
|
+
return path.resolve(packageRoot, artifact.dockerfile ?? "Dockerfile");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Resolve path to docker build context directory.
|
|
259
|
+
* @param packageRoot: package root path from where to resolve artifact's paths (context, Dockerfile, ...)
|
|
260
|
+
* @param artifact: docker artifact configuration
|
|
261
|
+
* @returns absolute path to docker build context directory
|
|
262
|
+
*/
|
|
263
|
+
function contextAbsPath(packageRoot: string, artifact: artifacts.dockerType): string {
|
|
264
|
+
if (artifact.context === "./" || artifact.context === ".") {
|
|
265
|
+
throw util.CLIError(
|
|
266
|
+
`Invalid Docker context: "${artifact.context}". Context cannot be "./" or "." - use absolute path or relative path without "./" prefix`,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return path.resolve(packageRoot, artifact.context ?? ".");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Calculate cummulative hash of docker build context directory context and Dockerfile.
|
|
274
|
+
* To speedup hash calculation, we do not read contents of each item in context dir but
|
|
275
|
+
* use metadata (size, mtime, ...).
|
|
276
|
+
*
|
|
277
|
+
* @param contextFullPath: abs path to docker build context
|
|
278
|
+
* @param dockerfileFullPath: abs path to Dockerfile
|
|
279
|
+
* @returns hash of what the keep
|
|
280
|
+
*/
|
|
281
|
+
function contentHash(contextFullPath: string, dockerfileFullPath: string): string {
|
|
282
|
+
if (!fs.existsSync(dockerfileFullPath)) {
|
|
283
|
+
throw util.CLIError(`Dockerfile '${dockerfileFullPath}' not found`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (!fs.existsSync(contextFullPath)) {
|
|
287
|
+
throw util.CLIError(`Context '${contextFullPath}' not found`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const contextHash = util.hashDirMetaSync(contextFullPath);
|
|
291
|
+
const dockerfileContent = fs.readFileSync(dockerfileFullPath, "utf8");
|
|
292
|
+
contextHash.update(dockerfileContent);
|
|
293
|
+
|
|
294
|
+
return contextHash.digest("hex").slice(0, 12);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function dockerTag(packageName: string, contentHash: string, registry?: string): string {
|
|
298
|
+
const dockerRegistry = registry ?? defaults.DOCKER_REGISTRY;
|
|
299
|
+
return `${dockerRegistry}:${packageName.replaceAll("/", ".")}.${contentHash}`;
|
|
300
|
+
}
|
package/src/core/envs.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const PL_PKG_VERSION = "PL_PKG_VERSION";
|
|
2
|
+
export const PL_PKG_OS = "PL_PKG_OS";
|
|
3
|
+
export const PL_PKG_ARCH = "PL_PKG_ARCH";
|
|
4
|
+
|
|
5
|
+
export const PL_PKG_CONTENT_ROOT = "PL_PKG_CONTENT_ROOT";
|
|
6
|
+
export const PL_PKG_ARCHIVE = "PL_PKG_ARCHIVE";
|
|
7
|
+
export const PL_PKG_STORAGE_URL = "PL_PKG_STORAGE_URL";
|
|
8
|
+
|
|
9
|
+
export const PL_PKG_DEV = "PL_PKG_DEV";
|
|
10
|
+
export const PL_PKG_FULL_HASH = "PL_PKG_FULL_HASH";
|
|
11
|
+
|
|
12
|
+
export const PL_CONDA_BUILD = "PL_CONDA_BUILD";
|
|
13
|
+
export const PL_CONDA_NO_BUILD = "PL_CONDA_NO_BUILD";
|
|
14
|
+
|
|
15
|
+
export const PL_DOCKER_REGISTRY = "PL_DOCKER_REGISTRY";
|
|
16
|
+
export const PL_DOCKER_REGISTRY_PUSH_TO = "PL_DOCKER_REGISTRY_PUSH_TO";
|
|
17
|
+
|
|
18
|
+
export const PL_DOCKER_BUILD = "PL_DOCKER_BUILD";
|
|
19
|
+
export const PL_DOCKER_NO_BUILD = "PL_DOCKER_NO_BUILD";
|
|
20
|
+
export const PL_DOCKER_AUTOPUSH = "PL_DOCKER_AUTOPUSH";
|
|
21
|
+
export const PL_DOCKER_NO_AUTOPUSH = "PL_DOCKER_NO_AUTOPUSH";
|
|
22
|
+
|
|
23
|
+
export const CI = "CI";
|
|
24
|
+
export const RUNNER_DEBUG = "RUNNER_DEBUG";
|
|
25
|
+
|
|
26
|
+
export function isCI(): boolean {
|
|
27
|
+
return process.env[CI] === "true";
|
|
28
|
+
}
|
|
29
|
+
export function isRunnerDebug(): boolean {
|
|
30
|
+
return process.env[RUNNER_DEBUG] === "true" || process.env[RUNNER_DEBUG] === "1";
|
|
31
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PackageInfo } from "./package-info";
|
|
2
|
+
import * as testArtifacts from "./schemas/test-artifacts";
|
|
3
|
+
import { createLogger } from "./util";
|
|
4
|
+
import { test, expect } from "vitest";
|
|
5
|
+
|
|
6
|
+
test("PackageInfo loads correctly for single binary package", () => {
|
|
7
|
+
const l = createLogger("error");
|
|
8
|
+
|
|
9
|
+
const i = new PackageInfo(l, {
|
|
10
|
+
pkgJsonData: testArtifacts.SingleBinaryackageJson,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const binary = i.getArtifact(testArtifacts.EPNameBinary, "binary");
|
|
14
|
+
expect(i.artifactName(binary)).toEqual(
|
|
15
|
+
testArtifacts.PackageNameNoAt + "/" + testArtifacts.EPNameBinary,
|
|
16
|
+
);
|
|
17
|
+
expect(i.artifactVersion(binary)).toEqual(testArtifacts.PackageVersion);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("PackageInfo loads correctly for multi-package", () => {
|
|
21
|
+
const l = createLogger("error");
|
|
22
|
+
|
|
23
|
+
const i = new PackageInfo(l, {
|
|
24
|
+
pkgJsonData: testArtifacts.PackageJson,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const asset = i.getArtifact(testArtifacts.EPNameAsset, "asset");
|
|
28
|
+
let registry = i.artifactRegistrySettings(asset);
|
|
29
|
+
expect(registry.name).toEqual(testArtifacts.BinaryRegistry);
|
|
30
|
+
expect(i.artifactName(asset)).toEqual(testArtifacts.PackageNameNoAt + "/pAsset");
|
|
31
|
+
expect(i.artifactVersion(asset)).toEqual(testArtifacts.PackageVersion);
|
|
32
|
+
expect(asset.root).toEqual("./src");
|
|
33
|
+
|
|
34
|
+
const binary = i.getArtifact(testArtifacts.EPNameCustomName, "binary");
|
|
35
|
+
registry = i.artifactRegistrySettings(binary);
|
|
36
|
+
expect(registry.name).toEqual(testArtifacts.BinaryRegistry);
|
|
37
|
+
expect(i.artifactName(binary)).toEqual(testArtifacts.BinaryCustomName1);
|
|
38
|
+
expect(i.artifactVersion(binary)).toEqual(testArtifacts.BinaryCustomVersion);
|
|
39
|
+
|
|
40
|
+
const environment = i.getArtifact(testArtifacts.EPNameJavaEnvironment, "environment");
|
|
41
|
+
registry = i.artifactRegistrySettings(environment);
|
|
42
|
+
expect(registry.name).toEqual(testArtifacts.BinaryRegistry);
|
|
43
|
+
expect(i.artifactName(environment)).toEqual(
|
|
44
|
+
testArtifacts.PackageNameNoAt + "/" + testArtifacts.EPNameJavaEnvironment,
|
|
45
|
+
);
|
|
46
|
+
expect(i.artifactVersion(environment)).toEqual(testArtifacts.PackageVersion);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("Limited list of supported platforms", () => {
|
|
50
|
+
const l = createLogger("error");
|
|
51
|
+
|
|
52
|
+
const i = new PackageInfo(l, {
|
|
53
|
+
pkgJsonData: testArtifacts.PackageJson,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const binary = i.getArtifact(testArtifacts.EPNameLimitedPlatformsBinary, "binary");
|
|
57
|
+
const platforms = i.artifactPlatforms(binary);
|
|
58
|
+
expect(platforms).toEqual(["linux-x64", "macosx-aarch64"]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("PackageInfo considers version override", () => {
|
|
62
|
+
const l = createLogger("error");
|
|
63
|
+
|
|
64
|
+
const i = new PackageInfo(l, {
|
|
65
|
+
pkgJsonData: testArtifacts.PackageJson,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const customVersion = "my-custom-version";
|
|
69
|
+
i.version = customVersion;
|
|
70
|
+
|
|
71
|
+
const asset = i.getArtifact("pAsset", "asset");
|
|
72
|
+
expect(i.artifactVersion(asset)).toEqual(customVersion);
|
|
73
|
+
|
|
74
|
+
const binary = i.getArtifact(testArtifacts.EPNameCustomName, "binary");
|
|
75
|
+
expect(i.artifactVersion(binary)).toEqual(customVersion);
|
|
76
|
+
|
|
77
|
+
const environment = i.getArtifact(testArtifacts.EPNameJavaEnvironment, "environment");
|
|
78
|
+
expect(i.artifactVersion(environment)).toEqual(customVersion);
|
|
79
|
+
|
|
80
|
+
const java = i.getArtifact(testArtifacts.EPNameJava, "java");
|
|
81
|
+
expect(i.artifactVersion(java)).toEqual(customVersion);
|
|
82
|
+
});
|