-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make commit information opt-in (#107)
* Make commit information optional * Adapt tests --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d543a0b
commit 6717873
Showing
13 changed files
with
190 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
"@siteimprove/alfa-test-utils": minor | ||
--- | ||
|
||
**Breaking:** `CommitInformation` is now optional and some of its properties have been rennamed; see the package's changelog for explanations and migration advice. | ||
|
||
Previously, `SIP.upload` was automatically collecting some information about the latest `git` commit and sending it to the Siteimprove Intelligence Platform, unless opted out via the `includeGitInfo: false` option. This presented two main drawbacks: | ||
|
||
1. (minor) This was heavily reliant on the directory being part of a `git` repository. For codebases that use a different version control system, not only this was useless, but no alternative was provided. | ||
2. (major) This was heavily reliant on the Accessibility Code Checker running from a NodeJS environment, where access to the underlying filesystem and `git` was doable. Not only this prevented the Accessibility Code Checker to run seamlessly from other environments such as browser extensions or Cypress; but the mere fact of trying to bundle `SIP.upload` for such environments (e.g. with Webpack) was causing the build to fail. | ||
|
||
As a consequence, this release reverts a bit the approach on that information. The commit information is still valuable and can be used to name or group tests in an organised way (e.g., to follow the number of issues in a feature branch), but it now has to be provided by the caller. A `git` helper is still provided since it is by far the most used version control system. | ||
|
||
Concretely, the following changes have been made: | ||
|
||
1. The `CommitInformation.GitOrigin` field has been renamed `CommitInformation.Origin`. | ||
2. `SIP.upload` now accepts a `commitInformation` option, of type `CommitInformation`; this in an object that must at least contain a `BranchName` field with a string value. (note the starting uppercase in `BranchName`). | ||
3. If no `commitInformation` is provided, but the `testName` is a function, it will resolve to the default "Unnamed" test. | ||
4. The `includeGitInfo` options of `SIP.upload` has been removed; if a `CommitInformation` has been provided, it will automatically be uploaded. | ||
|
||
In order to migrate from previous versions: | ||
|
||
1. If you were using `includeGitInfo: false` to opt-out of it, simply remove the option as it is now an opt-in information. | ||
2. If you were using a `testName` function; you need to provide the commit information to the call. For this, use: | ||
|
||
````typescript | ||
import { getCommitInformation } from "@siteimprove/alfa-test-utils/git.js"; | ||
|
||
const gitInformation = await getCommitInformation(); | ||
|
||
SIP.upload({ | ||
... // other options | ||
commitInformation: gitInformation, | ||
testName: (commitInfo) => ... // same function as previously | ||
}) | ||
``` | ||
3. If you were not previously relying on the commit information but wish to keep uploading it, use: | ||
````typescript | ||
import { getCommitInformation } from "@siteimprove/alfa-test-utils/git.js"; | ||
|
||
const gitInformation = await getCommitInformation(); | ||
|
||
SIP.upload({ | ||
... // other options | ||
commitInformation: gitInformation, | ||
}) | ||
``` | ||
|
||
Siteimprove recommends that you provide some basic commit information as it opens possibilities for filtering of the results and better reporting in the Siteimprove Intelligence Platform. As of November 2024, we are currently not relying on this information in any place, but it is likely that we will provide features using it in the future; therefore it might be easier to start providing it immediately instead of revisiting the codebase later. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Global structure of a version control metadata. | ||
* | ||
* @remarks | ||
* This is mostly modelled after git, but should work fine with other VCS like | ||
* svn or cvs. Notably, only the branch name is mandatory. | ||
* | ||
* @public | ||
*/ | ||
export interface CommitInformation { | ||
/** | ||
* The origin's URL. This may vary depending on whether the repository was cloned | ||
* using `http` or `ssh` protocol. | ||
*/ | ||
Origin?: string; | ||
/** | ||
* The name of the current branch. | ||
*/ | ||
BranchName: string; | ||
/** | ||
* The hash of the latest commit. | ||
*/ | ||
CommitHash?: string; | ||
/** | ||
* The name of the author of the latest commit. | ||
*/ | ||
Author?: string; | ||
/** | ||
* The email of the author of the latest commit. | ||
*/ | ||
Email?: string; | ||
/** | ||
* The timestamp of the latest commit. | ||
*/ | ||
CommitTimestamp?: string; | ||
/** | ||
* The message of the latest commit. | ||
*/ | ||
Message?: string; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
export * from "./git.js"; | ||
// git.js **MUST NOT** be re-exported automatically | ||
// It depends on simple-git, that runs in Node and uses node-specific functions | ||
// imported through the `node:` protocol. | ||
// Due to this: | ||
// 1. It cannot properly run in other environments, like the browser; thus | ||
// making it useless for browser extensions, and hard to use in Cypress. | ||
// 2. The mere fact of trying to bundle it for such environments (with Webpack or | ||
// the likes) may crash the bundler. | ||
// Therefore, we do not export it as part of the main package. It is still | ||
// provided as a separate helper with its own `exports` path and has to be | ||
// explicitly included in projects that need it. | ||
// export * from "./git.js"; | ||
|
||
export * from "./commit-information.js" | ||
export * from "./logging.js"; | ||
export * from "./sip.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.