Skip to content

Commit

Permalink
allow specifying whether we have bytecode size in bytes or opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Sep 24, 2024
1 parent 3fb8440 commit 8da4b0f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
11 changes: 8 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ const formatBrilligRows = (diffs, summaryQuantile = 0.8) => {
exports.formatBrilligRows = formatBrilligRows;
const formatMarkdownDiff = (header, repository, commitHash, summaryRows, fullReportRows,
// Flag to distinguish the markdown columns that should be used
circuitReport, refCommitHash, summaryQuantile = 0.8) => {
circuitReport, brillig_report_bytes, refCommitHash, summaryQuantile = 0.8) => {
const diffReport = [header, "", (0, utils_1.generateCommitInfo)(repository, commitHash, refCommitHash)];
if (fullReportRows.length === 0)
return diffReport.concat(["", "### There are no changes in circuit sizes"]).join("\n").trim();
return diffReport.concat(["", "### There are no changes in sizes"]).join("\n").trim();
let MARKDOWN_SUMMARY_COLS;
let MARKDOWN_DIFF_COLS;
if (circuitReport) {
Expand All @@ -256,6 +256,10 @@ circuitReport, refCommitHash, summaryQuantile = 0.8) => {
else {
MARKDOWN_SUMMARY_COLS = MARKDOWN_SUMMARY_COLS_BRILLIG;
MARKDOWN_DIFF_COLS = MARKDOWN_DIFF_COLS_BRILLIG;
if (brillig_report_bytes) {
MARKDOWN_SUMMARY_COLS[2].txt = "Bytecode size in bytes (+/-)";
MARKDOWN_DIFF_COLS[2].txt = "Bytecode size in bytes (+/-)";
}
}
const summaryHeader = MARKDOWN_SUMMARY_COLS.map((entry) => entry.txt)
.join(" | ")
Expand Down Expand Up @@ -396,6 +400,7 @@ const token = process.env.GITHUB_TOKEN || core.getInput("token");
const report = core.getInput("report");
const header = core.getInput("header");
const brillig_report = core.getInput("brillig_report");
const brillig_report_bytes = core.getInput("brillig_report_bytes");
const summaryQuantile = parseFloat(core.getInput("summaryQuantile"));
// const sortCriteria = core.getInput("sortCriteria").split(",");
// const sortOrders = core.getInput("sortOrders").split(",");
Expand Down Expand Up @@ -512,7 +517,7 @@ function run() {
}
core.info(`Format markdown of ${numDiffs} diffs`);
// const [summaryRows, fullReportRows] = formatCircuitRows(diffCircuitRows, summaryQuantile);
const markdown = (0, program_1.formatMarkdownDiff)(header, repository, github_1.context.sha, summaryRows, fullReportRows, !brillig_report, refCommitHash, summaryQuantile);
const markdown = (0, program_1.formatMarkdownDiff)(header, repository, github_1.context.sha, summaryRows, fullReportRows, !brillig_report, brillig_report_bytes == "true", refCommitHash, summaryQuantile);
core.info(`Format shell of ${numDiffs} diffs`);
let shell;
if (brillig_report) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/format/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ export const formatMarkdownDiff = (
fullReportRows: string[],
// Flag to distinguish the markdown columns that should be used
circuitReport: boolean,
brillig_report_bytes: boolean,
refCommitHash?: string,
summaryQuantile = 0.8
) => {
const diffReport = [header, "", generateCommitInfo(repository, commitHash, refCommitHash)];
if (fullReportRows.length === 0)
return diffReport.concat(["", "### There are no changes in circuit sizes"]).join("\n").trim();
return diffReport.concat(["", "### There are no changes in sizes"]).join("\n").trim();

let MARKDOWN_SUMMARY_COLS;
let MARKDOWN_DIFF_COLS;
Expand All @@ -404,6 +405,10 @@ export const formatMarkdownDiff = (
} else {
MARKDOWN_SUMMARY_COLS = MARKDOWN_SUMMARY_COLS_BRILLIG;
MARKDOWN_DIFF_COLS = MARKDOWN_DIFF_COLS_BRILLIG;
if (brillig_report_bytes) {
MARKDOWN_SUMMARY_COLS[2].txt = "Bytecode size in bytes (+/-)";
MARKDOWN_DIFF_COLS[2].txt = "Bytecode size in bytes (+/-)";
}
}

const summaryHeader = MARKDOWN_SUMMARY_COLS.map((entry) => entry.txt)
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const token = process.env.GITHUB_TOKEN || core.getInput("token");
const report = core.getInput("report");
const header = core.getInput("header");
const brillig_report = core.getInput("brillig_report");
const brillig_report_bytes = core.getInput("brillig_report_bytes");
const summaryQuantile = parseFloat(core.getInput("summaryQuantile"));
// const sortCriteria = core.getInput("sortCriteria").split(",");
// const sortOrders = core.getInput("sortOrders").split(",");
Expand Down Expand Up @@ -149,6 +150,7 @@ async function run() {
summaryRows,
fullReportRows,
!brillig_report,
brillig_report_bytes == "true",
refCommitHash,
summaryQuantile
);
Expand Down
6 changes: 5 additions & 1 deletion tests/program_report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe("Markdown format", () => {
summaryRows,
fullReportRows,
true,
false,
undefined,
0.8
)
Expand All @@ -70,6 +71,7 @@ describe("Markdown format", () => {
summaryRowsBrillig,
fullReportRowsBrillig,
false,
false,
undefined,
0.8
)
Expand All @@ -92,7 +94,8 @@ describe("Markdown format", () => {
"d62d23148ca73df77cd4378ee1b3c17f1f303dbf",
summaryRows,
fullReportRows,
true
true,
false
)
);

Expand All @@ -106,6 +109,7 @@ describe("Markdown format", () => {
summaryRowsBrillig,
fullReportRowsBrillig,
false,
false,
undefined,
0.8
)
Expand Down

0 comments on commit 8da4b0f

Please sign in to comment.