Skip to content

Commit faff2f7

Browse files
committed
fix(report): make it compatible with new format
1 parent bca7412 commit faff2f7

File tree

6 files changed

+77
-37
lines changed

6 files changed

+77
-37
lines changed

dist/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
431431
exports.computeDiffs = exports.loadReports = exports.variation = void 0;
432432
const orderBy_1 = __importDefault(__nccwpck_require__(94791));
433433
const minimatch_1 = __nccwpck_require__(4501);
434-
const reportHeaderRegex = /^\| .+:.+ contract +\|/;
434+
const reportHeaderRegex = /^\| .+:.+ contract +\|/gi;
435+
const reportSeparatorRegex = /^[\|╭╰]---/;
435436
const variation = (current, previous) => {
436437
const delta = current - previous;
437438
return {
@@ -455,11 +456,12 @@ const loadReports = (content, { ignorePatterns, matchPatterns, }) => {
455456
return Object.fromEntries(reportHeaderIndexes
456457
.map((reportHeaderIndex) => lines.slice(reportHeaderIndex, reportHeaderIndex + lines.slice(reportHeaderIndex).findIndex((line) => line.trim() === "")))
457458
.map((reportLines) => {
458-
const [filePath, name] = reportLines[0].split("|")[1].trim().split(":");
459+
const filteredReportLines = reportLines.filter((line) => !reportSeparatorRegex.test(line));
460+
const [filePath, name] = filteredReportLines[0].split("|")[1].trim().split(":");
459461
return {
460-
name: name.replace(" contract", ""),
462+
name: name.replace(/ contract/gi, ""),
461463
filePath,
462-
reportLines: reportLines.slice(3),
464+
reportLines: filteredReportLines.slice(2),
463465
};
464466
})
465467
.filter(matchMinimatchs
@@ -4187,6 +4189,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
41874189
core.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`);
41884190
return {
41894191
size: uploadResult.uploadSize,
4192+
digest: uploadResult.sha256Hash,
41904193
id: Number(artifactId)
41914194
};
41924195
});
@@ -141691,7 +141694,7 @@ module.exports = index;
141691141694
/***/ ((module) => {
141692141695

141693141696
"use strict";
141694-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.11","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
141697+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.0","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
141695141698

141696141699
/***/ }),
141697141700

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
"hardhat"
3434
],
3535
"dependencies": {
36-
"@actions/artifact": "^2.1.11",
36+
"@actions/artifact": "^2.2.0",
3737
"@actions/core": "^1.11.1",
3838
"@actions/exec": "^1.1.1",
3939
"@actions/github": "^5.1.1",
40-
"@octokit/core": "^6.1.2",
40+
"@octokit/core": "^6.1.3",
4141
"adm-zip": "^0.5.16",
4242
"lodash": "^4.17.21",
4343
"minimatch": "^10.0.1"
@@ -70,4 +70,4 @@
7070
},
7171
"verbose": true
7272
}
73-
}
73+
}

src/report.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Minimatch } from "minimatch";
33

44
import { DiffReport, GasReport, SortCriterion, SortOrder } from "./types";
55

6-
const reportHeaderRegex = /^\| .+:.+ contract +\|/;
6+
const reportHeaderRegex = /^\| .+:.+ contract +\|/gi;
7+
const reportSeparatorRegex = /^[\|]---/;
78

89
export const variation = (current: number, previous: number) => {
910
const delta = current - previous;
@@ -47,12 +48,13 @@ export const loadReports = (
4748
)
4849
)
4950
.map((reportLines) => {
50-
const [filePath, name] = reportLines[0].split("|")[1].trim().split(":");
51+
const filteredReportLines = reportLines.filter((line) => !reportSeparatorRegex.test(line));
52+
const [filePath, name] = filteredReportLines[0].split("|")[1].trim().split(":");
5153

5254
return {
53-
name: name.replace(" contract", ""),
55+
name: name.replace(/ contract/gi, ""),
5456
filePath,
55-
reportLines: reportLines.slice(3),
57+
reportLines: filteredReportLines.slice(2),
5658
};
5759
})
5860
.filter(

tests/mocks/gas_report.2.ansi

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,37 @@ Running 17 tests for test-foundry/compound/TestWithdraw.t.sol:TestWithdraw
316316
[PASS] testWithdrawWhileAttackerSendsCToken() (gas: 2286449)
317317
[PASS] testWithdrawnOnPoolThreshold() (gas: 587851)
318318
Test result: ok. 17 passed; 0 failed; finished in 118.90s
319-
| contracts/compound/IncentivesVault.sol:IncentivesVault contract | | | | | |
319+
╭-----------------------------------------------------------------+-----------------+-------+--------+-------+---------╮
320+
| contracts/compound/IncentivesVault.sol:IncentivesVault Contract | | | | | |
320321
|-----------------------------------------------------------------|-----------------|-------|--------|-------|---------|
321322
| Deployment Cost | Deployment Size | | | | |
323+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
322324
| 640594 | 3430 | | | | |
325+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
323326
| Function Name | min | avg | median | max | # calls |
327+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
324328
| MAX_BASIS_POINTS | 305 | 305 | 305 | 305 | 1 |
329+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
325330
| bonus | 318 | 318 | 318 | 318 | 1 |
331+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
326332
| incentivesTreasuryVault | 415 | 415 | 415 | 415 | 1 |
333+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
327334
| isPaused | 377 | 377 | 377 | 377 | 2 |
335+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
328336
| oracle | 393 | 393 | 393 | 393 | 1 |
337+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
329338
| setBonus | 2452 | 15520 | 21480 | 25580 | 5 |
339+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
330340
| setIncentivesTreasuryVault | 2605 | 7111 | 8614 | 8614 | 4 |
341+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
331342
| setOracle | 2606 | 5610 | 5610 | 8615 | 2 |
343+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
332344
| setPauseStatus | 1436 | 13858 | 14151 | 25694 | 4 |
345+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
333346
| tradeCompForMorphoTokens | 443 | 33672 | 36386 | 65651 | 6 |
347+
|-----------------------------------------------------------------+-----------------+-------+--------+-------+---------|
334348
| transferTokensToDao | 2604 | 20542 | 20542 | 38481 | 2 |
349+
╰-----------------------------------------------------------------+-----------------+-------+--------+-------+---------╯
335350

336351

337352
| contracts/compound/InterestRatesManager.sol:InterestRatesManager contract | | | | | |

yarn.lock

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@actions/artifact@^2.1.11":
6-
version "2.1.11"
7-
resolved "https://registry.yarnpkg.com/@actions/artifact/-/artifact-2.1.11.tgz#3dac32ea6feaa545bb99cb04bc4dd97b0c58e86a"
8-
integrity sha512-V/N/3yM3oLxozq2dpdGqbd/39UbDOR54bF25vYsvn3QZnyZERSzPjTAAwpGzdcwESye9G7vnuhPiKQACEuBQpg==
5+
"@actions/artifact@^2.2.0":
6+
version "2.2.0"
7+
resolved "https://registry.yarnpkg.com/@actions/artifact/-/artifact-2.2.0.tgz#9057ff1e0052602bd3640a36fb8d1496af1a6d90"
8+
integrity sha512-nDEyBsphN148zHe6ihq1a/UX92MDgC2GS9XmeFx2xs/wztZxzARYllviiP5U1nTDp2n9dEhnUig9RP9eSDcU5g==
99
dependencies:
1010
"@actions/core" "^1.10.0"
1111
"@actions/github" "^5.1.1"
@@ -774,16 +774,16 @@
774774
before-after-hook "^2.2.0"
775775
universal-user-agent "^6.0.0"
776776

777-
"@octokit/core@^6.1.2":
778-
version "6.1.2"
779-
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-6.1.2.tgz#20442d0a97c411612da206411e356014d1d1bd17"
780-
integrity sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==
777+
"@octokit/core@^6.1.3":
778+
version "6.1.3"
779+
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-6.1.3.tgz#280d3bb66c702297baac0a202219dd66611286e4"
780+
integrity sha512-z+j7DixNnfpdToYsOutStDgeRzJSMnbj8T1C/oQjB6Aa+kRfNjs/Fn7W6c8bmlt6mfy3FkgeKBRnDjxQow5dow==
781781
dependencies:
782782
"@octokit/auth-token" "^5.0.0"
783-
"@octokit/graphql" "^8.0.0"
784-
"@octokit/request" "^9.0.0"
785-
"@octokit/request-error" "^6.0.1"
786-
"@octokit/types" "^13.0.0"
783+
"@octokit/graphql" "^8.1.2"
784+
"@octokit/request" "^9.1.4"
785+
"@octokit/request-error" "^6.1.6"
786+
"@octokit/types" "^13.6.2"
787787
before-after-hook "^3.0.2"
788788
universal-user-agent "^7.0.0"
789789

@@ -813,13 +813,13 @@
813813
"@octokit/types" "^6.0.3"
814814
universal-user-agent "^6.0.0"
815815

816-
"@octokit/graphql@^8.0.0":
817-
version "8.1.1"
818-
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-8.1.1.tgz#3cacab5f2e55d91c733e3bf481d3a3f8a5f639c4"
819-
integrity sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==
816+
"@octokit/graphql@^8.1.2":
817+
version "8.1.2"
818+
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-8.1.2.tgz#98b9072b22e0471b782d52ed0da08e2b2de52b17"
819+
integrity sha512-bdlj/CJVjpaz06NBpfHhp4kGJaRZfz7AzC+6EwUImRtrwIw8dIgJ63Xg0OzV9pRn3rIzrt5c2sa++BL0JJ8GLw==
820820
dependencies:
821-
"@octokit/request" "^9.0.0"
822-
"@octokit/types" "^13.0.0"
821+
"@octokit/request" "^9.1.4"
822+
"@octokit/types" "^13.6.2"
823823
universal-user-agent "^7.0.0"
824824

825825
"@octokit/openapi-types@^12.11.0":
@@ -885,6 +885,13 @@
885885
dependencies:
886886
"@octokit/types" "^13.0.0"
887887

888+
"@octokit/request-error@^6.1.6":
889+
version "6.1.6"
890+
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-6.1.6.tgz#5f42c7894e7c3ab47c63aa3241f78cee8a826644"
891+
integrity sha512-pqnVKYo/at0NuOjinrgcQYpEbv4snvP3bKMRqHaD9kIsk9u1LCpb2smHZi8/qJfgeNqLo5hNW4Z7FezNdEo0xg==
892+
dependencies:
893+
"@octokit/types" "^13.6.2"
894+
888895
"@octokit/request@^5.6.0", "@octokit/request@^5.6.3":
889896
version "5.6.3"
890897
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0"
@@ -897,14 +904,15 @@
897904
node-fetch "^2.6.7"
898905
universal-user-agent "^6.0.0"
899906

900-
"@octokit/request@^9.0.0":
901-
version "9.1.1"
902-
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-9.1.1.tgz#e836eb69c0fb4b59b6437af7716ca348a1232a52"
903-
integrity sha512-pyAguc0p+f+GbQho0uNetNQMmLG1e80WjkIaqqgUkihqUp0boRU6nKItXO4VWnr+nbZiLGEyy4TeKRwqaLvYgw==
907+
"@octokit/request@^9.1.4":
908+
version "9.1.4"
909+
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-9.1.4.tgz#c1e90bd57c3113253d27337c92609b8fed54d13b"
910+
integrity sha512-tMbOwGm6wDII6vygP3wUVqFTw3Aoo0FnVQyhihh8vVq12uO3P+vQZeo2CKMpWtPSogpACD0yyZAlVlQnjW71DA==
904911
dependencies:
905912
"@octokit/endpoint" "^10.0.0"
906913
"@octokit/request-error" "^6.0.1"
907-
"@octokit/types" "^13.1.0"
914+
"@octokit/types" "^13.6.2"
915+
fast-content-type-parse "^2.0.0"
908916
universal-user-agent "^7.0.2"
909917

910918
"@octokit/types@^13.0.0", "@octokit/types@^13.1.0":
@@ -914,6 +922,13 @@
914922
dependencies:
915923
"@octokit/openapi-types" "^22.2.0"
916924

925+
"@octokit/types@^13.6.2":
926+
version "13.6.2"
927+
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.6.2.tgz#e10fc4d2bdd65d836d1ced223b03ad4cfdb525bd"
928+
integrity sha512-WpbZfZUcZU77DrSW4wbsSgTPfKcp286q3ItaIgvSbBpZJlu6mnYXAkjZz6LVZPXkEvLIM8McanyZejKTYUHipA==
929+
dependencies:
930+
"@octokit/openapi-types" "^22.2.0"
931+
917932
"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.39.0", "@octokit/types@^6.40.0":
918933
version "6.41.0"
919934
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04"
@@ -1747,6 +1762,11 @@ expect@^29.0.0, expect@^29.7.0:
17471762
jest-message-util "^29.7.0"
17481763
jest-util "^29.7.0"
17491764

1765+
fast-content-type-parse@^2.0.0:
1766+
version "2.0.1"
1767+
resolved "https://registry.yarnpkg.com/fast-content-type-parse/-/fast-content-type-parse-2.0.1.tgz#c236124534ee2cb427c8d8e5ba35a4856947847b"
1768+
integrity sha512-nGqtvLrj5w0naR6tDPfB4cUmYCqouzyQiz6C5y/LtcDllJdrcc6WaWW6iXyIIOErTa/XRybj28aasdn4LkVk6Q==
1769+
17501770
fast-fifo@^1.1.0, fast-fifo@^1.2.0:
17511771
version "1.3.2"
17521772
resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.2.tgz#286e31de96eb96d38a97899815740ba2a4f3640c"

0 commit comments

Comments
 (0)