Skip to content

Commit

Permalink
check numDiffs for posting markdown not diffCircuitRows.length
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Sep 25, 2024
1 parent ef8aaf4 commit ca7ea34
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const formatShellBrilligRows = (diffs, summaryQuantile = 0.8) => {
return [summaryRows, fullReportRows];
};
exports.formatShellBrilligRows = formatShellBrilligRows;
const formatShellDiffBrillig = (diffs, summaryRows, fullReportRows, summaryQuantile = 0.8) => {
const formatShellDiffBrillig = (diffs, summaryRows, fullReportRows, brillig_report_bytes, summaryQuantile = 0.8) => {
const maxProgramLength = Math.max(8, ...diffs.map(({ name }) => name.length));
const SHELL_SUMMARY_COLS = [
{ txt: "", length: 0 },
Expand All @@ -128,6 +128,10 @@ const formatShellDiffBrillig = (diffs, summaryRows, fullReportRows, summaryQuant
{ txt: "Brillig opcodes (+/-)", length: 33 },
{ txt: "", length: 0 },
];
if (brillig_report_bytes) {
SHELL_SUMMARY_COLS[2].txt = "Bytecode size in bytes (+/-)";
SHELL_DIFF_COLS[2].txt = "Bytecode size in bytes (+/-)";
}
const summaryHeader = SHELL_SUMMARY_COLS.map((entry) => colors_1.default.bold((0, utils_1.center)(entry.txt, entry.length || 0)))
.join(" | ")
.trim();
Expand Down Expand Up @@ -523,7 +527,7 @@ function run() {
if (brillig_report) {
core.info(`Format Brillig diffs`);
const [summaryRowsShell, fullReportRowsShell] = (0, program_1.formatShellBrilligRows)(diffBrilligRows, summaryQuantile);
shell = (0, program_1.formatShellDiffBrillig)(diffCircuitRows, summaryRowsShell, fullReportRowsShell, summaryQuantile);
shell = (0, program_1.formatShellDiffBrillig)(diffCircuitRows, summaryRowsShell, fullReportRowsShell, brillig_report_bytes == "true", summaryQuantile);
}
else {
core.info(`Format ACIR diffs`);
Expand All @@ -532,7 +536,7 @@ function run() {
}
core.endGroup();
console.log(shell);
if (diffCircuitRows.length > 0) {
if (numDiffs > 0) {
core.setOutput("shell", shell);
core.setOutput("markdown", markdown);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/format/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const formatShellDiffBrillig = (
diffs: DiffBrillig[],
summaryRows: string[],
fullReportRows: string[],
brillig_report_bytes: boolean,
summaryQuantile = 0.8
) => {
const maxProgramLength = Math.max(8, ...diffs.map(({ name }) => name.length));
Expand All @@ -209,6 +210,11 @@ export const formatShellDiffBrillig = (
{ txt: "", length: 0 },
];

if (brillig_report_bytes) {
SHELL_SUMMARY_COLS[2].txt = "Bytecode size in bytes (+/-)";
SHELL_DIFF_COLS[2].txt = "Bytecode size in bytes (+/-)";
}

const summaryHeader = SHELL_SUMMARY_COLS.map((entry) =>
colors.bold(center(entry.txt, entry.length || 0))
)
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ async function run() {
diffCircuitRows,
summaryRowsShell,
fullReportRowsShell,
brillig_report_bytes == "true",
summaryQuantile
);
} else {
Expand All @@ -187,7 +188,7 @@ async function run() {

console.log(shell);

if (diffCircuitRows.length > 0) {
if (numDiffs > 0) {
core.setOutput("shell", shell);
core.setOutput("markdown", markdown);
}
Expand Down
16 changes: 12 additions & 4 deletions tests/program_report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ describe("Shell format", () => {
console.log(formatShellDiff(circuitDiffs, summaryRows, fullReportRows));

const [summaryRowsBrillig, fullReportRowsBrillig] = formatShellBrilligRows(brilligDiffs);
console.log(formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig));
console.log(
formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig, false)
);
});

it("should compare 1 to 2", () => {
Expand All @@ -143,7 +145,9 @@ describe("Shell format", () => {
console.log(formatShellDiff(circuitDiffs, summaryRows, fullReportRows));

const [summaryRowsBrillig, fullReportRowsBrillig] = formatShellBrilligRows(brilligDiffs);
console.log(formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig));
console.log(
formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig, false)
);
});

// This test is just to make sure that we are accurately resetting our reference
Expand All @@ -169,7 +173,9 @@ describe("Shell format", () => {
console.log(formatShellDiff(circuitDiffs, summaryRows, fullReportRows));

const [summaryRowsBrillig, fullReportRowsBrillig] = formatShellBrilligRows(brilligDiffs);
console.log(formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig));
console.log(
formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig, false)
);
});

it("should compare 2 to 1", () => {
Expand All @@ -183,6 +189,8 @@ describe("Shell format", () => {
console.log(formatShellDiff(circuitDiffs, summaryRows, fullReportRows));

const [summaryRowsBrillig, fullReportRowsBrillig] = formatShellBrilligRows(brilligDiffs);
console.log(formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig));
console.log(
formatShellDiffBrillig(brilligDiffs, summaryRowsBrillig, fullReportRowsBrillig, false)
);
});
});

0 comments on commit ca7ea34

Please sign in to comment.