Skip to content

Commit

Permalink
feat(retry): make delay custom
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 20, 2023
1 parent c0fe1f0 commit 51af1d7
Show file tree
Hide file tree
Showing 8 changed files with 1,681 additions and 565 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ The directory inside which to run forge inspect.

_Defaults to: `.`_

### `retryDelay` _{string}_

The retry delay (in milliseconds) between each GitHub API query.

_Defaults to: `1000`_

### `token` _{string}_

The github token allowing the action to upload and download gas reports generated by foundry. You should not need to customize this, as the action already has access to the default Github Action token.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
description: The directory inside which to run forge inspect.
default: .
required: false
retryDelay:
description: The retry delay (in milliseconds) between each GitHub API query.
default: 1000
required: false

runs:
using: node16
Expand Down
1,345 changes: 1,198 additions & 147 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,33 @@
"proxy"
],
"dependencies": {
"@actions/artifact": "^1.1.1",
"@actions/core": "^1.10.0",
"@actions/artifact": "^1.1.2",
"@actions/core": "^1.10.1",
"@actions/github": "^5.1.1",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/solidity": "^5.7.0",
"@octokit/core": "^5.0.0",
"@octokit/core": "^5.0.1",
"@solidity-parser/parser": "^0.16.1",
"js-sha3": "^0.8.0",
"lodash": "^4.17.21",
"shell-quote": "^1.8.1"
},
"devDependencies": {
"@actions/exec": "^1.1.1",
"@jest/types": "^29.6.1",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/adm-zip": "^0.5.0",
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.195",
"@types/node": "^20.4.2",
"@types/shell-quote": "^1.7.1",
"@jest/types": "^29.6.3",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/adm-zip": "^0.5.3",
"@types/jest": "^29.5.6",
"@types/lodash": "^4.14.200",
"@types/node": "^20.8.7",
"@types/shell-quote": "^1.7.3",
"@vercel/ncc": "^0.36.1",
"adm-zip": "^0.5.10",
"colors": "^1.4.0",
"jest": "^29.6.1",
"jest": "^29.7.0",
"prettier": "^2.8.8",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"jest": {
"clearMocks": true,
Expand All @@ -81,4 +81,4 @@
},
"verbose": true
}
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const address = core.getInput("address");
const rpcUrl = core.getInput("rpcUrl");
const failOnRemoval = core.getInput("failOnRemoval") === "true";
const workingDirectory = core.getInput("workingDirectory");
const retryDelay = parseInt(core.getInput("retryDelay"));

const contractAbs = join(workingDirectory, contract);
const contractEscaped = contractAbs.replace(/\//g, "_").replace(/:/g, "-");
Expand Down Expand Up @@ -79,7 +80,7 @@ async function _run() {
})) {
const artifact = res.data.find((artifact) => !artifact.expired && artifact.name === baseReport);
if (!artifact) {
await new Promise((resolve) => setTimeout(resolve, 800)); // avoid reaching the API rate limit
await new Promise((resolve) => setTimeout(resolve, retryDelay)); // avoid reaching the API rate limit

continue;
}
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"target": "es2020",
"module": "nodenext",
"moduleResolution": "nodenext",
"outDir": "lib",
"rootDir": ".",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
Expand Down
Loading

0 comments on commit 51af1d7

Please sign in to comment.