Skip to content

Commit 230a41f

Browse files
committed
Merge origin/master into renovate/js-yaml-5.x
2 parents 025d6d7 + 4c365da commit 230a41f

9 files changed

Lines changed: 212 additions & 131 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.idea/
22
/node_modules/
3+
/.bun/
34
/bin/
45
/ppa/
56
/dist/

bun.lock

Lines changed: 112 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,33 @@
2323
"typecheck": "tsc --noEmit",
2424
"fetch-schema": "curl https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json -sf > src/schema.json"
2525
},
26-
"dependencies": {
26+
"devDependencies": {
27+
"@eslint/js": "10.x",
28+
"@stylistic/eslint-plugin": "5.x",
29+
"@types/base64url": "2.x.x",
30+
"@types/bun": "1.x.x",
31+
"@types/checksum": "0.1.x",
32+
"@types/deep-extend": "0.6.x",
33+
"@types/fs-extra": "11.x.x",
34+
"@types/micromatch": "4.x.x",
35+
"@types/pretty-hrtime": "1.x.x",
36+
"@types/semver": "7.x.x",
37+
"@types/split2": "4.x.x",
38+
"@types/yargs": "17.x.x",
39+
"@vitest/coverage-v8": "^4.0.18",
2740
"ajv": "8.x.x",
2841
"axios": "1.x.x",
42+
"axios-mock-adapter": "2.x",
2943
"base64url": "3.x.x",
3044
"camelcase": "9.x.x",
31-
"chalk": "5.x.x",
45+
"chalk": "6.x",
3246
"chalk-template": "1.x.x",
3347
"checksum": "1.x.x",
3448
"deep-extend": "0.6.x",
49+
"depcheck": "1.x.x",
3550
"dotenv": "17.x",
36-
"execa": "5.x.x",
51+
"eslint": "10.x",
52+
"execa": "10.x",
3753
"fs-extra": "11.x.x",
3854
"globby": "16.x.x",
3955
"js-yaml": "5.x",
@@ -46,29 +62,10 @@
4662
"semver": "7.x.x",
4763
"split2": "4.x.x",
4864
"terminal-link": "5.x.x",
49-
"yargs": "18.x"
50-
},
51-
"devDependencies": {
52-
"@eslint/js": "10.x",
53-
"@stylistic/eslint-plugin": "5.x",
54-
"@types/base64url": "2.x.x",
55-
"@types/bun": "1.x.x",
56-
"@types/checksum": "0.1.x",
57-
"@types/deep-extend": "0.6.x",
58-
"@types/fs-extra": "11.x.x",
59-
"@types/js-yaml": "4.x.x",
60-
"@types/micromatch": "4.x.x",
61-
"@types/pretty-hrtime": "1.x.x",
62-
"@types/semver": "7.x.x",
63-
"@types/split2": "4.x.x",
64-
"@types/yargs": "17.x.x",
65-
"@vitest/coverage-v8": "^4.0.18",
66-
"axios-mock-adapter": "2.x",
67-
"depcheck": "1.x.x",
68-
"eslint": "10.x",
6965
"typescript": "6.x",
7066
"typescript-eslint": "8.x.x",
71-
"vitest": "^4.0.18"
67+
"vitest": "^4.0.18",
68+
"yargs": "18.x"
7269
},
7370
"repository": {
7471
"type": "git",
@@ -95,5 +92,8 @@
9592
"files": [
9693
"dist/index.js",
9794
"dist/index.js.map"
98-
]
95+
],
96+
"overrides": {
97+
"chalk": "$chalk"
98+
}
9999
}

src/argv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class Argv {
105105
}
106106

107107
private constructor (argv: any, writeStreams?: WriteStreams) {
108-
if (argv.noColor) {
108+
if (argv.noColor || argv.color === false || (process.env.NO_COLOR ?? "") !== "") {
109109
chalkBase.level = 0;
110110
}
111111
this.writeStreams = writeStreams;

src/job.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {GitData} from "./git-data.js";
99
import assert, {AssertionError} from "node:assert";
1010
import {Mutex} from "./mutex.js";
1111
import {Argv} from "./argv.js";
12-
import execa from "execa";
12+
import {execa} from "execa";
1313
import {CICDVariable} from "./variables-from-files.js";
1414
import {GitlabRunnerCPUsPresetValue, GitlabRunnerMemoryPresetValue, GitlabRunnerPresetValues} from "./gitlab-preset.js";
1515
import {handler} from "./handler.js";
@@ -932,10 +932,12 @@ If you know what you're doing and would like to suppress this warning, use one o
932932
shell: "bash",
933933
stdio: ["inherit", "inherit", "inherit"],
934934
env: {...expanded, ...process.env},
935+
reject: false,
935936
});
937+
const interactiveChildProcess = interactiveCp.nodeChildProcess;
936938
return new Promise<number>((resolve, reject) => {
937-
void interactiveCp.on("exit", (code) => resolve(code ?? 0));
938-
void interactiveCp.on("error", (err) => reject(err));
939+
interactiveChildProcess.on("exit", (code) => resolve(code ?? 0));
940+
interactiveChildProcess.on("error", (err) => reject(err));
939941
});
940942
}
941943

@@ -1143,7 +1145,9 @@ If you know what you're doing and would like to suppress this warning, use one o
11431145
cwd,
11441146
shell: "bash",
11451147
env: imageName ? process.env : expanded,
1148+
reject: false,
11461149
});
1150+
const childProcess = cp.nodeChildProcess;
11471151

11481152
// eslint-disable-next-line no-control-regex
11491153
const sectionRegex = /\x1b\[0Ksection_(start|end):(\d+):([^\s[]+)(?:\[[^\]]*\])?\r\x1b\[0K/;
@@ -1187,11 +1191,11 @@ If you know what you're doing and would like to suppress this warning, use one o
11871191
}
11881192
// Wait for "close" rather than "exit" so all stdout/stderr data events
11891193
// have flushed to the output log file before we resolve.
1190-
void cp.on("close", (code) => {
1194+
childProcess.on("close", (code) => {
11911195
clearTimeout(this._longRunningSilentTimeout);
11921196
return resolve(code ?? 0);},
11931197
);
1194-
void cp.on("error", (err) => {
1198+
childProcess.on("error", (err) => {
11951199
clearTimeout(this._longRunningSilentTimeout);
11961200
return reject(err);
11971201
});

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {needsComplex} from "./data-expander.js";
66
import fs from "fs-extra";
77
import checksum from "checksum";
88
import base64url from "base64url";
9-
import execa, {ExecaError} from "execa";
9+
import {execa, execaSync, ExecaError} from "execa";
1010
import assert from "node:assert";
1111
import {createHash} from "node:crypto";
1212
import {CICDVariable} from "./variables-from-files.js";
@@ -30,11 +30,11 @@ type ExpandWith = {
3030
};
3131

3232
export class Utils {
33-
static bashMulti (scripts: string[], cwd = process.cwd()): Promise<{stdout: string; stderr: string; exitCode: number}> {
33+
static bashMulti (scripts: string[], cwd = process.cwd()): Promise<{stdout: string; stderr: string; exitCode?: number}> {
3434
return execa(scripts.join(" && \\"), {shell: "bash", cwd});
3535
}
3636

37-
static bash (shellScript: string, cwd = process.cwd()): Promise<{stdout: string; stderr: string; exitCode: number}> {
37+
static bash (shellScript: string, cwd = process.cwd()): Promise<{stdout: string; stderr: string; exitCode?: number}> {
3838
return execa(shellScript, {shell: "bash", cwd});
3939
}
4040

@@ -43,7 +43,7 @@ export class Utils {
4343
}
4444

4545
static syncSpawn (cmdArgs: string[], cwd = process.cwd()): {stdout: string; stderr: string} {
46-
return execa.sync(cmdArgs[0], cmdArgs.slice(1), {cwd});
46+
return execaSync(cmdArgs[0], cmdArgs.slice(1), {cwd});
4747
}
4848

4949
static fsUrl (url: string): string {

tests/argv-color.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import "../src/global.js";
2+
import chalkBase, {type ColorSupportLevel} from "chalk";
3+
import {Argv} from "../src/argv.js";
4+
import {WriteStreamsMock} from "../src/write-streams.js";
5+
6+
let writeStreams: WriteStreamsMock;
7+
let originalLevel: ColorSupportLevel;
8+
let originalNoColor: string | undefined;
9+
10+
beforeEach(() => {
11+
writeStreams = new WriteStreamsMock();
12+
originalLevel = chalkBase.level;
13+
originalNoColor = process.env.NO_COLOR;
14+
});
15+
16+
afterEach(() => {
17+
chalkBase.level = originalLevel;
18+
if (originalNoColor === undefined) {
19+
delete process.env.NO_COLOR;
20+
} else {
21+
process.env.NO_COLOR = originalNoColor;
22+
}
23+
});
24+
25+
test("color stays enabled by default", async () => {
26+
chalkBase.level = 2;
27+
delete process.env.NO_COLOR;
28+
await Argv.build({}, writeStreams);
29+
expect(chalkBase.level).toBe(2);
30+
});
31+
32+
test("--no-color disables color", async () => {
33+
chalkBase.level = 2;
34+
delete process.env.NO_COLOR;
35+
await Argv.build({color: false}, writeStreams);
36+
expect(chalkBase.level).toBe(0);
37+
});
38+
39+
test("NO_COLOR disables color", async () => {
40+
chalkBase.level = 2;
41+
process.env.NO_COLOR = "1";
42+
await Argv.build({}, writeStreams);
43+
expect(chalkBase.level).toBe(0);
44+
});
45+
46+
test("an empty NO_COLOR leaves color enabled", async () => {
47+
chalkBase.level = 2;
48+
process.env.NO_COLOR = "";
49+
await Argv.build({}, writeStreams);
50+
expect(chalkBase.level).toBe(2);
51+
});

tests/test-cases/dependency-proxy/integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("dependency-proxy", () => {
7575
}, writeStreams);
7676
} catch (e: any) {
7777
// In ci environment, gitlab.com:443 is not authenticated, but at least this shows that we're pulling from the correct path
78-
expect(e.shortMessage).toEqual("Command failed with exit code 1: docker pull gitlab.com:443/gcl/dependency_proxy/containers/busybox:latest");
78+
expect(e.command).toEqual("docker pull gitlab.com:443/gcl/dependency_proxy/containers/busybox:latest");
7979
return;
8080
}
8181
throw new Error("Error is expected but not thrown/caught");

tests/test-cases/needs-parallel-matrix-artifacts/integration.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import fs from "fs-extra";
12
import {WriteStreamsMock} from "../../../src/write-streams.js";
23
import {handler} from "../../../src/handler.js";
34
import chalk from "chalk-template";
45

6+
const cwd = "tests/test-cases/needs-parallel-matrix-artifacts";
7+
8+
afterAll(async () => {
9+
await Promise.all(["aws", "gcp"].map(provider => fs.rm(`${cwd}/tag-${provider}.txt`, {force: true})));
10+
});
11+
512
test.concurrent("needs-parallel-matrix-artifacts cascades only the matching producer's artifacts to each consumer permutation", async () => {
613
const writeStreams = new WriteStreamsMock();
714
await handler({
8-
cwd: "tests/test-cases/needs-parallel-matrix-artifacts",
15+
cwd,
916
shellIsolation: true,
1017
stateDir: ".gitlab-ci-local-needs-parallel-matrix-artifacts",
1118
}, writeStreams);

0 commit comments

Comments
 (0)