Skip to content

Commit e3da2dd

Browse files
committed
feat(ci): download report from graphql api and convert to report.json format
1 parent fe6ca01 commit e3da2dd

File tree

10 files changed

+727
-8
lines changed

10 files changed

+727
-8
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"node": ">=22.14"
2323
},
2424
"dependencies": {
25-
"@code-pushup/portal-client": "^0.13.0",
25+
"@code-pushup/portal-client": "^0.14.3",
2626
"@isaacs/cliui": "^8.0.2",
2727
"@nx/devkit": "19.8.13",
2828
"@poppinss/cliui": "6.4.1",

packages/ci/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"type": "module",
2828
"dependencies": {
2929
"@code-pushup/models": "0.70.0",
30+
"@code-pushup/portal-client": "^0.14.3",
3031
"@code-pushup/utils": "0.70.0",
3132
"glob": "^11.0.1",
3233
"simple-git": "^3.20.0",
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`transformGQLReport > should convert full GraphQL report to valid report.json format 1`] = `
4+
{
5+
"categories": [
6+
{
7+
"isBinary": false,
8+
"refs": [
9+
{
10+
"plugin": "eslint",
11+
"slug": "suggestions",
12+
"type": "group",
13+
"weight": 1,
14+
},
15+
],
16+
"slug": "code-style",
17+
"title": "Code style",
18+
},
19+
{
20+
"isBinary": false,
21+
"refs": [
22+
{
23+
"plugin": "bundle-stats",
24+
"slug": "initial",
25+
"type": "audit",
26+
"weight": 1,
27+
},
28+
],
29+
"slug": "bundle-size",
30+
"title": "Bundle size",
31+
},
32+
],
33+
"commit": {
34+
"author": "John Doe <[email protected]>",
35+
"date": 2025-08-01T00:00:00.000Z,
36+
"hash": "4da737d63efcc83d0dd05620801f195968611eb7",
37+
"message": "Apply suggestions from code review",
38+
},
39+
"date": "2025-08-01T00:10:00.000Z",
40+
"duration": 30000,
41+
"packageName": "@code-pushup/core",
42+
"plugins": [
43+
{
44+
"audits": [
45+
{
46+
"details": {
47+
"issues": [
48+
{
49+
"message": "File has too many lines (420). Maximum allowed is 300.",
50+
"severity": "warning",
51+
"source": {
52+
"file": "src/main.ts",
53+
"position": {
54+
"endLine": 420,
55+
"startLine": 301,
56+
},
57+
},
58+
},
59+
],
60+
},
61+
"displayValue": "1 warning",
62+
"score": 0,
63+
"slug": "max-lines",
64+
"title": "Enforce a maximum number of lines per file",
65+
"value": 1,
66+
},
67+
{
68+
"details": {},
69+
"displayValue": "passed",
70+
"score": 1,
71+
"slug": "max-lines-per-function",
72+
"title": "Enforce a maximum number of lines of code per function",
73+
"value": 0,
74+
},
75+
],
76+
"date": "2025-08-01T00:10:00.000Z",
77+
"duration": 20000,
78+
"groups": [
79+
{
80+
"refs": [
81+
{
82+
"slug": "max-lines",
83+
"weight": 1,
84+
},
85+
{
86+
"slug": "max-lines-per-function",
87+
"weight": 1,
88+
},
89+
],
90+
"slug": "suggestions",
91+
"title": "Suggestion",
92+
},
93+
],
94+
"icon": "eslint",
95+
"packageName": "@code-pushup/eslint-plugin",
96+
"slug": "eslint",
97+
"title": "ESLint",
98+
"version": "0.42.0",
99+
},
100+
{
101+
"audits": [
102+
{
103+
"details": {
104+
"issues": [
105+
{
106+
"message": "\`main.js\` is **420 kB**, exceeds warning threshold of 350 kB",
107+
"severity": "warning",
108+
},
109+
],
110+
"table": {
111+
"columns": [
112+
{
113+
"align": "left",
114+
"key": "0",
115+
"label": "Group",
116+
},
117+
{
118+
"align": "right",
119+
"key": "1",
120+
"label": "Size",
121+
},
122+
{
123+
"align": "right",
124+
"key": "2",
125+
"label": "Modules",
126+
},
127+
],
128+
"rows": [
129+
{
130+
"0": "3rd-party packages",
131+
"1": "321.4 kB",
132+
"2": "101",
133+
},
134+
{
135+
"0": "Application shell",
136+
"1": "98.6 kB",
137+
"2": "7",
138+
},
139+
],
140+
},
141+
"trees": [
142+
{
143+
"root": {
144+
"children": [
145+
{
146+
"children": [
147+
{
148+
"children": [
149+
{
150+
"children": [
151+
{
152+
"name": "src/main.ts",
153+
"values": {
154+
"size": "275 kB",
155+
},
156+
},
157+
{
158+
"name": "src/utils/format.ts",
159+
"values": {
160+
"size": "120 kB",
161+
},
162+
},
163+
{
164+
"name": "src/utils/math.ts",
165+
"values": {
166+
"size": "25 kB",
167+
},
168+
},
169+
],
170+
"name": "inputs",
171+
},
172+
],
173+
"name": "dist/main.js",
174+
"values": {
175+
"size": "420 kB",
176+
},
177+
},
178+
],
179+
"name": "outputs",
180+
},
181+
],
182+
"name": "stats.json",
183+
},
184+
"type": "basic",
185+
},
186+
],
187+
},
188+
"displayValue": "420 kB",
189+
"score": 0.75,
190+
"slug": "initial",
191+
"title": "Initial JavaScript bundle",
192+
"value": 420000,
193+
},
194+
],
195+
"date": "2025-08-01T00:10:20.000Z",
196+
"duration": 10000,
197+
"groups": [],
198+
"icon": "javascript-map",
199+
"slug": "bundle-stats",
200+
"title": "Bundle stats",
201+
},
202+
],
203+
"version": "0.42.0",
204+
}
205+
`;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
type PortalDownloadArgs,
3+
downloadFromPortal,
4+
} from '@code-pushup/portal-client';
5+
import { transformGQLReport } from './transform.js';
6+
7+
export async function downloadReportFromPortal(
8+
args: PortalDownloadArgs,
9+
): Promise<string | undefined> {
10+
const gqlReport = await downloadFromPortal(args);
11+
if (!gqlReport) {
12+
return undefined;
13+
}
14+
const report = transformGQLReport(gqlReport);
15+
return JSON.stringify(report, null, 2);
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { downloadReportFromPortal } from './download.js';

0 commit comments

Comments
 (0)