Skip to content

Commit

Permalink
Fix: handle rate limit error (#58)
Browse files Browse the repository at this point in the history
* Fix: handle rate limit error

* Fix: action version
  • Loading branch information
AlexSim93 authored Dec 19, 2024
1 parent 12eb36d commit cd1c246
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
18 changes: 14 additions & 4 deletions build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-analytics-action",
"version": "4.4.0",
"version": "4.4.2",
"description": "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance.",
"main": "build/index.js",
"scripts": {
Expand Down
35 changes: 21 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
validate,
} from "./common/utils";
import { getRateLimit } from "./requests/getRateLimit";
import {
sendActionError,
sendActionRun,
} from "./analytics";
import { sendActionError, sendActionRun } from "./analytics";

async function main() {
try {
Expand All @@ -34,11 +31,17 @@ async function main() {
);
return;
}
const rateLimitAtBeginning = await getRateLimit();
console.log(
"RATE LIMIT REMAINING BEFORE REQUESTS: ",
rateLimitAtBeginning.data.rate.remaining
);
try {
const rateLimitAtBeginning = await getRateLimit();
console.log(
"RATE LIMIT REMAINING BEFORE REQUESTS: ",
rateLimitAtBeginning.data.rate.remaining
);
} catch (error) {
console.log(
"Rate limit could not be retrieved at the beginning of the action"
);
}

const ownersRepos = getOwnersRepositories();
const organizationsRepos = await getOrganizationsRepositories();
Expand Down Expand Up @@ -93,11 +96,15 @@ async function main() {
console.log("Calculation complete. Generating markdown.");
await createOutput(preparedData);

const rateLimitAtEnd = await getRateLimit();
console.log(
"RATE LIMIT REMAINING AFTER REQUESTS: ",
rateLimitAtEnd.data.rate.remaining
);
try {
const rateLimitAtEnd = await getRateLimit();
console.log(
"RATE LIMIT REMAINING AFTER REQUESTS: ",
rateLimitAtEnd.data.rate.remaining
);
} catch (error) {
console.log("Rate limit could not be retrieved at the end of the action");
}
} catch (error) {
sendActionError(error as Error);
throw error;
Expand Down

0 comments on commit cd1c246

Please sign in to comment.