mirror of
https://github.com/godotengine/godot-team-reports.git
synced 2025-12-31 13:48:17 +03:00
Break CI when PR database creation fails
This commit is contained in:
@@ -12,6 +12,11 @@ const PULLS_PER_PAGE = 100;
|
||||
let page_count = 1;
|
||||
let last_cursor = "";
|
||||
|
||||
const ExitCodes = {
|
||||
"RequestFailure": 1,
|
||||
"ParseFailure": 2,
|
||||
};
|
||||
|
||||
const API_REPOSITORY_ID = `owner:"godotengine" name:"godot"`;
|
||||
const API_RATE_LIMIT = `
|
||||
rateLimit {
|
||||
@@ -101,6 +106,7 @@ async function checkRates() {
|
||||
const res = await fetchGithub(query);
|
||||
if (res.status !== 200) {
|
||||
console.warn(` Failed to get the API rate limits; server responded with code ${res.status}`);
|
||||
process.exitCode = ExitCodes.RequestFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,6 +118,7 @@ async function checkRates() {
|
||||
console.log(` [$${rate_limit.cost}] Available API calls: ${rate_limit.remaining}/${rate_limit.limit}; resets at ${rate_limit.resetAt}`);
|
||||
} catch (err) {
|
||||
console.error(" Error checking the API rate limits: " + err);
|
||||
process.exitCode = ExitCodes.RequestFailure;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -215,6 +222,7 @@ async function fetchPulls(page) {
|
||||
const res = await fetchGithub(query);
|
||||
if (res.status !== 200) {
|
||||
console.warn(` Failed to get pull requests for '${API_REPOSITORY_ID}'; server responded with code ${res.status}`);
|
||||
process.exitCode = ExitCodes.RequestFailure;
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -234,11 +242,13 @@ async function fetchPulls(page) {
|
||||
return pulls_data;
|
||||
} catch (err) {
|
||||
console.error(" Error fetching pull request data: " + err);
|
||||
process.exitCode = ExitCodes.RequestFailure;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function processPulls(pullsRaw) {
|
||||
try {
|
||||
pullsRaw.forEach((item) => {
|
||||
// Compile basic information about a PR.
|
||||
let pr = {
|
||||
@@ -379,6 +389,10 @@ function processPulls(pullsRaw) {
|
||||
|
||||
pulls.push(pr);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(" Error parsing pull request data: " + err);
|
||||
process.exitCode = ExitCodes.ParseFailure;
|
||||
}
|
||||
}
|
||||
|
||||
function extractLinkedIssues(pullBody) {
|
||||
@@ -429,11 +443,18 @@ function extractLinkedIssues(pullBody) {
|
||||
return links;
|
||||
}
|
||||
|
||||
function checkForExit() {
|
||||
if (process.exitCode > 0) {
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("[*] Building local pull request database.");
|
||||
|
||||
console.log("[*] Checking the rate limits before.")
|
||||
await checkRates();
|
||||
checkForExit();
|
||||
|
||||
console.log("[*] Fetching pull request data from GitHub.");
|
||||
// Pages are starting with 1 for better presentation.
|
||||
@@ -441,11 +462,13 @@ async function main() {
|
||||
while (page <= page_count) {
|
||||
const pullsRaw = await fetchPulls(page);
|
||||
processPulls(pullsRaw);
|
||||
checkForExit();
|
||||
page++;
|
||||
}
|
||||
|
||||
console.log("[*] Checking the rate limits after.")
|
||||
await checkRates();
|
||||
checkForExit();
|
||||
|
||||
console.log("[*] Finalizing database.")
|
||||
const output = {
|
||||
|
||||
Reference in New Issue
Block a user