@code-pushup/ci 0.53.1 → 0.54.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 +11 -11
- package/index.js +11 -7
- package/package.json +3 -3
- package/src/lib/models.d.ts +2 -2
package/README.md
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
This package exports **provider-agnostic core logic for running Code PushUp in CI pipelines**. It serves as the base for the following provider integrations:
|
|
16
16
|
|
|
17
|
-
| |
|
|
18
|
-
| :------------- |
|
|
19
|
-
| GitHub Actions | [`code-pushup/github-action`](https://github.com/marketplace/actions/code-pushup)
|
|
20
|
-
| GitLab CI/CD |
|
|
17
|
+
| | |
|
|
18
|
+
| :------------- | :-------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| GitHub Actions | [`code-pushup/github-action`](https://github.com/marketplace/actions/code-pushup) |
|
|
20
|
+
| GitLab CI/CD | [`code-pushup/gitlab-pipelines-template`](https://gitlab.com/code-pushup/gitlab-pipelines-template) |
|
|
21
21
|
|
|
22
22
|
## Setup
|
|
23
23
|
|
|
@@ -74,13 +74,13 @@ This will additionally compare reports from both source and target branches and
|
|
|
74
74
|
The PR flow requires interacting with the Git provider's API to post a comparison comment.
|
|
75
75
|
Wrap these requests in functions and pass them in as an object which configures the provider.
|
|
76
76
|
|
|
77
|
-
| Property | Required | Type | Description
|
|
78
|
-
| :----------------------- | :------: | :----------------------------------------------- |
|
|
79
|
-
| `createComment` | yes | `(body: string) => Promise<Comment>` | Posts a new comment to PR
|
|
80
|
-
| `updateComment` | yes | `(id: number, body: string) => Promise<Comment>` | Updates existing PR comment
|
|
81
|
-
| `listComments` | yes | `() => Promise<Comment[]>` | Fetches all comments from PR
|
|
82
|
-
| `maxCommentChars` | yes | `number` | Character limit for comment body
|
|
83
|
-
| `downloadReportArtifact` | no | `() => Promise<string \| null>`
|
|
77
|
+
| Property | Required | Type | Description |
|
|
78
|
+
| :----------------------- | :------: | :----------------------------------------------- | :------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
+
| `createComment` | yes | `(body: string) => Promise<Comment>` | Posts a new comment to PR |
|
|
80
|
+
| `updateComment` | yes | `(id: number, body: string) => Promise<Comment>` | Updates existing PR comment |
|
|
81
|
+
| `listComments` | yes | `() => Promise<Comment[]>` | Fetches all comments from PR |
|
|
82
|
+
| `maxCommentChars` | yes | `number` | Character limit for comment body |
|
|
83
|
+
| `downloadReportArtifact` | no | `(project?: string) => Promise<string \| null>` | Fetches previous (root/project) `report.json` for base branch and returns path, used as cache to speed up comparison |
|
|
84
84
|
|
|
85
85
|
A `Comment` object has the following required properties:
|
|
86
86
|
|
package/index.js
CHANGED
|
@@ -113,7 +113,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
113
113
|
message: `The filename has to be valid`
|
|
114
114
|
}).min(1, { message: "file name is invalid" });
|
|
115
115
|
var positiveIntSchema = z.number().int().positive();
|
|
116
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
117
116
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
118
117
|
function packageVersionSchema(options) {
|
|
119
118
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -662,7 +661,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
662
661
|
z16.object({
|
|
663
662
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
664
663
|
z16.object({
|
|
665
|
-
diff: z16.number().
|
|
664
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
666
665
|
})
|
|
667
666
|
).describe("Audit `value` comparison"),
|
|
668
667
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -756,6 +755,7 @@ function executeProcess(cfg) {
|
|
|
756
755
|
return new Promise((resolve, reject) => {
|
|
757
756
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
758
757
|
shell: true,
|
|
758
|
+
windowsHide: true,
|
|
759
759
|
...options
|
|
760
760
|
});
|
|
761
761
|
let stdout = "";
|
|
@@ -1611,7 +1611,7 @@ async function runOnProject(args) {
|
|
|
1611
1611
|
return noDiffOutput;
|
|
1612
1612
|
}
|
|
1613
1613
|
logger.info(
|
|
1614
|
-
`PR detected, preparing to compare base branch ${base.ref} to head ${head.ref}`
|
|
1614
|
+
`PR/MR detected, preparing to compare base branch ${base.ref} to head ${head.ref}`
|
|
1615
1615
|
);
|
|
1616
1616
|
const prevReport = await collectPreviousReport({ ...args, base, ctx });
|
|
1617
1617
|
if (!prevReport) {
|
|
@@ -1652,9 +1652,13 @@ async function runOnProject(args) {
|
|
|
1652
1652
|
return { ...diffOutput, newIssues };
|
|
1653
1653
|
}
|
|
1654
1654
|
async function collectPreviousReport(args) {
|
|
1655
|
-
const { base, api, settings, ctx, git } = args;
|
|
1655
|
+
const { project, base, api, settings, ctx, git } = args;
|
|
1656
1656
|
const logger = settings.logger;
|
|
1657
|
-
const cachedBaseReport = await api.downloadReportArtifact?.()
|
|
1657
|
+
const cachedBaseReport = await api.downloadReportArtifact?.(project?.name).catch((error) => {
|
|
1658
|
+
logger.warn(
|
|
1659
|
+
`Error when downloading previous report artifact, skipping - ${stringifyError(error)}`
|
|
1660
|
+
);
|
|
1661
|
+
});
|
|
1658
1662
|
if (api.downloadReportArtifact != null) {
|
|
1659
1663
|
logger.info(
|
|
1660
1664
|
`Previous report artifact ${cachedBaseReport ? "found" : "not found"}`
|
|
@@ -1687,7 +1691,7 @@ async function collectPreviousReport(args) {
|
|
|
1687
1691
|
const prevReport = await fs.readFile(prevReportPath, "utf8");
|
|
1688
1692
|
logger.debug(`Collected previous report at ${prevReportPath}`);
|
|
1689
1693
|
await git.checkout(["-f", "-"]);
|
|
1690
|
-
logger.info("Switched back to PR branch");
|
|
1694
|
+
logger.info("Switched back to PR/MR branch");
|
|
1691
1695
|
return prevReport;
|
|
1692
1696
|
}
|
|
1693
1697
|
}
|
|
@@ -1706,7 +1710,7 @@ async function findNewIssues(args) {
|
|
|
1706
1710
|
changedFiles
|
|
1707
1711
|
});
|
|
1708
1712
|
logger.debug(
|
|
1709
|
-
`Found ${issues.length} relevant issues for ${Object.keys(changedFiles).length} changed files
|
|
1713
|
+
`Found ${issues.length} relevant issues for ${Object.keys(changedFiles).length} changed files`
|
|
1710
1714
|
);
|
|
1711
1715
|
return issues;
|
|
1712
1716
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/ci",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "CI automation logic for Code PushUp (provider-agnostic)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/ci#readme",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"main": "./index.js",
|
|
29
29
|
"types": "./src/index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@code-pushup/models": "0.
|
|
32
|
-
"@code-pushup/utils": "0.
|
|
31
|
+
"@code-pushup/models": "0.54.0",
|
|
32
|
+
"@code-pushup/utils": "0.54.0",
|
|
33
33
|
"glob": "^10.4.5",
|
|
34
34
|
"simple-git": "^3.20.0",
|
|
35
35
|
"yaml": "^2.5.1"
|
package/src/lib/models.d.ts
CHANGED
|
@@ -33,13 +33,13 @@ export type GitRefs = {
|
|
|
33
33
|
*/
|
|
34
34
|
export type ProviderAPIClient = {
|
|
35
35
|
maxCommentChars: number;
|
|
36
|
-
downloadReportArtifact?: () => Promise<string | null>;
|
|
36
|
+
downloadReportArtifact?: (project?: string) => Promise<string | null>;
|
|
37
37
|
listComments: () => Promise<Comment[]>;
|
|
38
38
|
updateComment: (id: number, body: string) => Promise<Comment>;
|
|
39
39
|
createComment: (body: string) => Promise<Comment>;
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
|
-
* PR comment from {@link ProviderAPIClient}
|
|
42
|
+
* PR/MR comment from {@link ProviderAPIClient}
|
|
43
43
|
*/
|
|
44
44
|
export type Comment = {
|
|
45
45
|
id: number;
|