forked from yardenshoham/gitea-backporter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run typecheck on CI and fix issues (#133)
1. type checking (`deno check`) was not running on CI and there were 7 type errors which I've fixed and now it's running 2. GitHub API types are sourced from https://github.com/octokit/types.ts and I created basic types for `Issue` and `PullRequest`. 3. IDK about those two webhook errors, so I used `@ts-expect-error`. 4. `deno.lock` was auto generated, I guess it's good to have it in-repo. 5. `actions/checkout` is upgraded to latest major.
- Loading branch information
1 parent
8cea624
commit f80155a
Showing
7 changed files
with
59 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
} from "./github.ts"; | ||
import { fetchGiteaVersions } from "./giteaVersion.ts"; | ||
import { debounce } from "https://deno.land/[email protected]/async/mod.ts"; | ||
import type { PullRequest } from "./types.ts"; | ||
|
||
// a relevant label is one that is used to control the merge queue, | ||
// manage backports or any other label that causes the bot to act on | ||
|
@@ -77,15 +78,11 @@ export const removeBackportLabelsFromPrsTargetingReleaseBranches = async () => { | |
}; | ||
|
||
// given a list of PRs, removes the backport/* labels from them | ||
export const removeBackportLabelsFromPrs = (prs) => { | ||
export const removeBackportLabelsFromPrs = (prs: PullRequest[]) => { | ||
if (prs === undefined) { | ||
throw new Error("removeBackportLabelsFromPrs called with undefined"); | ||
} | ||
return Promise.all(prs.flatMap((pr: { | ||
title; | ||
labels; | ||
number: number; | ||
}) => { | ||
return Promise.all(prs.flatMap((pr: PullRequest) => { | ||
const backportLabels = pr.labels.filter((label: { name: string }) => | ||
label.name.startsWith("backport/") | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as SemVer from "https://deno.land/[email protected]/semver/mod.ts"; | ||
import { fetchGiteaVersions } from "./giteaVersion.ts"; | ||
import * as github from "./github.ts"; | ||
import type { PullRequest } from "./types.ts"; | ||
|
||
// given a PR number, set the milestone of the PR according to its base branch | ||
export const assign = async (pr: { number: number; base: { ref: string } }) => { | ||
|
@@ -58,7 +59,7 @@ const removeMilestonesFromUnmergedClosedPrs = async () => { | |
// and remove the milestone each PR | ||
return Promise.all(milestones.flatMap(async (m) => { | ||
const prs = await github.fetchUnmergedClosedWithMilestone(m.title); | ||
return prs.items.map(async (pr) => { | ||
return prs.items.map(async (pr: PullRequest) => { | ||
const response = await github.removeMilestone(pr.number); | ||
if (!response.ok) { | ||
console.error( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Endpoints } from "npm:@octokit/[email protected]"; | ||
|
||
type IssueGetResponse = | ||
Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}"]["response"][ | ||
"data" | ||
]; | ||
type PullGetResponse = | ||
Endpoints["GET /repos/{owner}/{repo}/pulls/{pull_number}"]["response"][ | ||
"data" | ||
]; | ||
|
||
export type Issue = IssueGetResponse; | ||
export type PullRequest = PullGetResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters