Skip to content

Commit d35e98e

Browse files
committed
addressed PR comments
1 parent 2433390 commit d35e98e

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

scripts/size_report/report_binary_size.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { resolve } from 'path';
1919
import * as fs from 'fs';
2020
import { execSync } from 'child_process';
2121
import * as terser from 'terser';
22-
import { upload, runId, RequestBody } from './size_report_helper';
22+
import {
23+
upload,
24+
runId,
25+
RequestBody,
26+
RequestEndpoint
27+
} from './size_report_helper';
2328

2429
interface Report {
2530
sdk: string;
@@ -136,9 +141,9 @@ function traverseDirs(
136141

137142
function makeReportObject(sdk: string, type: string, value: number): Report {
138143
return {
139-
sdk: sdk,
140-
type: type,
141-
value: value
144+
sdk,
145+
type,
146+
value
142147
};
143148
}
144149

@@ -164,4 +169,4 @@ function generateSizeReport(): BinarySizeRequestBody {
164169
}
165170

166171
const report = generateSizeReport();
167-
upload(report, 'reports');
172+
upload(report, RequestEndpoint.BINARY_SIZE);

scripts/size_report/report_modular_export_binary_size.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ import {
2121
} from '../../repo-scripts/size-analysis/analysis-helper';
2222
import { mapWorkspaceToPackages } from '../release/utils/workspace';
2323
import { projectRoot } from '../utils';
24-
import { upload, runId, RequestBody } from './size_report_helper';
24+
import {
25+
upload,
26+
runId,
27+
RequestBody,
28+
RequestEndpoint
29+
} from './size_report_helper';
2530
interface ModularExportBinarySizeRequestBody extends RequestBody {
2631
modules: Report[];
2732
}
2833

2934
async function generateReport(): Promise<ModularExportBinarySizeRequestBody> {
30-
const requestBody: ModularExportBinarySizeRequestBody = {
31-
log: `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${runId}`,
32-
modules: []
33-
};
34-
3535
let allModulesLocation: string[] = await mapWorkspaceToPackages([
3636
`${projectRoot}/packages-exp/*`
3737
]);
@@ -46,17 +46,15 @@ async function generateReport(): Promise<ModularExportBinarySizeRequestBody> {
4646
});
4747

4848
const reports: Report[] = await generateReportForModules(allModulesLocation);
49-
50-
for (const report of reports) {
51-
requestBody.modules.push(report);
52-
}
53-
54-
return requestBody;
49+
return {
50+
log: `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${runId}`,
51+
modules: reports
52+
};
5553
}
5654

5755
async function main(): Promise<void> {
5856
const reports: ModularExportBinarySizeRequestBody = await generateReport();
5957
console.log(JSON.stringify(reports, null, 4));
60-
upload(reports, 'size_analysis');
58+
upload(reports, RequestEndpoint.MODULAR_EXPORT_BINARY_SIZE);
6159
}
6260
main();

scripts/size_report/size_report_helper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ import * as https from 'https';
2121
export interface RequestBody {
2222
log: string;
2323
}
24+
export enum RequestEndpoint {
25+
MODULAR_EXPORT_BINARY_SIZE = 'size_analysis',
26+
BINARY_SIZE = 'reports'
27+
}
2428
export const runId = process.env.GITHUB_RUN_ID || 'local-run-id';
2529

26-
export const METRICS_SERVICE_URL = process.env.METRICS_SERVICE_URL!;
30+
const METRICS_SERVICE_URL = process.env.METRICS_SERVICE_URL!;
2731

28-
export function constructRequestPath(requestEndpoint: string): string {
32+
function constructRequestPath(requestEndpoint: string): string {
2933
const repo = process.env.GITHUB_REPOSITORY;
3034
const commit = process.env.GITHUB_SHA;
3135
let path = `/repos/${repo}/commits/${commit}/${requestEndpoint}`;
@@ -41,7 +45,7 @@ export function constructRequestPath(requestEndpoint: string): string {
4145
return path;
4246
}
4347

44-
export function constructRequestOptions(path: string) {
48+
function constructRequestOptions(path: string) {
4549
const accessToken = execSync('gcloud auth print-identity-token', {
4650
encoding: 'utf8'
4751
}).trim();

0 commit comments

Comments
 (0)