chore: upgrade octokit to v5 and probot to v14#484
Conversation
|
note: this should be run locally to confirm everything is working |
|
|
||
| rulesLogger.info('Creating branch protection for all branches', { | ||
| repositoryOwner: context.payload.repository.owner.login, | ||
| repositoryOwner: context.payload.repository.owner!.login, |
There was a problem hiding this comment.
Probably better to have this handle the case where the repository owner doesn't exist, since the intended result would be the same (log undefined). Otherwise, this could lead to an exception.
| repositoryOwner: context.payload.repository.owner!.login, | |
| repositoryOwner: context.payload.repository.owner?.login, |
|
|
||
| rulesLogger.info('Creating branch protection for default branch', { | ||
| repositoryOwner: context.payload.repository.owner.login, | ||
| repositoryOwner: context.payload.repository.owner!.login, |
There was a problem hiding this comment.
| repositoryOwner: context.payload.repository.owner!.login, | |
| repositoryOwner: context.payload.repository.owner?.login, |
| repository: Repository | ||
| }>(getBranchProtectionRulesetGQL, { | ||
| owner: context.payload.repository.owner.login, | ||
| owner: context.payload.repository.owner!.login, |
There was a problem hiding this comment.
This case isn't just logging, so may need better error handling unless we're strongly confident this will always be defined
There was a problem hiding this comment.
Could potentially make a utility function that handles the value being undefined and reuse that across the uses in the file
| branch: pattern, | ||
| enforce_admins: true, | ||
| owner: context.payload.repository.owner.login, | ||
| owner: context.payload.repository.owner!.login, |
| rulesLogger.info('Created branch protection via REST', { | ||
| res, | ||
| repositoryOwner: context.payload.repository.owner.login, | ||
| repositoryOwner: context.payload.repository.owner!.login, |
There was a problem hiding this comment.
| repositoryOwner: context.payload.repository.owner!.login, | |
| repositoryOwner: context.payload.repository.owner?.login, |
| @@ -0,0 +1,12 @@ | |||
| { | |||
| "extends": "./tsconfig.json", | |||
There was a problem hiding this comment.
Is separate tsconfig needed? As part of #435 I updated tsconfig to include tests. Build only needs a separate tsconfig to adjust the default settings, but does test also need that? If not, I would revert this change.
riley-kohler
left a comment
There was a problem hiding this comment.
I'm still doing further testing but ran into some initial issues that were causing the application to break that I suggested fixes for.
| // @ts-expect-error getCustomPropertiesValues exists in the API but is not yet | ||
| // in octokit 5 type definitions. Tracked upstream: | ||
| // https://github.com/octokit/octokit.js/discussions/2050 | ||
| const props = await octokit.rest.repos.getCustomPropertiesValues({ |
There was a problem hiding this comment.
| // @ts-expect-error getCustomPropertiesValues exists in the API but is not yet | |
| // in octokit 5 type definitions. Tracked upstream: | |
| // https://github.com/octokit/octokit.js/discussions/2050 | |
| const props = await octokit.rest.repos.getCustomPropertiesValues({ | |
| const props = await octokit.rest.repos.customPropertiesForReposGetRepositoryValues({ |
There is a way to get custom properties in Octokit 5 that has types defined it just uses the worst name scheme imaginable.
| // @ts-expect-error getAllCustomProperties exists in the API but is not yet in octokit 5 type definitions | ||
| await privateOctokit.rest.orgs.getAllCustomProperties({ |
There was a problem hiding this comment.
| // @ts-expect-error getAllCustomProperties exists in the API but is not yet in octokit 5 type definitions | |
| await privateOctokit.rest.orgs.getAllCustomProperties({ | |
| await privateOctokit.rest.orgs.customPropertiesForReposGetOrganizationDefinitions({ |
Similar to above but for getting organization custom property definitions.
| // @ts-expect-error createOrUpdateCustomProperty exists in the API but is not yet in octokit 5 type definitions | ||
| await privateOctokit.rest.orgs.createOrUpdateCustomProperty({ |
There was a problem hiding this comment.
| // @ts-expect-error createOrUpdateCustomProperty exists in the API but is not yet in octokit 5 type definitions | |
| await privateOctokit.rest.orgs.createOrUpdateCustomProperty({ | |
| await privateOctokit.rest.orgs.customPropertiesForReposCreateOrUpdateOrganizationDefinition({ |
Similar to above but for setting organization custom property definitions.
| export default await createNodeMiddleware(app, { | ||
| probot: createProbot({ | ||
| defaults: { | ||
| log: { | ||
| child: () => probotLogger, | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| } as any, | ||
| }, | ||
| }), | ||
| webhooksPath: '/api/webhooks', | ||
| }) |
There was a problem hiding this comment.
| // Probot v14 requires a pino logger so custom logging has been removed | |
| // In the future it is worth considering replacing tslog with pino entirely | |
| export default await createNodeMiddleware(app, { | |
| probot: createProbot(), | |
| webhooksPath: '/api/webhooks', | |
| }) |
Probot is configured to use Pino and is incompatible with tslog which causes some errors in the new version because Probot started using more features of Pino. This change just removes the custom logging for now which retains most of the functionality but logs will be formatted slightly differently.
| import { createNodeMiddleware, createProbot } from 'probot' | ||
| import { logger } from 'utils/logger' | ||
|
|
||
| export const probot = createProbot() |
There was a problem hiding this comment.
| import { createNodeMiddleware, createProbot } from 'probot' | |
| export const probot = createProbot() |
The suggestion is behaving a bit strangely but the intent is just to delete the logger import in favor of the change below to use the probot default logging.
| export const probot = createProbot() | ||
|
|
||
| const probotLogger = logger.getSubLogger({ name: 'probot' }) | ||
|
|
||
| export const config = { |
There was a problem hiding this comment.
| export const probot = createProbot() | |
| export const config = { |
The suggestion is behaving a bit strangely but the intent is just to delete the sub logger creation in favor of the change below to use the probot default logging.
Pull Request
This PR will update
OctokitandProbotalong with updating any files based on the various majors we are updating to.Closes #329
fixed merge conflicts from #477
Proposed Changes
Upgrades
Probot 13 → 14.3.2andOctokit 3 → 5,aligning the entire@octokit/coredependency tree to a single dedupedv7.0.6.Key changes:
Type workarounds
Why:
@primer/react's DataTable component usesObjectPaths<Data>for the field prop type. UndermoduleResolution: "bundler"(from @tsconfig/next), the generic Data parameter isn't inferred from the data prop and falls back to UniqueRow, which only exposes "id" as a valid field. This is a known issue with@primer/react's draft DataTable generics.When to remove: When
@primer/reactupdates DataTable to support moduleResolution: "bundler", or when DataTable moves out of drafts with fixed generic inference.Why:
rest.orgs.getAllCustomProperties()andrest.orgs.createOrUpdateCustomProperty()exist in the GitHub API and work at runtime, but octokit 5's bundled REST types (@octokit/plugin-rest-endpoint-methods) have not yet added these endpoints to their type definitions.When to remove: When
@octokit/plugin-rest-endpoint-methodsadds the custom properties endpoints tracked upstream | tracked locally in #485Why: The visibility parameter for repos.createInOrg only types "private" | "public" in octokit 5, but "internal" is a valid value for GitHub Enterprise/GHEC orgs.
When to remove: When octokit's REST types add "internal" to the visibility union.
PR #477 Follow-ups
useForks.tsx:19—satisfiesoverasforks/[forkId]/page.tsx:570—satisfiesoverascontroller.ts:37— tracking issuetsconfig.test.json— is it needed?Readiness Checklist
Author/Contributor
npm run formatand fix any formatting issues that have been introducednpm run lintand fix any linting issues that have been introducednpm run testand run tests