@argos-ci/core 5.1.1 → 5.1.3

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.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  exports.upload = async (...args) => {
2
- const { upload } = await import("./index.js");
2
+ const { upload } = await import("./index.mjs");
3
3
  return upload(...args);
4
4
  };
5
5
 
6
6
  exports.finalize = async (...args) => {
7
- const { finalize } = await import("./index.js");
7
+ const { finalize } = await import("./index.mjs");
8
8
  return finalize(...args);
9
9
  };
10
10
 
11
11
  exports.readConfig = async (...args) => {
12
- const { readConfig } = await import("./index.js");
12
+ const { readConfig } = await import("./index.mjs");
13
13
  return readConfig(...args);
14
14
  };
@@ -0,0 +1,312 @@
1
+ import { ArgosAPISchema } from "@argos-ci/api-client";
2
+ import { ScreenshotMetadata } from "@argos-ci/util";
3
+
4
+ //#region src/config.d.ts
5
+ interface Config {
6
+ /**
7
+ * Base URL of the Argos API.
8
+ * Use this to target a self-hosted installation.
9
+ * @default "https://api.argos-ci.com/v2/"
10
+ */
11
+ apiBaseUrl: string;
12
+ /**
13
+ * Git commit SHA.
14
+ */
15
+ commit: string;
16
+ /**
17
+ * Git branch name of the build.
18
+ * @example "main", "develop", "release/1.0"
19
+ */
20
+ branch: string;
21
+ /**
22
+ * Argos repository access token.
23
+ */
24
+ token: string | null;
25
+ /**
26
+ * Custom build name.
27
+ * Useful for multi-build setups on the same commit.
28
+ */
29
+ buildName: string | null;
30
+ /**
31
+ * Whether this build is split across multiple parallel jobs.
32
+ * @default false
33
+ */
34
+ parallel: boolean;
35
+ /**
36
+ * Unique identifier shared by all parallel jobs.
37
+ */
38
+ parallelNonce: string | null;
39
+ /**
40
+ * Index of the current parallel job.
41
+ * Must be between 1 and `parallelTotal`, or null if not set.
42
+ */
43
+ parallelIndex: number | null;
44
+ /**
45
+ * Total number of parallel jobs.
46
+ * Use -1 if unknown, or null if not set.
47
+ */
48
+ parallelTotal: number | null;
49
+ /**
50
+ * Git branch used as the baseline for screenshot comparison.
51
+ */
52
+ referenceBranch: string | null;
53
+ /**
54
+ * Git commit SHA used as the baseline for screenshot comparison.
55
+ */
56
+ referenceCommit: string | null;
57
+ /**
58
+ * Repository slug of the source repository.
59
+ * Example: "my-org/my-repo" or "my-user/my-repo".
60
+ * If from a fork, this refers to the fork repository.
61
+ */
62
+ repository: string | null;
63
+ /**
64
+ * Repository slug of the original (base) repository.
65
+ * Example: "my-org/my-repo" or "my-user/my-repo".
66
+ * If from a fork, this refers to the base repository.
67
+ */
68
+ originalRepository: string | null;
69
+ /**
70
+ * CI job identifier (if provided by the CI environment).
71
+ */
72
+ jobId: string | null;
73
+ /**
74
+ * CI run identifier (if provided by the CI environment).
75
+ */
76
+ runId: string | null;
77
+ /**
78
+ * CI run attempt number (if provided by the CI environment).
79
+ */
80
+ runAttempt: number | null;
81
+ /**
82
+ * Pull request number associated with the build.
83
+ */
84
+ prNumber: number | null;
85
+ /**
86
+ * Pull request head commit SHA (if available).
87
+ */
88
+ prHeadCommit: string | null;
89
+ /**
90
+ * Pull request base branch (if available).
91
+ */
92
+ prBaseBranch: string | null;
93
+ /**
94
+ * Build mode to use.
95
+ * - "ci": Review visual changes introduced by a feature branch and prevent regressions.
96
+ * - "monitoring": Track visual changes outside the standard CI flow, either on a schedule or before a release.
97
+ * @see https://argos-ci.com/docs/build-modes
98
+ */
99
+ mode: "ci" | "monitoring" | null;
100
+ /**
101
+ * Name of the detected CI provider (if available).
102
+ * @example "github-actions", "gitlab-ci", "circleci"
103
+ */
104
+ ciProvider: string | null;
105
+ /**
106
+ * Diff sensitivity threshold between 0 and 1.
107
+ * Higher values make Argos less sensitive to differences.
108
+ */
109
+ threshold: number | null;
110
+ /**
111
+ * Base URL to use for preview links.
112
+ * @example "https://my-preview.example.com"
113
+ */
114
+ previewBaseUrl: string | null;
115
+ /**
116
+ * Skip this build.
117
+ * No screenshots are uploaded, and the commit status is marked as success.
118
+ */
119
+ skipped?: boolean;
120
+ /**
121
+ * Whether the environment is a merge queue.
122
+ */
123
+ mergeQueue?: boolean;
124
+ /**
125
+ * Whether this build contains only a subset of screenshots.
126
+ * This is useful when a build is created from an incomplete test suite where some tests are skipped.
127
+ */
128
+ subset?: boolean;
129
+ }
130
+ declare function readConfig(options?: Partial<Config>): Promise<Config>;
131
+ declare function getConfigFromOptions({
132
+ parallel,
133
+ ...options
134
+ }: Omit<Partial<Config>, "parallel"> & {
135
+ parallel?: {
136
+ /** Unique build ID for this parallel build */nonce: string; /** The number of parallel nodes being ran */
137
+ total: number; /** The index of the parallel node */
138
+ index?: number;
139
+ } | false | undefined;
140
+ }): Promise<Config>;
141
+ //#endregion
142
+ //#region src/finalize.d.ts
143
+ type FinalizeParameters = {
144
+ parallel?: {
145
+ nonce: string;
146
+ };
147
+ };
148
+ /**
149
+ * Finalize pending builds.
150
+ */
151
+ declare function finalize(params: FinalizeParameters): Promise<{
152
+ builds: {
153
+ id: string;
154
+ number: number;
155
+ status: ("accepted" | "rejected") | ("no-changes" | "changes-detected") | ("expired" | "pending" | "progress" | "error" | "aborted");
156
+ conclusion: ("no-changes" | "changes-detected") | null;
157
+ stats: {
158
+ added: number;
159
+ removed: number;
160
+ unchanged: number;
161
+ changed: number;
162
+ ignored: number;
163
+ failure: number;
164
+ retryFailure: number;
165
+ total: number;
166
+ } | null;
167
+ metadata: {
168
+ testReport?: {
169
+ status: "passed" | "failed" | "timedout" | "interrupted";
170
+ stats?: {
171
+ startTime?: string | undefined;
172
+ duration?: number | undefined;
173
+ } | undefined;
174
+ } | undefined;
175
+ } | null;
176
+ url: string;
177
+ notification: {
178
+ description: string;
179
+ context: string;
180
+ github: {
181
+ state: "pending" | "success" | "error" | "failure";
182
+ };
183
+ gitlab: {
184
+ state: "pending" | "running" | "success" | "failed" | "canceled";
185
+ };
186
+ } | null;
187
+ }[];
188
+ }>;
189
+ //#endregion
190
+ //#region src/upload.d.ts
191
+ type BuildMetadata = ArgosAPISchema.components["schemas"]["BuildMetadata"];
192
+ interface UploadParameters {
193
+ /**
194
+ * Globs that match image file paths to upload.
195
+ */
196
+ files?: string[];
197
+ /**
198
+ * Root directory used to resolve image paths.
199
+ * @default process.cwd()
200
+ */
201
+ root?: string;
202
+ /**
203
+ * Globs that match image file paths to exclude from upload.
204
+ * @default ["**\/*.{png,jpg,jpeg}"]
205
+ */
206
+ ignore?: string[];
207
+ /**
208
+ * Base URL of the Argos API.
209
+ * @default "https://api.argos-ci.com/v2/"
210
+ */
211
+ apiBaseUrl?: string;
212
+ /**
213
+ * Git commit SHA of the build.
214
+ */
215
+ commit?: string;
216
+ /**
217
+ * Git branch name of the build.
218
+ */
219
+ branch?: string;
220
+ /**
221
+ * Argos repository access token.
222
+ */
223
+ token?: string;
224
+ /**
225
+ * Pull request number associated with the build.
226
+ */
227
+ prNumber?: number;
228
+ /**
229
+ * Custom build name. Useful when triggering multiple Argos builds
230
+ * for the same commit.
231
+ */
232
+ buildName?: string;
233
+ /**
234
+ * Build mode to use.
235
+ * - "ci": Review the visual changes introduced by a feature branch and prevent regressions.
236
+ * - "monitoring": Track visual changes outside the standard CI flow, either on a schedule or before a release.
237
+ * @see https://argos-ci.com/docs/build-modes
238
+ * @default "ci"
239
+ */
240
+ mode?: "ci" | "monitoring";
241
+ /**
242
+ * Parallel test suite configuration.
243
+ * @default false
244
+ */
245
+ parallel?: {
246
+ /** Unique build identifier shared across parallel jobs. */nonce: string; /** Total number of parallel jobs, set to -1 to finalize manually. */
247
+ total: number; /** Index of the current job (must start from 1). */
248
+ index?: number;
249
+ } | false;
250
+ /**
251
+ * Branch used as the baseline for screenshot comparison.
252
+ */
253
+ referenceBranch?: string;
254
+ /**
255
+ * Commit SHA used as the baseline for screenshot comparison.
256
+ */
257
+ referenceCommit?: string;
258
+ /**
259
+ * Diff sensitivity threshold between 0 and 1.
260
+ * Higher values make Argos less sensitive to differences.
261
+ * @default 0.5
262
+ */
263
+ threshold?: number;
264
+ /**
265
+ * Additional build metadata.
266
+ */
267
+ metadata?: BuildMetadata;
268
+ /**
269
+ * Preview URL configuration.
270
+ * Can be a fixed base URL or a function to transform URLs dynamically.
271
+ */
272
+ previewUrl?: {
273
+ baseUrl: string;
274
+ } | ((url: string) => string);
275
+ /**
276
+ * Whether this build contains only a subset of screenshots.
277
+ * This is useful when a build is created from an incomplete test suite where some tests are skipped.
278
+ * @default false
279
+ */
280
+ subset?: boolean;
281
+ }
282
+ interface Screenshot {
283
+ hash: string;
284
+ optimizedPath: string;
285
+ metadata: ScreenshotMetadata | null;
286
+ threshold: number | null;
287
+ baseName: string | null;
288
+ pwTrace: {
289
+ path: string;
290
+ hash: string;
291
+ } | null;
292
+ name: string;
293
+ path: string;
294
+ }
295
+ /**
296
+ * Upload screenshots to Argos.
297
+ */
298
+ declare function upload(params: UploadParameters): Promise<{
299
+ build: ArgosAPISchema.components["schemas"]["Build"];
300
+ screenshots: Screenshot[];
301
+ }>;
302
+ //#endregion
303
+ //#region src/skip.d.ts
304
+ type SkipParameters = Pick<UploadParameters, "apiBaseUrl" | "commit" | "branch" | "token" | "prNumber" | "buildName" | "metadata">;
305
+ /**
306
+ * Mark a build as skipped.
307
+ */
308
+ declare function skip(params: SkipParameters): Promise<{
309
+ build: ArgosAPISchema.components["schemas"]["Build"];
310
+ }>;
311
+ //#endregion
312
+ export { Config, FinalizeParameters, UploadParameters, finalize, getConfigFromOptions, readConfig, skip, upload };