Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade octokit dependencies #2459

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: upgrade octokit dependencies
The main goal here is to upgrade `@octokit/plugin-throttling` to `5`, so that the secondary rate limit wait time is increased, wich hopefully fixes #2458. This required other dependencies to be upgraded. The `resolutions` for `@octokit/plugin-rest-endpoint-methods` is necessary, because without it it pulls in `10.0.0` of `@octokit/types` which isn't compatible with the other libraries.
restfulhead committed Jul 3, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 319e52b10865249114eb50d0c4f7a1bd060f017e
14 changes: 9 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -39,11 +39,12 @@
"dependencies": {
"@auto-it/bot-list": "link:../../packages/bot-list",
"@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2",
"@octokit/core": "^3.5.1",
"@octokit/plugin-enterprise-compatibility": "1.3.0",
"@octokit/plugin-retry": "^3.0.9",
"@octokit/plugin-throttling": "^3.6.2",
"@octokit/rest": "^18.12.0",
"@octokit/core": "^4.0.0",
"@octokit/plugin-enterprise-compatibility": "^2.0.5",
"@octokit/plugin-retry": "^4.1.6",
"@octokit/plugin-throttling": "^5.2.3",
"@octokit/plugin-rest-endpoint-methods": "~7.1.3",
"@octokit/rest": "^19.0.13",
"await-to-js": "^3.0.0",
"chalk": "^4.0.0",
"cosmiconfig": "7.0.0",
@@ -99,5 +100,8 @@
"@types/tinycolor2": "^1.4.1",
"@types/url-join": "^4.0.0",
"graphql": "^15.0.0"
},
"resolutions": {
"@octokit/plugin-rest-endpoint-methods": "7.1.3"
}
}
58 changes: 31 additions & 27 deletions packages/core/src/git.ts
Original file line number Diff line number Diff line change
@@ -140,7 +140,8 @@ export default class Git {
request: { agent: this.options.agent },
throttle: {
/** Add a wait once rate limit is hit */
onRateLimit: (retryAfter: number, opts: ThrottleOpts) => {
onRateLimit: (retryAfter: number, options: unknown) => {
const opts = options as ThrottleOpts;
this.logger.log.warn(
`Request quota exhausted for request ${opts.method} ${opts.url}`
);
@@ -153,7 +154,8 @@ export default class Git {
}
},
/** wait after abuse */
onAbuseLimit: (retryAfter: number, opts: ThrottleOpts) => {
onAbuseLimit: (retryAfter: number, options: unknown) => {
const opts = options as ThrottleOpts;
this.logger.log.error(
`Went over abuse rate limit ${opts.method} ${
opts.url
@@ -204,7 +206,8 @@ export default class Git {
this.logger.verbose.info("Got latest release:\n", latestRelease);

return latestRelease.tag_name;
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
if (e.status === 404) {
this.logger.verbose.info(
"Couldn't find latest release on GitHub, using first commit."
@@ -278,14 +281,14 @@ export default class Git {
this.logger.verbose.info("Found labels on PR:\n", labels.data);

return labels.data.map((l) => l.name);
} catch (e) {
throw new GitAPIError("listLabelsOnIssue", args, e);
} catch (e: unknown) {
throw new GitAPIError("listLabelsOnIssue", args, e as Error);
}
}

/** Get all the information about a PR or issue */
@memoize()
async getPr(prNumber: number) {
async getPr(prNumber: number): Promise<RestEndpointMethodTypes["issues"]["get"]["response"]> {
this.logger.verbose.info(`Getting info for PR: ${prNumber}`);

const args: RestEndpointMethodTypes["issues"]["get"]["parameters"] = {
@@ -300,14 +303,14 @@ export default class Git {
const info = await this.github.issues.get(args);
this.logger.veryVerbose.info('Got response for "issues.get":\n', info);
return info;
} catch (e) {
throw new GitAPIError("getPr", args, e);
} catch (e: unknown) {
throw new GitAPIError("getPr", args, e as Error);
}
}

/** Get information about specific commit */
@memoize()
async getCommit(sha: string) {
async getCommit(sha: string): Promise<RestEndpointMethodTypes["repos"]["getCommit"]["response"]> {
this.logger.verbose.info(`Getting info for commit: ${sha}`);

try {
@@ -321,8 +324,8 @@ export default class Git {
info
);
return info;
} catch (e) {
throw new GitAPIError("getCommit", [], e);
} catch (e: unknown) {
throw new GitAPIError("getCommit", [], e as Error);
}
}

@@ -338,20 +341,20 @@ export default class Git {
};

try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const labels = await this.github.paginate(
this.github.issues.listLabelsForRepo,
args
);

this.logger.veryVerbose.info(
'Got response for "getProjectLabels":\n',
labels
);
this.logger.verbose.info("Found labels on project:\n", labels);

return labels.map((l) => l.name);
} catch (e) {
throw new GitAPIError("getProjectLabels", args, e);
} catch (e: unknown) {
throw new GitAPIError("getProjectLabels", args, e as Error);
}
}

@@ -402,7 +405,8 @@ export default class Git {

return all;
}, []);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log(error);
const tag = error.match(/ambiguous argument '(\S+)\.\.\S+'/);

@@ -493,7 +497,7 @@ export default class Git {

/** Get all the information about a PR or issue */
@memoize()
async getPullRequest(pr: number) {
async getPullRequest(pr: number): Promise<RestEndpointMethodTypes["pulls"]["get"]["response"]> {
this.logger.verbose.info(`Getting Pull Request: ${pr}`);

const args: RestEndpointMethodTypes["pulls"]["get"]["parameters"] = {
@@ -548,7 +552,7 @@ export default class Git {
}

/** Create a status (or checkmark) on a commit */
async createStatus(prInfo: IPRInfo) {
async createStatus(prInfo: IPRInfo): Promise<RestEndpointMethodTypes["repos"]["createCommitStatus"]["response"]> {
const args = {
...prInfo,
owner: this.options.owner,
@@ -568,7 +572,7 @@ export default class Git {
}

/** Add a label to the project */
async createLabel(label: ILabelDefinition) {
async createLabel(label: ILabelDefinition): Promise<RestEndpointMethodTypes["issues"]["createLabel"]["response"]> {
this.logger.verbose.info(
`Creating "${label.releaseType || "general"}" label :\n${label.name}`
);
@@ -591,7 +595,7 @@ export default class Git {
}

/** Update a label on the project */
async updateLabel(label: ILabelDefinition) {
async updateLabel(label: ILabelDefinition): Promise<RestEndpointMethodTypes["issues"]["updateLabel"]["response"]> {
this.logger.verbose.info(
`Updating "${label.releaseType || "generic"}" label :\n${label.name}`
);
@@ -615,7 +619,7 @@ export default class Git {
}

/** Add a label to and issue or pull request */
async addLabelToPr(pr: number, label: string) {
async addLabelToPr(pr: number, label: string): Promise<RestEndpointMethodTypes["issues"]["addLabels"]["response"]> {
this.logger.verbose.info(`Creating "${label}" label to PR ${pr}`);

const result = await this.github.issues.addLabels({
@@ -632,7 +636,7 @@ export default class Git {
}

/** Add a label to and issue or pull request */
async removeLabel(pr: number, label: string) {
async removeLabel(pr: number, label: string): Promise<RestEndpointMethodTypes["issues"]["removeLabel"]["response"]> {
this.logger.verbose.info(`Removing "${label}" from #${pr}`);

const result = await this.github.issues.removeLabel({
@@ -649,7 +653,7 @@ export default class Git {
}

/** Lock an issue */
async lockIssue(issue: number) {
async lockIssue(issue: number): Promise<RestEndpointMethodTypes["issues"]["lock"]["response"]> {
this.logger.verbose.info(`Locking #${issue} issue...`);

const result = await this.github.issues.lock({
@@ -763,7 +767,7 @@ export default class Git {
}

/** Create a comment on an issue or pull request */
async createComment(message: string, pr: number, context = "default") {
async createComment(message: string, pr: number, context = "default"): Promise<RestEndpointMethodTypes["issues"]["createComment"]["response"]> {
const commentIdentifier = makeCommentIdentifier(context);

this.logger.verbose.info("Using comment identifier:", commentIdentifier);
@@ -786,7 +790,7 @@ export default class Git {
}

/** Edit a comment on an issue or pull request */
async editComment(message: string, pr: number, context = "default") {
async editComment(message: string, pr: number, context = "default"): Promise<RestEndpointMethodTypes["issues"]["updateComment"]["response"] | RestEndpointMethodTypes["issues"]["createComment"]["response"]> {
const commentIdentifier = makeCommentIdentifier(context);

this.logger.verbose.info("Using comment identifier:", commentIdentifier);
@@ -810,7 +814,7 @@ export default class Git {
}

/** Create a comment on a pull request body */
async addToPrBody(message: string, pr: number, context = "default") {
async addToPrBody(message: string, pr: number, context = "default"): Promise<RestEndpointMethodTypes["issues"]["update"]["response"]> {
const id = makePrBodyIdentifier(context);

this.logger.verbose.info("Using PR body identifier:", id);
@@ -858,7 +862,7 @@ export default class Git {
prerelease = false,
fallbackCommit?: string,
latestRelease = false
) {
): Promise<RestEndpointMethodTypes["repos"]["createRelease"]["response"]> {
this.logger.verbose.info("Creating release on GitHub for tag:", tag);

const result = await this.github.repos.createRelease({
@@ -869,7 +873,7 @@ export default class Git {
name: tag,
body: releaseNotes,
prerelease,
make_latest: `${latestRelease}`,
make_latest: `${latestRelease}` as 'true' | 'false',
});

this.logger.veryVerbose.info("Got response from createRelease\n", result);
Loading