@qawolf/ci-sdk 3.7.1 → 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.
- package/README.md +82 -0
- package/dist/index.js +626 -81
- package/dist/index.js.map +4 -4
- package/dist/lib/sdk/defaults/contracts.d.ts +24 -0
- package/dist/lib/sdk/domain/collectCommitChanges/commitChange.d.ts +22 -0
- package/dist/lib/sdk/domain/collectCommitChanges/fitChanges.d.ts +17 -0
- package/dist/lib/sdk/domain/collectCommitChanges/parseLog.d.ts +7 -5
- package/dist/lib/sdk/domain/collectCommitChanges/readCommitRange.d.ts +32 -0
- package/dist/lib/sdk/domain/collectCommitChanges/summarizeCommits.d.ts +3 -6
- package/dist/lib/sdk/domain/collectDeployChanges/explainCollection.d.ts +8 -0
- package/dist/lib/sdk/domain/collectDeployChanges/filterChanges.d.ts +21 -0
- package/dist/lib/sdk/domain/collectDeployChanges/index.d.ts +18 -0
- package/dist/lib/sdk/domain/collectDeployChanges/isGitHubRepository.d.ts +8 -0
- package/dist/lib/sdk/domain/collectDeployChanges/sendableChanges.d.ts +8 -0
- package/dist/lib/sdk/domain/collectDeployChanges/testHarness.d.ts +46 -0
- package/dist/lib/sdk/domain/collectDeployChanges/types.d.ts +60 -0
- package/dist/lib/sdk/domain/detectProviderDeploymentId/ciSystems.d.ts +16 -0
- package/dist/lib/sdk/domain/detectProviderDeploymentId/index.d.ts +3 -4
- package/dist/lib/sdk/domain/repositoryCoverage/contracts.d.ts +10 -0
- package/dist/lib/sdk/domain/repositoryCoverage/findRepositoryCoverage.d.ts +17 -0
- package/dist/lib/sdk/domain/repositoryCoverage/identifyRepository.d.ts +44 -0
- package/dist/lib/sdk/domain/repositoryCoverage/index.d.ts +15 -0
- package/dist/lib/sdk/domain/repositoryCoverage/testHarness.d.ts +46 -0
- package/dist/lib/sdk/domain/repositoryCoverage/types.d.ts +73 -0
- package/dist/lib/sdk/index.d.ts +20 -8
- package/dist/tests/test-lib.d.ts +12 -8
- package/package.json +5 -5
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:
|
|
@@ -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`.
|