Skip to content

Commit

Permalink
Update GitHub OpenAPI.yaml (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM authored Jan 4, 2025
1 parent b3fea03 commit abfdfb5
Show file tree
Hide file tree
Showing 17 changed files with 229,590 additions and 250,014 deletions.
2 changes: 1 addition & 1 deletion Lambdas/GHHooks/EventHandler/Handlers/IssueHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct IssueHandler: Sendable {
}

/// Returns the `closed-by` user if the issue is closed at all.
func maybeGetClosedByUser() async throws -> (id: Int, uiName: String)? {
func maybeGetClosedByUser() async throws -> (id: Int64, uiName: String)? {
if issue.closedAt == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion Lambdas/GHHooks/EventHandler/Handlers/PRHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private enum Status: String {
}

init(pr: PullRequest) {
if pr.mergedBy != nil {
if pr.mergedAt != nil {
self = .merged
} else if pr.closedAt != nil {
self = .closed
Expand Down
10 changes: 5 additions & 5 deletions Lambdas/GHHooks/EventHandler/Handlers/ProjectBoardHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ struct ProjectBoardHandler {
).created
}

func move(toColumnID columnID: Int, cardID: Int) async throws {
func move(toColumnID columnID: Int, cardID: Int64) async throws {
_ = try await self.context.githubClient.projectsMoveCard(
path: .init(cardId: cardID),
path: .init(cardId: Int(cardID)),
body: .json(.init(position: "top", columnId: columnID))
).created
}

func delete(cardID: Int) async throws {
func delete(cardID: Int64) async throws {
_ = try await self.context.githubClient.projectsDeleteCard(
path: .init(cardId: cardID)
path: .init(cardId: Int(cardID))
).noContent
}

Expand All @@ -130,7 +130,7 @@ struct ProjectBoardHandler {
try await self.getCards(in: project.columnID(of: column))
}

func move(cardID: Int) async throws {
func move(cardID: Int64) async throws {
try await self.move(toColumnID: project.columnID(of: targetColumn), cardID: cardID)
}

Expand Down
18 changes: 8 additions & 10 deletions Lambdas/GHHooks/EventHandler/Handlers/ReleaseMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ struct ReleaseMaker {

enum Configuration {
/// The postgres-nio repository ID.
static let repositoryIDDenyList: Set<Int> = [150_622_661]
static let repositoryIDDenyList: Set<Int64> = [150_622_661]
/// Needs the Penny installation to be installed on the org,
/// which is not possible without making Penny app public.
/// The Vapor organization ID.
static let organizationIDAllowList: Set<Int> = [17_364_220]
static let organizationIDAllowList: Set<Int64> = [17_364_220]
static let releaseNoticePrefix = "**These changes are now available in"
}

Expand Down Expand Up @@ -289,7 +289,7 @@ struct ReleaseMaker {
return sorted
}

func isNewContributor(codeOwners: CodeOwners, existingContributors: Set<Int>) -> Bool {
func isNewContributor(codeOwners: CodeOwners, existingContributors: Set<Int64>) -> Bool {
pr.authorAssociation != .owner && !pr.user.isBot && !codeOwners.contains(user: pr.user)
&& !existingContributors.contains(pr.user.id)
}
Expand Down Expand Up @@ -320,9 +320,9 @@ struct ReleaseMaker {
return json
}

func getExistingContributorIDs() async throws -> Set<Int> {
func getExistingContributorIDs() async throws -> Set<Int64> {
var page = 1
var contributorIds: [Int] = []
var contributorIds: [Int64] = []
/// Hack: Vapor has around this amount of contributors and we know it, so better
/// to reserve enough capacity for it up-front.
contributorIds.reserveCapacity(250)
Expand All @@ -338,7 +338,7 @@ struct ReleaseMaker {
return Set(contributorIds)
}

func getExistingContributorIDs(page: Int) async throws -> (ids: [Int], hasNext: Bool) {
func getExistingContributorIDs(page: Int) async throws -> (ids: [Int64], hasNext: Bool) {
logger.debug(
"Will fetch current contributors",
metadata: [
Expand All @@ -364,14 +364,12 @@ struct ReleaseMaker {
/// If the header contains `rel="next"` then we'll have a next page to fetch.
let hasNext =
switch ok.headers.link {
case let .case1(string):
case let .some(string):
string.contains(#"rel="next""#)
case let .case2(strings):
strings.contains { $0.contains(#"rel="next""#) }
case .none:
false
}
let ids = json.compactMap(\.id)
let ids = json.compactMap(\.id).map(Int64.init)
logger.debug(
"Fetched some contributors",
metadata: [
Expand Down
12 changes: 6 additions & 6 deletions Lambdas/GHHooks/EventHandler/Handlers/TicketReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ struct TicketReporter {

enum Configuration {
/// The dependabot[bot] user ID.
static let userIDDenyList: Set<Int> = [49_699_333]
static let userIDDenyList: Set<Int64> = [49_699_333]
}

private static let ticketQueue = SerialProcessor()

var context: HandlerContext
let embed: Embed
let createdAt: Date
let repoID: Int
let repoID: Int64
let number: Int
let authorID: Int
let authorID: Int64
var ticketKey: String {
"\(repoID)_\(number)"
}
Expand All @@ -34,9 +34,9 @@ struct TicketReporter {
context: HandlerContext,
embed: Embed,
createdAt: Date,
repoID: Int,
repoID: Int64,
number: Int,
authorID: Int
authorID: Int64
) {
self.context = context
self.embed = embed
Expand Down Expand Up @@ -134,7 +134,7 @@ struct TicketReporter {
}

extension Constants.Channels {
fileprivate static func reportingChannel(repoID: Int, createdAt: Date) -> Self {
fileprivate static func reportingChannel(repoID: Int64, createdAt: Date) -> Self {
/// The change to use `.documentation` was made only after this timestamp.
if createdAt.timeIntervalSince1970 < 1_696_067_000 {
return .issuesAndPRs
Expand Down
19 changes: 16 additions & 3 deletions Lambdas/GHHooks/GHHooksHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,29 @@ struct GHHooksHandler: LambdaHandler {
.init(
title: "GHHooks lambda top-level error",
description: "\(error)".unicodesPrefix(2_048),
color: .red
color: .red,
fields: [
.init(
name: "X-Github-Delivery",
value: request.headers.first(name: "x-github-delivery") ?? "<null>"
)
]
)
],
files: [
.init(
data: ByteBuffer(string: "\(error)"),
filename: "error"
)
),
.init(
data: request.body.map(ByteBuffer.init(string:)) ?? ByteBuffer(),
filename: "body"
),
],
attachments: [.init(index: 0, filename: "error")]
attachments: [
.init(index: 0, filename: "error"),
.init(index: 1, filename: "body"),
]
)
).guardSuccess()
} catch {
Expand Down
10 changes: 5 additions & 5 deletions Lambdas/GHHooks/MessageLookupRepo/DynamoMessageRepo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ struct DynamoMessageRepo: MessageLookupRepo {
self.logger = logger
}

private func makeTicketID(repoID: Int, number: Int) -> String {
private func makeTicketID(repoID: Int64, number: Int) -> String {
"\(repoID)_\(number)"
}

func getMessageID(repoID: Int, number: Int) async throws -> String {
func getMessageID(repoID: Int64, number: Int) async throws -> String {
let item = try await self.getItem(repoID: repoID, number: number)
if item.isUnavailable {
throw Errors.unavailable
}
return item.messageID
}

private func getItem(repoID: Int, number: Int) async throws -> Item {
private func getItem(repoID: Int64, number: Int) async throws -> Item {
let id = makeTicketID(repoID: repoID, number: number)
let item = try await self.get(id: id)
return item
Expand All @@ -69,13 +69,13 @@ struct DynamoMessageRepo: MessageLookupRepo {
/// for a ticket to Discord, but a moderator deletes that messages, then there is an update
/// to the ticket, but the previous message is unavailable to edit anymore, so Penny should
/// just ignore updates to messages of that ticket.
func markAsUnavailable(repoID: Int, number: Int) async throws {
func markAsUnavailable(repoID: Int64, number: Int) async throws {
var item = try await self.getItem(repoID: repoID, number: number)
item._isUnavailable = true
try await save(item: item)
}

func saveMessageID(messageID: String, repoID: Int, number: Int) async throws {
func saveMessageID(messageID: String, repoID: Int64, number: Int) async throws {
let id = makeTicketID(repoID: repoID, number: number)
let item = Item(id: id, messageID: messageID)
try await save(item: item)
Expand Down
6 changes: 3 additions & 3 deletions Lambdas/GHHooks/MessageLookupRepo/MessageLookupRepo.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
protocol MessageLookupRepo: Sendable {
func getMessageID(repoID: Int, number: Int) async throws -> String
func markAsUnavailable(repoID: Int, number: Int) async throws
func saveMessageID(messageID: String, repoID: Int, number: Int) async throws
func getMessageID(repoID: Int64, number: Int) async throws -> String
func markAsUnavailable(repoID: Int64, number: Int) async throws
func saveMessageID(messageID: String, repoID: Int64, number: Int) async throws
}
4 changes: 0 additions & 4 deletions Lambdas/GitHubAPI/Aliases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package typealias FoundationURL = Foundation.URL

package typealias Repository = Components.Schemas.Repository
package typealias User = Components.Schemas.SimpleUser
package typealias Organization = Components.Schemas.OrganizationSimple
package typealias PullRequest = Components.Schemas.PullRequest
package typealias SimplePullRequest = Components.Schemas.PullRequestSimple
package typealias Issue = Components.Schemas.Issue
Expand All @@ -25,14 +24,11 @@ package typealias Release = Components.Schemas.Release
package typealias InstallationToken = Components.Schemas.InstallationToken
package typealias NullableUser = Components.Schemas.NullableSimpleUser
package typealias Contributor = Components.Schemas.Contributor
package typealias PullRequestReviewComment = Components.Schemas.PullRequestReviewComment
package typealias PullRequestReview = Components.Schemas.PullRequestReview
package typealias DiffEntry = Components.Schemas.DiffEntry
package typealias Commit = Components.Schemas.Commit
package typealias SimpleCommit = Components.Schemas.SimpleCommit
package typealias Committer = Components.Schemas.SimpleCommit.CommitterPayload
package typealias Enterprise = Components.Schemas.Enterprise
package typealias Installation = Components.Schemas.SimpleInstallation
package typealias Tag = Components.Schemas.Tag
package typealias ProjectCard = Components.Schemas.ProjectCard
package typealias TimelineIssueEvents = Components.Schemas.TimelineIssueEvents
2 changes: 0 additions & 2 deletions Lambdas/GitHubAPI/GHEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package struct GHEvent: Sendable, Codable {
package let action: String?
package let sender: User
package let repository: Repository?
package let organization: Organization?

package let issue: Issue?
package let label: Label?
Expand All @@ -29,7 +28,6 @@ package struct GHEvent: Sendable, Codable {
package let installation: Installation?
package let pusher: Committer?
package let ref: String?
package let enterprise: Enterprise?
}

extension GHEvent {
Expand Down
Loading

0 comments on commit abfdfb5

Please sign in to comment.