@argos-ci/core 6.8.3 → 6.8.5
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/dist/index.mjs +55 -26
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,24 @@ import tmp from "tmp";
|
|
|
17
17
|
//#region src/debug.ts
|
|
18
18
|
const KEY = "@argos-ci/core";
|
|
19
19
|
const debug = createDebug(KEY);
|
|
20
|
+
/**
|
|
21
|
+
* Leading characters of a token kept in the debug output: enough to tell two
|
|
22
|
+
* tokens apart, far too few to use.
|
|
23
|
+
*/
|
|
24
|
+
const TOKEN_PREVIEW_LENGTH = 6;
|
|
25
|
+
/**
|
|
26
|
+
* Show which token is in play without publishing it.
|
|
27
|
+
*
|
|
28
|
+
* Debug output is the documented way to report an upload problem: it gets
|
|
29
|
+
* pasted into public issues and written to CI logs, which are world-readable on
|
|
30
|
+
* public repositories, so a token printed in full is a published token
|
|
31
|
+
* (GHSA-28pg-v3hp-9g7f). The first few characters answer "is that the token I
|
|
32
|
+
* think it is?" and are useless to anyone else.
|
|
33
|
+
*/
|
|
34
|
+
function maskToken(token) {
|
|
35
|
+
if (!token) return token;
|
|
36
|
+
return `${token.slice(0, TOKEN_PREVIEW_LENGTH)}…`;
|
|
37
|
+
}
|
|
20
38
|
const isDebugEnabled = createDebug.enabled(KEY);
|
|
21
39
|
const debugTime = (arg) => {
|
|
22
40
|
if (isDebugEnabled) console.time(arg);
|
|
@@ -76,6 +94,7 @@ function gitMergeBase(input) {
|
|
|
76
94
|
try {
|
|
77
95
|
return execFileSync("git", [
|
|
78
96
|
"merge-base",
|
|
97
|
+
"--end-of-options",
|
|
79
98
|
input.head,
|
|
80
99
|
input.base
|
|
81
100
|
]).toString().trim();
|
|
@@ -103,14 +122,20 @@ function checkIsGitLockError(error) {
|
|
|
103
122
|
return output.includes(".lock': File exists") || output.includes("Another git process seems to be running");
|
|
104
123
|
}
|
|
105
124
|
/**
|
|
106
|
-
* Run `git fetch` with the given
|
|
125
|
+
* Run `git fetch` from origin with the given options and refs (or refspecs).
|
|
107
126
|
*
|
|
108
127
|
* Retries on lock contention (`.git/shallow.lock` "File exists") with an
|
|
109
128
|
* exponential backoff, since this is usually a transient conflict with another
|
|
110
129
|
* git process and resolves once that process releases the lock.
|
|
111
130
|
*/
|
|
112
|
-
function runGitFetch(
|
|
113
|
-
return pRetry(() => execFileAsync("git", [
|
|
131
|
+
function runGitFetch(input) {
|
|
132
|
+
return pRetry(() => execFileAsync("git", [
|
|
133
|
+
"fetch",
|
|
134
|
+
...input.options,
|
|
135
|
+
"--end-of-options",
|
|
136
|
+
"origin",
|
|
137
|
+
...input.refs
|
|
138
|
+
]), {
|
|
114
139
|
retries: 3,
|
|
115
140
|
minTimeout: 500,
|
|
116
141
|
shouldRetry: ({ error }) => checkIsGitLockError(error),
|
|
@@ -123,14 +148,15 @@ function runGitFetch(args) {
|
|
|
123
148
|
* Run git fetch with a specific ref and depth.
|
|
124
149
|
*/
|
|
125
150
|
async function gitFetch(input) {
|
|
126
|
-
await runGitFetch(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
await runGitFetch({
|
|
152
|
+
options: [
|
|
153
|
+
"--force",
|
|
154
|
+
"--update-head-ok",
|
|
155
|
+
"--depth",
|
|
156
|
+
String(input.depth)
|
|
157
|
+
],
|
|
158
|
+
refs: [`${input.ref}:${input.target}`]
|
|
159
|
+
});
|
|
134
160
|
}
|
|
135
161
|
/**
|
|
136
162
|
* Check if an error is an exec error that includes stderr.
|
|
@@ -154,6 +180,7 @@ function checkLocalRefExists(ref) {
|
|
|
154
180
|
"rev-parse",
|
|
155
181
|
"--verify",
|
|
156
182
|
"--quiet",
|
|
183
|
+
"--end-of-options",
|
|
157
184
|
`${ref}^{commit}`
|
|
158
185
|
]);
|
|
159
186
|
return true;
|
|
@@ -241,7 +268,7 @@ async function getMergeBaseCommitSha$2(input) {
|
|
|
241
268
|
function listShas(path, maxCount) {
|
|
242
269
|
const args = ["log", "--format=%H"];
|
|
243
270
|
if (maxCount) args.push(`--max-count=${maxCount}`);
|
|
244
|
-
args.push(path);
|
|
271
|
+
args.push("--end-of-options", path);
|
|
245
272
|
return execFileSync("git", args).toString().trim().split("\n");
|
|
246
273
|
}
|
|
247
274
|
/**
|
|
@@ -256,11 +283,10 @@ function listShas(path, maxCount) {
|
|
|
256
283
|
async function listAncestorCommits$1(input) {
|
|
257
284
|
const depth = input.limit + 1;
|
|
258
285
|
try {
|
|
259
|
-
await runGitFetch(
|
|
260
|
-
`--depth=${depth}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
]);
|
|
286
|
+
await runGitFetch({
|
|
287
|
+
options: [`--depth=${depth}`],
|
|
288
|
+
refs: [input.sha]
|
|
289
|
+
});
|
|
264
290
|
} catch (error) {
|
|
265
291
|
debug(`Failed to deepen history for ${input.sha}, using local history`, getGitErrorOutput(error));
|
|
266
292
|
}
|
|
@@ -284,11 +310,10 @@ async function getCommitParents(sha) {
|
|
|
284
310
|
const localParents = readCommitParents(sha);
|
|
285
311
|
if (localParents?.length) return localParents;
|
|
286
312
|
try {
|
|
287
|
-
await runGitFetch(
|
|
288
|
-
"--depth=2",
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
]);
|
|
313
|
+
await runGitFetch({
|
|
314
|
+
options: ["--depth=2"],
|
|
315
|
+
refs: [sha]
|
|
316
|
+
});
|
|
292
317
|
} catch (error) {
|
|
293
318
|
debug(`Failed to deepen history for ${sha}, using local history`, getGitErrorOutput(error));
|
|
294
319
|
return localParents;
|
|
@@ -308,6 +333,7 @@ function readCommitParents(sha) {
|
|
|
308
333
|
"--parents",
|
|
309
334
|
"-n",
|
|
310
335
|
"1",
|
|
336
|
+
"--end-of-options",
|
|
311
337
|
sha,
|
|
312
338
|
"--"
|
|
313
339
|
], { stdio: [
|
|
@@ -950,7 +976,7 @@ function listAncestorCommits(input) {
|
|
|
950
976
|
*/
|
|
951
977
|
async function getCiEnvironment() {
|
|
952
978
|
const context = createContext();
|
|
953
|
-
debug("Detecting CI environment"
|
|
979
|
+
debug("Detecting CI environment");
|
|
954
980
|
const service = getCiService(context);
|
|
955
981
|
if (service) {
|
|
956
982
|
debug("Internal service matched", service.name);
|
|
@@ -963,6 +989,7 @@ async function getCiEnvironment() {
|
|
|
963
989
|
debug("CI environment", ciEnvironment);
|
|
964
990
|
return ciEnvironment;
|
|
965
991
|
}
|
|
992
|
+
debug("No CI service matched");
|
|
966
993
|
return null;
|
|
967
994
|
}
|
|
968
995
|
//#endregion
|
|
@@ -1452,7 +1479,7 @@ async function exchangeGitHubActionsTokenlessToken(args) {
|
|
|
1452
1479
|
*/
|
|
1453
1480
|
async function resolveArgosToken(config) {
|
|
1454
1481
|
if (config.token) {
|
|
1455
|
-
debug(
|
|
1482
|
+
debug(`Authenticated with ARGOS_TOKEN (${maskToken(config.token)}).`);
|
|
1456
1483
|
return config.token;
|
|
1457
1484
|
}
|
|
1458
1485
|
if (isGitHubActionsOidcAvailable()) {
|
|
@@ -2203,7 +2230,8 @@ const PLAYWRIGHT_TRACE_CONTENT_TYPE = "application/zip";
|
|
|
2203
2230
|
* Upload screenshots to Argos.
|
|
2204
2231
|
*/
|
|
2205
2232
|
async function upload(params) {
|
|
2206
|
-
|
|
2233
|
+
const { token: _paramsToken, ...debugParams } = params;
|
|
2234
|
+
debug("Starting upload with params", debugParams);
|
|
2207
2235
|
const [config, argosSdk] = await Promise.all([getConfigFromOptions(params), getArgosCoreSDKIdentifier()]);
|
|
2208
2236
|
const authToken = await resolveArgosToken(config);
|
|
2209
2237
|
const apiClient = createClient({
|
|
@@ -2219,7 +2247,8 @@ async function upload(params) {
|
|
|
2219
2247
|
}
|
|
2220
2248
|
const previewUrlFormatter = params.previewUrl ?? (config.previewBaseUrl ? { baseUrl: config.previewBaseUrl } : void 0);
|
|
2221
2249
|
const globs = params.files ?? ["**/*.{png,jpg,jpeg}"];
|
|
2222
|
-
|
|
2250
|
+
const { token: _configToken, ...debugConfig } = config;
|
|
2251
|
+
debug("Using config and files", debugConfig, globs);
|
|
2223
2252
|
const files = await discoverSnapshots(globs, {
|
|
2224
2253
|
root: params.root,
|
|
2225
2254
|
ignore: params.ignore
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/core",
|
|
3
3
|
"description": "Node.js SDK for visual testing with Argos.",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"lint": "eslint .",
|
|
69
69
|
"test": "vitest"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "18b61fb04ed2502c5018eb42a521ec358bef194e"
|
|
72
72
|
}
|