@code-pushup/ci 0.53.0 → 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 +13 -8
- package/package.json +20 -11
- 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
|
@@ -19,7 +19,7 @@ var MAX_ISSUE_MESSAGE_LENGTH = 1024;
|
|
|
19
19
|
var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
|
|
20
20
|
var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
|
|
21
21
|
function hasDuplicateStrings(strings) {
|
|
22
|
-
const sortedStrings =
|
|
22
|
+
const sortedStrings = strings.toSorted();
|
|
23
23
|
const duplStrings = sortedStrings.filter(
|
|
24
24
|
(item, index) => index !== 0 && item === sortedStrings[index - 1]
|
|
25
25
|
);
|
|
@@ -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 = "";
|
|
@@ -1562,6 +1562,7 @@ async function runInCI(refs, api, options, git = simpleGit4()) {
|
|
|
1562
1562
|
diffArtifact
|
|
1563
1563
|
};
|
|
1564
1564
|
}
|
|
1565
|
+
return { mode: "monorepo", projects: projectResults };
|
|
1565
1566
|
}
|
|
1566
1567
|
logger.info("Running Code PushUp in standalone project mode");
|
|
1567
1568
|
const { artifacts, newIssues } = await runOnProject({
|
|
@@ -1610,7 +1611,7 @@ async function runOnProject(args) {
|
|
|
1610
1611
|
return noDiffOutput;
|
|
1611
1612
|
}
|
|
1612
1613
|
logger.info(
|
|
1613
|
-
`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}`
|
|
1614
1615
|
);
|
|
1615
1616
|
const prevReport = await collectPreviousReport({ ...args, base, ctx });
|
|
1616
1617
|
if (!prevReport) {
|
|
@@ -1651,9 +1652,13 @@ async function runOnProject(args) {
|
|
|
1651
1652
|
return { ...diffOutput, newIssues };
|
|
1652
1653
|
}
|
|
1653
1654
|
async function collectPreviousReport(args) {
|
|
1654
|
-
const { base, api, settings, ctx, git } = args;
|
|
1655
|
+
const { project, base, api, settings, ctx, git } = args;
|
|
1655
1656
|
const logger = settings.logger;
|
|
1656
|
-
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
|
+
});
|
|
1657
1662
|
if (api.downloadReportArtifact != null) {
|
|
1658
1663
|
logger.info(
|
|
1659
1664
|
`Previous report artifact ${cachedBaseReport ? "found" : "not found"}`
|
|
@@ -1686,7 +1691,7 @@ async function collectPreviousReport(args) {
|
|
|
1686
1691
|
const prevReport = await fs.readFile(prevReportPath, "utf8");
|
|
1687
1692
|
logger.debug(`Collected previous report at ${prevReportPath}`);
|
|
1688
1693
|
await git.checkout(["-f", "-"]);
|
|
1689
|
-
logger.info("Switched back to PR branch");
|
|
1694
|
+
logger.info("Switched back to PR/MR branch");
|
|
1690
1695
|
return prevReport;
|
|
1691
1696
|
}
|
|
1692
1697
|
}
|
|
@@ -1705,7 +1710,7 @@ async function findNewIssues(args) {
|
|
|
1705
1710
|
changedFiles
|
|
1706
1711
|
});
|
|
1707
1712
|
logger.debug(
|
|
1708
|
-
`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`
|
|
1709
1714
|
);
|
|
1710
1715
|
return issues;
|
|
1711
1716
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
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
|
-
"dependencies": {
|
|
6
|
-
"@code-pushup/models": "0.53.0",
|
|
7
|
-
"@code-pushup/utils": "0.53.0",
|
|
8
|
-
"glob": "^10.4.5",
|
|
9
|
-
"simple-git": "^3.20.0",
|
|
10
|
-
"yaml": "^2.5.1"
|
|
11
|
-
},
|
|
12
5
|
"license": "MIT",
|
|
13
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/ci#readme",
|
|
14
7
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/code-pushup/cli/issues"
|
|
8
|
+
"url": "https://github.com/code-pushup/cli/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3A\"🧩%20ci\""
|
|
16
9
|
},
|
|
17
10
|
"repository": {
|
|
18
11
|
"type": "git",
|
|
19
12
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
20
13
|
"directory": "packages/ci"
|
|
21
14
|
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"Code PushUp",
|
|
17
|
+
"CI integration",
|
|
18
|
+
"automation",
|
|
19
|
+
"KPI tracking",
|
|
20
|
+
"tech debt",
|
|
21
|
+
"automated feedback",
|
|
22
|
+
"regression guard"
|
|
23
|
+
],
|
|
22
24
|
"publishConfig": {
|
|
23
25
|
"access": "public"
|
|
24
26
|
},
|
|
25
27
|
"type": "module",
|
|
26
28
|
"main": "./index.js",
|
|
27
|
-
"types": "./src/index.d.ts"
|
|
28
|
-
|
|
29
|
+
"types": "./src/index.d.ts",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@code-pushup/models": "0.54.0",
|
|
32
|
+
"@code-pushup/utils": "0.54.0",
|
|
33
|
+
"glob": "^10.4.5",
|
|
34
|
+
"simple-git": "^3.20.0",
|
|
35
|
+
"yaml": "^2.5.1"
|
|
36
|
+
}
|
|
37
|
+
}
|
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;
|