@qawolf/ci-sdk 0.23.1 → 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/README.md +30 -198
- package/dist/index.cjs +632 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +6 -211
- package/dist/index.d.ts +6 -211
- package/dist/index.js +58 -1047
- package/dist/index.js.map +1 -1
- package/package.json +23 -25
- package/dist/index.mjs +0 -1610
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
# QAWolf CI SDK
|
|
2
2
|
|
|
3
|
-
> :warning: This is an experimental package. Please report any
|
|
4
|
-
> issues you encounter to your support channel. It should still
|
|
5
|
-
> provide a better experience than using our internal GraphQL
|
|
6
|
-
> API directly.
|
|
7
|
-
|
|
8
3
|
This package provides a TypeScript (CSM and ESM compatible) SDK
|
|
9
4
|
to interact with the QA Wolf Customer-facing API.
|
|
10
5
|
|
|
11
|
-
It exposes
|
|
12
|
-
the examples below. There is also an experimental VCS Branch Testing (aka PR Testing)
|
|
13
|
-
feature, encapsulated in its own object, that is described at the bottom of this
|
|
14
|
-
document.
|
|
6
|
+
It exposes several functions associated with different endpoints, which are detailed in the table of contents below.
|
|
15
7
|
|
|
16
8
|
Note that these functions do not throw. They yield a result object that
|
|
17
9
|
contains the outcome of the operation. This outcome should be scrutinized
|
|
@@ -86,6 +78,19 @@ const deployConfig: GitLabDeployConfig = {
|
|
|
86
78
|
},
|
|
87
79
|
};
|
|
88
80
|
|
|
81
|
+
// Example for Ephemeral deployments
|
|
82
|
+
const deployConfig: EphemeralDeployConfig = {
|
|
83
|
+
branch: undefined,
|
|
84
|
+
commitUrl: undefined,
|
|
85
|
+
deduplicationKey: undefined,
|
|
86
|
+
// Required only if the target trigger requires matching a deployment type
|
|
87
|
+
deploymentType: "staging", // e.g., "production", "staging", "qa"
|
|
88
|
+
deploymentUrl: "https://preview.environment.com",
|
|
89
|
+
ephemeralEnvironment: true,
|
|
90
|
+
sha: undefined,
|
|
91
|
+
variables: undefined,
|
|
92
|
+
};
|
|
93
|
+
|
|
89
94
|
// General Example
|
|
90
95
|
// Edit this to your needs.
|
|
91
96
|
const deployConfig: DeployConfig = {
|
|
@@ -133,7 +138,9 @@ Once enabled, to use PR/MR testing functionality:
|
|
|
133
138
|
|
|
134
139
|
- Pass `hostingService: "GitLab"`, `repository` information, and `mergeRequestNumber` while notifying a deployment as described in the [Notify Deployment](#notify-deployment) section
|
|
135
140
|
|
|
136
|
-
3. For
|
|
141
|
+
3. For `Ephemeral` deployments (no code hosting integration):
|
|
142
|
+
|
|
143
|
+
- Pass `ephemeralEnvironment: true` and `deploymentUrl` while notifying a deployment as described in the [Notify Deployment](#notify-deployment) section
|
|
137
144
|
|
|
138
145
|
<a id="ci-greenlight"></a>
|
|
139
146
|
|
|
@@ -249,191 +256,6 @@ async function uploadRunArtifact(filePath: string): Promise<string> {
|
|
|
249
256
|
}
|
|
250
257
|
```
|
|
251
258
|
|
|
252
|
-
<a name="vcs-branch-testing"></a>
|
|
253
|
-
|
|
254
|
-
## VCS Branch Testing (Experimental)
|
|
255
|
-
|
|
256
|
-
> ⚠️ For GitHub and GitLab users, we recommend using the standard notify deployment approach described in [Notify Preview Deployment (Pull Request / Merge Request Testing)](#notify-preview). The standard approach provides better integration with your repository when you include the proper repository and PR/MR information.
|
|
257
|
-
|
|
258
|
-
> ⚠️ This section is not covered by SemVer and will change.
|
|
259
|
-
|
|
260
|
-
> ℹ️ This feature must be activated by QA Wolf. Please reach out to a QA Wolf
|
|
261
|
-
> representative to enable it, and help you with the setup.
|
|
262
|
-
|
|
263
|
-
### Highlights and Definitions
|
|
264
|
-
|
|
265
|
-
VCS Branch Testing allows you to set up QA Wolf ephemeral environments associated with
|
|
266
|
-
preview deployments (builds) of your product, which code is hosted in VCS branches (e.g.
|
|
267
|
-
Git branches). It can be understood as "PR Testing", however the SDK does not need
|
|
268
|
-
the concept of PR or MR to operate.
|
|
269
|
-
|
|
270
|
-
> ℹ️ Read our [introduction to VCS Branch Testing](https://qawolf.notion.site/VCS-Branch-Testing-45be5d10d93249aeb8c1f995d26356ec?pvs=4) to get familiar with core concepts. We also provide [a more detailed SDK guide over here](https://qawolf.notion.site/qawolf-ci-sdk-VCS-Branch-Testing-df701e8742b84be39632d7284c926491?pvs=74).
|
|
271
|
-
|
|
272
|
-
### Usage
|
|
273
|
-
|
|
274
|
-
This SDK exposes an experimental VCS Branch Testing object:
|
|
275
|
-
|
|
276
|
-
```ts
|
|
277
|
-
import { makeQaWolfSdk } from "@qawolf/ci-sdk";
|
|
278
|
-
|
|
279
|
-
const vcsBranchTestingSdk = makeQaWolfSdk({
|
|
280
|
-
apiKey: "qawolf_xxxxx",
|
|
281
|
-
}).experimental_vcsBranchTesting;
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
The above object contains the following methods:
|
|
285
|
-
|
|
286
|
-
- `notifyVCSBranchBuildDeployed`;
|
|
287
|
-
- `notifyVCSBranchMergeCanceled`;
|
|
288
|
-
- `notifyVCSBranchMergeCompleted`.
|
|
289
|
-
|
|
290
|
-
#### Notify Build Deployed `notifyVCSBranchBuildDeployed`
|
|
291
|
-
|
|
292
|
-
```ts
|
|
293
|
-
import {
|
|
294
|
-
makeQaWolfSdk,
|
|
295
|
-
arbitraryStringToEnvironmentAlias,
|
|
296
|
-
} from "@qawolf/ci-sdk";
|
|
297
|
-
|
|
298
|
-
const { notifyVCSBranchBuildDeployed } = makeQaWolfSdk({
|
|
299
|
-
apiKey: "qawolf_xxxxx",
|
|
300
|
-
}).experimental_vcsBranchTesting;
|
|
301
|
-
|
|
302
|
-
// Mappings let QA Wolf know how to associate base VCS branches to environments.
|
|
303
|
-
const baseEnvironmentsMapping = [
|
|
304
|
-
{
|
|
305
|
-
environmentAlias: "develop",
|
|
306
|
-
vcsBranch: "main",
|
|
307
|
-
},
|
|
308
|
-
];
|
|
309
|
-
|
|
310
|
-
(async () => {
|
|
311
|
-
const baseVcsBranch = "main";
|
|
312
|
-
const headVcsBranch = "feature/foo";
|
|
313
|
-
const headPreviewUrl = "https://feature-foo.example.com";
|
|
314
|
-
const headVcsCommitId = "abcdef";
|
|
315
|
-
// Optional. It will show up in the UI when provided. If an integration with
|
|
316
|
-
// a code hosting service is already set up, you don't need to provide this field.
|
|
317
|
-
const optionalHeadCommitUrl = "https://.../commits/abcdef";
|
|
318
|
-
// Optional. It is required for a code hosting service integration to function
|
|
319
|
-
// properly. When that is the case, comments will be posted in the PR/MR describing
|
|
320
|
-
// the outcome of tests in the head environment.
|
|
321
|
-
const optionalPullOrMergeRequestNumber = 123;
|
|
322
|
-
// The alias must be stable for the lifetime of the VCS Branch / Environment.
|
|
323
|
-
// It also should be unique across your organization, accounting for different
|
|
324
|
-
// repositories.
|
|
325
|
-
const headEnvironmentAlias = arbitraryStringToEnvironmentAlias(
|
|
326
|
-
`org/repo/${headVcsBranch}`,
|
|
327
|
-
);
|
|
328
|
-
// The name of the environment, as it will show-up in the QA Wolf UI.
|
|
329
|
-
const headEnvironmentName = `org/repo/${headVcsBranch}`;
|
|
330
|
-
// Environment variables are not optional. There must be at least one locator
|
|
331
|
-
// for the deployed application. Since this deployment is entirely handled by
|
|
332
|
-
// customers, we cannot provide more generic guidance.
|
|
333
|
-
const headEnvironmentVariables = {
|
|
334
|
-
URL: headPreviewUrl,
|
|
335
|
-
};
|
|
336
|
-
// Obviously, configuration object should be adapted to your needs, and
|
|
337
|
-
// most are dynamic and shall be derived from context. This is just an example.
|
|
338
|
-
const { outcome } = await notifyVCSBranchBuildDeployed({
|
|
339
|
-
baseEnvironmentsMapping,
|
|
340
|
-
baseVcsBranch: "main",
|
|
341
|
-
headEnvironmentAlias,
|
|
342
|
-
// If you are not sure how to build the environment name, just use the
|
|
343
|
-
// alias. This name will show up in the UI though.
|
|
344
|
-
headEnvironmentName,
|
|
345
|
-
headVcsBranch,
|
|
346
|
-
headVcsCommitId,
|
|
347
|
-
headCommitUrl: optionalHeadCommitUrl,
|
|
348
|
-
headEnvironmentVariables,
|
|
349
|
-
pullOrMergeRequestNumber: optionalPullOrMergeRequestNumber,
|
|
350
|
-
});
|
|
351
|
-
if (outcome !== "success") {
|
|
352
|
-
// Fail the job.
|
|
353
|
-
process.exit(1);
|
|
354
|
-
}
|
|
355
|
-
// Continue CI.
|
|
356
|
-
})();
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
#### Notify Merge Canceled `notifyVCSBranchMergeCanceled`
|
|
360
|
-
|
|
361
|
-
```ts
|
|
362
|
-
import { makeQaWolfSdk } from "@qawolf/ci-sdk";
|
|
363
|
-
|
|
364
|
-
const { notifyVCSBranchMergeCanceled } = makeQaWolfSdk({
|
|
365
|
-
apiKey: "qawolf_xxxxx",
|
|
366
|
-
}).experimental_vcsBranchTesting;
|
|
367
|
-
|
|
368
|
-
(async () => {
|
|
369
|
-
const headVcsBranch = "feature/foo";
|
|
370
|
-
// The alias must be stable for the lifetime of the VCS Branch / Environment.
|
|
371
|
-
// It also should be unique across your organization, accounting for different
|
|
372
|
-
// repositories.
|
|
373
|
-
const headEnvironmentAlias = arbitraryStringToEnvironmentAlias(
|
|
374
|
-
`org/repo/${headVcsBranch}`,
|
|
375
|
-
);
|
|
376
|
-
const result = await notifyVCSBranchMergeCanceled({
|
|
377
|
-
headEnvironmentAlias,
|
|
378
|
-
});
|
|
379
|
-
if (result.outcome !== "success") {
|
|
380
|
-
if (result.abortReason === "head-environment-not-found") {
|
|
381
|
-
console.warn(
|
|
382
|
-
`Head environment not found. Skipping! The QA Wolf environment was either never created or it was manually deleted.`,
|
|
383
|
-
);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
// Fail the job.
|
|
387
|
-
process.exit(1);
|
|
388
|
-
}
|
|
389
|
-
// Continue CI.
|
|
390
|
-
})();
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
### Notify Merge Completed `notifyVCSBranchMergeCompleted`
|
|
394
|
-
|
|
395
|
-
```ts
|
|
396
|
-
import {
|
|
397
|
-
makeQaWolfSdk,
|
|
398
|
-
arbitraryStringToEnvironmentAlias,
|
|
399
|
-
} from "@qawolf/ci-sdk";
|
|
400
|
-
|
|
401
|
-
const { notifyVCSBranchMergeCompleted } = makeQaWolfSdk({
|
|
402
|
-
apiKey: "qawolf_xxxxx",
|
|
403
|
-
}).experimental_vcsBranchTesting;
|
|
404
|
-
|
|
405
|
-
// Mappings let QA Wolf know how to associate base VCS branches to environments.
|
|
406
|
-
const baseEnvironmentsMapping = [
|
|
407
|
-
{
|
|
408
|
-
environmentAlias: "develop",
|
|
409
|
-
vcsBranch: "main",
|
|
410
|
-
},
|
|
411
|
-
];
|
|
412
|
-
|
|
413
|
-
(async () => {
|
|
414
|
-
const headVcsBranch = "feature/foo";
|
|
415
|
-
// The alias must be stable for the lifetime of the VCS Branch / Environment.
|
|
416
|
-
// It also should be unique across your organization, accounting for different
|
|
417
|
-
// repositories.
|
|
418
|
-
const headEnvironmentAlias = arbitraryStringToEnvironmentAlias(
|
|
419
|
-
`org/repo/${headVcsBranch}`,
|
|
420
|
-
);
|
|
421
|
-
const baseVcsBranch = "main";
|
|
422
|
-
|
|
423
|
-
const { outcome } = await notifyVCSBranchMergeCompleted({
|
|
424
|
-
baseEnvironmentsMapping,
|
|
425
|
-
headVcsBranch,
|
|
426
|
-
headEnvironmentAlias,
|
|
427
|
-
baseVcsBranch,
|
|
428
|
-
});
|
|
429
|
-
if (outcome !== "success") {
|
|
430
|
-
// Fail the job.
|
|
431
|
-
process.exit(1);
|
|
432
|
-
}
|
|
433
|
-
// Continue CI.
|
|
434
|
-
})();
|
|
435
|
-
```
|
|
436
|
-
|
|
437
259
|
<a name="requirements"></a>
|
|
438
260
|
|
|
439
261
|
## Requirements
|
|
@@ -458,9 +280,7 @@ const sdk = makeQaWolfSdk(
|
|
|
458
280
|
|
|
459
281
|
This package follows the [SemVer](https://semver.org/) versioning scheme. Additional notes:
|
|
460
282
|
|
|
461
|
-
-
|
|
462
|
-
- We recommend depending on the `^` range operator for this package, as it will not introduce breaking changes and guarantee
|
|
463
|
-
an up-to-date API usage version.
|
|
283
|
+
- We recommend depending on the `^` range operator for this package, as it will not introduce breaking changes and guarantee an up-to-date API usage version.
|
|
464
284
|
<!-- There is a limitation in NPM preventing us from using relative links and hosting other MD files when the repository hosting code is not
|
|
465
285
|
public, hence we inline the changelog in the README. See https://github.com/npm/feedback/discussions/666 -->
|
|
466
286
|
- We will provide a changelog for each release, which will be available in the Changelog section below.
|
|
@@ -474,6 +294,18 @@ an up-to-date API usage version.
|
|
|
474
294
|
|
|
475
295
|
# Changelog
|
|
476
296
|
|
|
297
|
+
## v1.1.0
|
|
298
|
+
|
|
299
|
+
- New `ephemeralEnvironment` parameter for `attemptNotifyDeploy`
|
|
300
|
+
|
|
301
|
+
## v1.0.1
|
|
302
|
+
|
|
303
|
+
- Internal ESM-related refactoring
|
|
304
|
+
|
|
305
|
+
## v1.0.0
|
|
306
|
+
|
|
307
|
+
- Breaking Change: Remove `experimental_vcsBranchTesting` and `experimental_testPreview`. See how to migrate in [Notify Preview Deployment (Pull Request / Merge Request Testing)](#notify-preview) section.
|
|
308
|
+
|
|
477
309
|
## v0.23.1
|
|
478
310
|
|
|
479
311
|
- Fix ESM build
|