@qawolf/ci-sdk 3.7.0 → 3.8.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.
Files changed (29) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -7
  3. package/dist/index.js +629 -83
  4. package/dist/index.js.map +4 -4
  5. package/dist/lib/sdk/defaults/contracts.d.ts +24 -0
  6. package/dist/lib/sdk/domain/collectCommitChanges/commitChange.d.ts +22 -0
  7. package/dist/lib/sdk/domain/collectCommitChanges/fitChanges.d.ts +17 -0
  8. package/dist/lib/sdk/domain/collectCommitChanges/parseLog.d.ts +7 -5
  9. package/dist/lib/sdk/domain/collectCommitChanges/readCommitRange.d.ts +32 -0
  10. package/dist/lib/sdk/domain/collectCommitChanges/summarizeCommits.d.ts +3 -6
  11. package/dist/lib/sdk/domain/collectDeployChanges/explainCollection.d.ts +8 -0
  12. package/dist/lib/sdk/domain/collectDeployChanges/filterChanges.d.ts +21 -0
  13. package/dist/lib/sdk/domain/collectDeployChanges/index.d.ts +18 -0
  14. package/dist/lib/sdk/domain/collectDeployChanges/isGitHubRepository.d.ts +8 -0
  15. package/dist/lib/sdk/domain/collectDeployChanges/sendableChanges.d.ts +8 -0
  16. package/dist/lib/sdk/domain/collectDeployChanges/testHarness.d.ts +46 -0
  17. package/dist/lib/sdk/domain/collectDeployChanges/types.d.ts +60 -0
  18. package/dist/lib/sdk/domain/detectProviderDeploymentId/ciSystems.d.ts +16 -0
  19. package/dist/lib/sdk/domain/detectProviderDeploymentId/index.d.ts +3 -4
  20. package/dist/lib/sdk/domain/repositoryCoverage/contracts.d.ts +10 -0
  21. package/dist/lib/sdk/domain/repositoryCoverage/findRepositoryCoverage.d.ts +17 -0
  22. package/dist/lib/sdk/domain/repositoryCoverage/identifyRepository.d.ts +44 -0
  23. package/dist/lib/sdk/domain/repositoryCoverage/index.d.ts +15 -0
  24. package/dist/lib/sdk/domain/repositoryCoverage/testHarness.d.ts +46 -0
  25. package/dist/lib/sdk/domain/repositoryCoverage/types.d.ts +73 -0
  26. package/dist/lib/sdk/domain/uploadBuild/types.d.ts +2 -2
  27. package/dist/lib/sdk/index.d.ts +35 -5
  28. package/dist/tests/test-lib.d.ts +27 -5
  29. package/package.json +8 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QA Wolf Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -175,6 +175,7 @@ It is required, and the SDK never guesses it. Beware that `GITHUB_RUN_ID` alone
175
175
  | Buildkite | `BUILDKITE` | `BUILDKITE_BUILD_ID`-`BUILDKITE_JOB_ID`-`BUILDKITE_RETRY_COUNT` |
176
176
  | Jenkins | `JENKINS_URL` or `JENKINS_HOME` | `BUILD_TAG` |
177
177
  | Bitbucket Pipelines | `BITBUCKET_WORKSPACE` or `BITBUCKET_BUILD_NUMBER` | `BITBUCKET_BUILD_NUMBER`-`BITBUCKET_STEP_UUID`-`BITBUCKET_STEP_RUN_NUMBER` |
178
+ | Azure Pipelines | `TF_BUILD` | `BUILD_BUILDID`-`SYSTEM_JOBID`-`SYSTEM_JOBATTEMPT` |
178
179
 
179
180
  Jenkins needs no job or attempt part: `BUILD_TAG` is `jenkins-<job name>-<build number>`, and Jenkins allocates a fresh build number for every re-run you can start from outside the build. Bitbucket needs all three, because rerunning only the failed steps keeps the build number while parallel steps share both it and the step run number.
180
181
 
@@ -233,6 +234,79 @@ if (collected.outcome === "collected") {
233
234
 
234
235
  Each commit on the first-parent line after `since` becomes one change. A GitHub or GitLab merge commit, or a GitHub squash-merge commit (its subject ends in `(#123)`), becomes a pull request titled from its message, and any other commit stays a commit. `"descriptions"` adds each change's message body, and `"paths"` adds the file paths it changed, as many as fit beside the other changes. It never reads diffs or file contents. It reads at most the 250 newest commits; older ones, and any left out to fit the API's limits, are counted in `omittedCount`. On a shallow clone it returns `history-unavailable` instead of sending part of the range, and when `since` names no commit it returns `since-not-found`. Send `changes` on the first `success` report or earlier.
235
236
 
237
+ <a id="collect-deploy-changes"></a>
238
+
239
+ ### Collect a deploy's changes
240
+
241
+ `deployment.collectDeployChanges` builds `changes` for you. It sends nothing itself, so you pass what it returns to `deployment.reportStatus`:
242
+
243
+ ```javascript
244
+ const collected = await deployment.collectDeployChanges({
245
+ since: "v1.2.0", // the commit or tag the environment ran before
246
+ });
247
+ if (collected.outcome !== "collected") console.warn(collected.message);
248
+ await deployment.reportStatus({
249
+ /* ... */
250
+ changes: collected.outcome === "collected" ? collected.changes : undefined,
251
+ status: "success",
252
+ });
253
+ ```
254
+
255
+ It collects this deploy's commits from the local git history, with their messages and changed file paths. QA Wolf reads merged pull requests from GitHub or GitLab itself, but never commits pushed straight to a branch, such as a hotfix, so the commits are collected whatever QA Wolf reads. It also asks QA Wolf what it reads of the repository, logs the answer and returns it as `coverage`.
256
+
257
+ Each change carries its ids, a pull request's number and the commit it landed as, or a commit's sha, so QA Wolf lists a change it also reads from your code host only once. A merge commit's message names its pull or merge request; on GitHub, a commit whose subject ends in `(#N)` is a squashed pull request too. Elsewhere `#N` can name an issue, so such a commit is sent as a commit. Before it returns them, it redacts secrets from the text, such as tokens, keys and passwords, with the same patterns QA Wolf applies when it receives changes, removes trailers like `Co-authored-by:` that name a person by email, and leaves out any change QA Wolf wouldn't accept. On a shallow clone, or when `since` names no commit, it returns no changes but says what went wrong in `changes.problems`, so QA Wolf can tell you; the log says how to fix it.
258
+
259
+ Options:
260
+
261
+ | Option | Meaning |
262
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
263
+ | `since` | Required. The commit or tag the environment ran before, e.g. the previous release tag. |
264
+ | `repository` | `{ type: "url", url }` or `{ type: "full-name", fullName, host }`. By default, the repository your CI names (GitHub Actions, GitLab CI/CD, CircleCI, Buildkite, Jenkins, Bitbucket Pipelines and Azure Pipelines are recognized), else the clone's `origin` remote. A full name's `host` defaults to that repository's host, else `github.com`. Credentials in a URL are removed before it's sent. |
265
+ | `workspaceId` | Only needed with an organization or user API key. See [API Keys and Workspaces](#api-keys). |
266
+ | `include` | What to send for each change: `"titles"`, `"descriptions"` and `"paths"`, all by default. Commit messages and changed paths are what QA Wolf chooses the flows to run from, so `include: ["titles"]` lowers the quality of the choice. |
267
+ | `filter` | Edits the changes before they're redacted and sent. See below. |
268
+ | `filterTimeoutMs` | How long `filter` may take; 2 minutes by default. `Infinity` sets no limit. |
269
+ | `releaseNotes` | Notes written for the release, redacted and sent with the changes. |
270
+ | `cwd` | The repository folder; the current directory by default. If it's a checkout of another repository than the one the job was started for, pass `repository` too. |
271
+ | `env` | The variables to read the CI's repository from; `process.env` by default. |
272
+
273
+ To clean or leave out changes before they leave CI, pass a `filter`. It gets the changes and returns the ones to send, and it may be async, e.g. to remove sensitive details with your own tools in one call:
274
+
275
+ ```javascript
276
+ const collected = await deployment.collectDeployChanges({
277
+ filter: async (changes) =>
278
+ Promise.all(
279
+ changes
280
+ .filter((change) => !change.title.startsWith("chore:"))
281
+ .map(async (change) => ({
282
+ ...change,
283
+ description: await removeSensitiveDetails(change.description),
284
+ })),
285
+ ),
286
+ since: "v1.2.0",
287
+ });
288
+ ```
289
+
290
+ When the filter throws, takes longer than `filterTimeoutMs` or returns something that isn't a list of changes, none of the changes are sent, never the text as it was before the filter, and `changes.problems` says the filter failed. A returned change QA Wolf doesn't accept, such as one without a title or with a field it doesn't know, is left out, and `changes.problems` says the filter failed too. Redaction runs on what the filter returns.
291
+
292
+ The result carries `coverage`, what QA Wolf said it can read, and `repository`, the URL it checked and where the URL came from. Other outcomes are `git-failed`, with git's `message`, and `outdated-contracts`, when the installed `@qawolf/api-contracts` is older than 0.148.0, the first version that redacts changes. More outcomes may be added in minor versions, and every outcome other than `collected` carries a `message`.
293
+
294
+ To only check what QA Wolf reads of a repository, call `codeHostIntegration.findForRepository`, which takes the same `repository`, `workspaceId`, `cwd` and `env` options and never fails: an answer it can't get has `coverage.status` `unknown`, with a `reason` and a `message`.
295
+
296
+ ```javascript
297
+ const { coverage } = await codeHostIntegration.findForRepository({
298
+ repository: { fullName: "acme/storefront", type: "full-name" },
299
+ });
300
+ if (coverage.status === "covered")
301
+ console.log(
302
+ `QA Wolf reads ${coverage.fullName} through ${coverage.provider}`,
303
+ );
304
+ ```
305
+
306
+ `coverage.status` is `covered`, with what QA Wolf may access (`permissions.code` and `permissions.pullRequests`), `not-covered`, `unsupported-host` or `unknown`. More values may be added in minor versions; treat one you don't handle like `unknown`.
307
+
308
+ `deployment.collectCommitChanges` stays as it is, for building `changes` yourself.
309
+
236
310
  ### Result
237
311
 
238
312
  `deployment.reportStatus` returns a discriminated union and never throws for an outcome you are expected to branch on. Branch on `outcome` alone:
@@ -772,7 +846,7 @@ A promotion usually settles within a minute or two. The SDK has no wait helper f
772
846
 
773
847
  ## Upload an App Build
774
848
 
775
- `uploadBuild` uploads an Android `.apk` or `.aab`, or an iOS `.ipa` file, up to 1 GB by default, and registers it as a QA Wolf build. QA Wolf reads the app ID, version and build number from the file, and runs that launch the app install the build.
849
+ `uploadBuild` uploads an Android `.apk` or `.aab`, an iOS `.ipa`, or a Linux Electron `.deb` or `.rpm` file, up to 1 GB by default, and registers it as a QA Wolf build. QA Wolf reads the app ID, version and build number from the file, and runs that launch the app install the build.
776
850
 
777
851
  ```ts
778
852
  import { makeQaWolfSdk } from "@qawolf/ci-sdk";
@@ -802,12 +876,12 @@ The parameters other than `filePath` are the input of the `build.create` contrac
802
876
 
803
877
  `uploadBuild` answers `{ outcome: "uploaded", build }`, where `build` carries the build's `id`, `appId`, `appName`, `platform`, `version`, `buildNumber`, `fileName`, `sizeBytes` and `url`. It never throws.
804
878
 
805
- | `outcome` | Meaning |
806
- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
807
- | `file-unreadable` | `filePath` does not name a readable file. Nothing was sent to QA Wolf. Carries `filePath`. |
808
- | `upload-rejected` | Storage refused the file's bytes, for example because the upload URL expired. Carries `buildId` and `httpStatus`. |
809
- | `upload-network-error` | The file's bytes never reached storage, or the connection dropped. Carries `buildId`. |
810
- | `invalid-request`, `unauthorized`, `not-found`, `conflict`, `server-error`, `unexpected-status`, `network-error`, `invalid-response-body` | QA Wolf refused or failed one of the two calls. `failedStep` says which: `request-upload` (for `invalid-request`, a file that is not an `.apk`, `.aab` or `.ipa`, or is over the workspace's limit, 1 GB by default) or `create` (for `invalid-request`, a file that is not an app, which also carries `buildId`). Same meanings as for `deployment.reportStatus`. |
879
+ | `outcome` | Meaning |
880
+ | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
881
+ | `file-unreadable` | `filePath` does not name a readable file. Nothing was sent to QA Wolf. Carries `filePath`. |
882
+ | `upload-rejected` | Storage refused the file's bytes, for example because the upload URL expired. Carries `buildId` and `httpStatus`. |
883
+ | `upload-network-error` | The file's bytes never reached storage, or the connection dropped. Carries `buildId`. |
884
+ | `invalid-request`, `unauthorized`, `not-found`, `conflict`, `server-error`, `unexpected-status`, `network-error`, `invalid-response-body` | QA Wolf refused or failed one of the two calls. `failedStep` says which: `request-upload` (for `invalid-request`, a file that is not an `.apk`, `.aab`, `.ipa`, `.deb` or `.rpm`, or is over the workspace's limit, 1 GB by default) or `create` (for `invalid-request`, a file that is not an app, which also carries `buildId`). Same meanings as for `deployment.reportStatus`. |
811
885
 
812
886
  A failed call creates no build. To retry, call `uploadBuild` again: each call uploads the file under a new build.
813
887
 
@@ -991,6 +1065,14 @@ This package follows the [SemVer](https://semver.org/) versioning scheme. Additi
991
1065
 
992
1066
  # Changelog
993
1067
 
1068
+ ## v3.8.0
1069
+
1070
+ - New `deployment.collectDeployChanges`, which builds `changes` for `deployment.reportStatus`: it collects the deploy's commits with their ids, messages and paths, including ones pushed straight to a branch that QA Wolf can't see, asks QA Wolf what it reads of the repository, runs your optional `filter`, and redacts secrets. A subject ending in `(#N)` is read as a squashed pull request only on GitHub. See [Collect a deploy's changes](#collect-deploy-changes).
1071
+ - New `codeHostIntegration.findForRepository`, which tells you what QA Wolf reads of a repository through your workspace's code host integrations, as `coverage.status`.
1072
+ - `detectProviderDeploymentId` recognizes Azure Pipelines. `CiSystem` now also allows other strings, since more CI systems may be added, so a `switch` over it needs a `default` case.
1073
+ - The `@qawolf/api-contracts` dependency floor is now `0.148.0`, the first version that redacts changes. With an older version installed, `collectDeployChanges` answers `outdated-contracts` and says which version to install; everything else works as before.
1074
+ - `deployment.collectCommitChanges` is unchanged.
1075
+
994
1076
  ## v3.7.0
995
1077
 
996
1078
  - `deployment.collectChanges` is renamed to `deployment.collectCommitChanges`, and its `CollectChangesParams` and `CollectChangesResult` types to `CollectCommitChangesParams` and `CollectCommitChangesResult`.