@norskvideo/ctl-test-harness 0.1.6 → 0.1.7
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/launch.d.ts +14 -0
- package/launch.js +32 -0
- package/package.json +5 -1
package/launch.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The `uid:gid` the current process runs as, for docker `--container-user`, or
|
|
2
|
+
* undefined where POSIX uids don't exist (e.g. Windows, or Docker Desktop's VM
|
|
3
|
+
* which maps bind-mount ownership itself and needs no explicit spec). */
|
|
4
|
+
export declare function runnerContainerUser(): string | undefined;
|
|
5
|
+
/** Default a launch's `containerUser` to the runner's uid:gid so bind-mounted
|
|
6
|
+
* writes are user-owned, not root. An explicit containerUser always wins, and a
|
|
7
|
+
* platform without POSIX uids is left untouched (returns opts unchanged). The
|
|
8
|
+
* intersection parameter lets T absorb the caller's own launch-opts shape
|
|
9
|
+
* without constraining it, so any launch options object passes through typed. */
|
|
10
|
+
export declare function withContainerUser<T>(opts: T & {
|
|
11
|
+
containerUser?: string;
|
|
12
|
+
}): T & {
|
|
13
|
+
containerUser?: string;
|
|
14
|
+
};
|
package/launch.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// A launched product instance bind-mounts host dirs into the Studio + media
|
|
2
|
+
// containers, which run as root by default -- so every file the container writes
|
|
3
|
+
// under the working directory lands root-owned on the host. On a CI runner the
|
|
4
|
+
// non-root user then cannot remove them, and the next checkout's `git clean`
|
|
5
|
+
// EACCESes on the leftover tree (worst on a shared runner pool, where an
|
|
6
|
+
// innocent sibling workflow inherits the mess). Launching the container as the
|
|
7
|
+
// runner's own uid:gid keeps those writes user-owned, so cleanup stays clean.
|
|
8
|
+
//
|
|
9
|
+
// This is the prevention half; @norskvideo/ctl-test-harness/daemon's
|
|
10
|
+
// cleanupDaemon is the tolerance half (root-nuke on teardown). Pairing the two
|
|
11
|
+
// is the harness's whole "launch clean, tear down clean" story.
|
|
12
|
+
/** The `uid:gid` the current process runs as, for docker `--container-user`, or
|
|
13
|
+
* undefined where POSIX uids don't exist (e.g. Windows, or Docker Desktop's VM
|
|
14
|
+
* which maps bind-mount ownership itself and needs no explicit spec). */
|
|
15
|
+
export function runnerContainerUser() {
|
|
16
|
+
const getuid = process.getuid?.bind(process);
|
|
17
|
+
const getgid = process.getgid?.bind(process);
|
|
18
|
+
if (!getuid || !getgid)
|
|
19
|
+
return undefined;
|
|
20
|
+
return `${getuid()}:${getgid()}`;
|
|
21
|
+
}
|
|
22
|
+
/** Default a launch's `containerUser` to the runner's uid:gid so bind-mounted
|
|
23
|
+
* writes are user-owned, not root. An explicit containerUser always wins, and a
|
|
24
|
+
* platform without POSIX uids is left untouched (returns opts unchanged). The
|
|
25
|
+
* intersection parameter lets T absorb the caller's own launch-opts shape
|
|
26
|
+
* without constraining it, so any launch options object passes through typed. */
|
|
27
|
+
export function withContainerUser(opts) {
|
|
28
|
+
if (opts.containerUser !== undefined)
|
|
29
|
+
return opts;
|
|
30
|
+
const user = runnerContainerUser();
|
|
31
|
+
return user === undefined ? opts : { ...opts, containerUser: user };
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norskvideo/ctl-test-harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./daemon": {
|
|
7
7
|
"types": "./daemon.d.ts",
|
|
8
8
|
"default": "./daemon.js"
|
|
9
9
|
},
|
|
10
|
+
"./launch": {
|
|
11
|
+
"types": "./launch.d.ts",
|
|
12
|
+
"default": "./launch.js"
|
|
13
|
+
},
|
|
10
14
|
"./source-pump": {
|
|
11
15
|
"types": "./source-pump.d.ts",
|
|
12
16
|
"default": "./source-pump.js"
|