Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tranhl committed Nov 27, 2024
1 parent 1428781 commit cb324e8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
32 changes: 16 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42858,13 +42858,13 @@ async function main({
});
});
pullRequests.forEach((pullRequest) => {
repoGraph.mergeNode(pullRequest.headRefName, {
repoGraph.mergeNode(pullRequest.head.ref, {
type: "pull-request",
...pullRequest
});
});
pullRequests.forEach((pullRequest) => {
repoGraph.mergeDirectedEdge(pullRequest.baseRefName, pullRequest.headRefName);
repoGraph.mergeDirectedEdge(pullRequest.base.ref, pullRequest.head.ref);
});
const getOutput = (graph) => {
const lines = [];
Expand Down Expand Up @@ -42895,7 +42895,7 @@ async function main({
const jobs = [];
const stackGraph = getStackGraph(repoGraph, currentPullRequest);
const shouldSkip = () => {
const neighbors = stackGraph.neighbors(currentPullRequest.headRefName);
const neighbors = stackGraph.neighbors(currentPullRequest.head.ref);
const allPerennialBranches = stackGraph.filterNodes(
(_, nodeAttributes) => nodeAttributes.type === "perennial"
);
Expand All @@ -42918,10 +42918,10 @@ async function main({
}
function getStackGraph(repoGraph, pullRequest) {
const stackGraph = repoGraph.copy();
stackGraph.setNodeAttribute(pullRequest.headRefName, "isCurrent", true);
stackGraph.setNodeAttribute(pullRequest.head.ref, "isCurrent", true);
(0, import_graphology_traversal.bfsFromNode)(
repoGraph,
pullRequest.headRefName,
pullRequest.head.ref,
(ref, attributes) => {
stackGraph.setNodeAttribute(ref, "shouldPrint", true);
return attributes.type === "perennial";
Expand All @@ -42932,7 +42932,7 @@ function getStackGraph(repoGraph, pullRequest) {
);
(0, import_graphology_traversal.dfsFromNode)(
stackGraph,
pullRequest.headRefName,
pullRequest.head.ref,
(ref) => {
stackGraph.setNodeAttribute(ref, "shouldPrint", true);
},
Expand Down Expand Up @@ -46796,8 +46796,12 @@ var z = /* @__PURE__ */ Object.freeze({
// src/types.ts
var pullRequestSchema = objectType({
number: numberType(),
baseRefName: stringType(),
headRefName: stringType(),
base: objectType({
ref: stringType()
}),
head: objectType({
ref: stringType()
}),
body: stringType().optional()
});

Expand Down Expand Up @@ -46876,15 +46880,11 @@ var inputs = {
},
getCurrentPullRequest(context2) {
try {
const pullRequest = context2.payload.pull_request;
const pullRequest = pullRequestSchema.parse(context2.payload.pull_request);
core2.startGroup("Inputs: Current pull request");
core2.info(JSON.stringify(pullRequest));
core2.endGroup();
return pullRequestSchema.parse({
number: pullRequest?.number,
baseRefName: pullRequest?.base?.ref,
headRefName: pullRequest?.head?.ref
});
return pullRequest;
} catch (error) {
core2.setFailed(`Unable to determine current pull request from action payload`);
throw error;
Expand All @@ -46901,8 +46901,8 @@ var inputs = {
(response) => response.data.map(
(item) => ({
number: item.number,
baseRefName: item.base.ref,
headRefName: item.head.ref,
base: item.base,
head: item.head,
body: item.body ?? void 0
})
)
Expand Down
18 changes: 4 additions & 14 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,13 @@ export const inputs = {

getCurrentPullRequest(context: typeof github.context) {
try {
const pullRequest:
| {
number: number
base?: { ref?: string }
head?: { ref?: string }
}
| undefined = context.payload.pull_request
const pullRequest = pullRequestSchema.parse(context.payload.pull_request)

core.startGroup('Inputs: Current pull request')
core.info(JSON.stringify(pullRequest))
core.endGroup()

return pullRequestSchema.parse({
number: pullRequest?.number,
baseRefName: pullRequest?.base?.ref,
headRefName: pullRequest?.head?.ref,
})
return pullRequest
} catch (error) {
core.setFailed(`Unable to determine current pull request from action payload`)
throw error
Expand All @@ -138,8 +128,8 @@ export const inputs = {
response.data.map(
(item): PullRequest => ({
number: item.number,
baseRefName: item.base.ref,
headRefName: item.head.ref,
base: item.base,
head: item.head,
body: item.body ?? undefined,
})
)
Expand Down
12 changes: 6 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export async function main({
})

pullRequests.forEach((pullRequest) => {
repoGraph.mergeNode(pullRequest.headRefName, {
repoGraph.mergeNode(pullRequest.head.ref, {
type: 'pull-request',
...pullRequest,
})
})

pullRequests.forEach((pullRequest) => {
repoGraph.mergeDirectedEdge(pullRequest.baseRefName, pullRequest.headRefName)
repoGraph.mergeDirectedEdge(pullRequest.base.ref, pullRequest.head.ref)
})

const getOutput = (graph: MultiDirectedGraph<StackNodeAttributes>) => {

Check failure on line 49 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint - ESLint

'getOutput' is assigned a value but never used. Allowed unused vars must match /^_/u
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function main({
const stackGraph = getStackGraph(repoGraph, currentPullRequest)

const shouldSkip = () => {
const neighbors = stackGraph.neighbors(currentPullRequest.headRefName)
const neighbors = stackGraph.neighbors(currentPullRequest.head.ref)
const allPerennialBranches = stackGraph.filterNodes(
(_, nodeAttributes) => nodeAttributes.type === 'perennial'
)
Expand Down Expand Up @@ -136,11 +136,11 @@ function getStackGraph(
pullRequest: PullRequest
) {
const stackGraph = repoGraph.copy() as MultiDirectedGraph<StackNodeAttributes>
stackGraph.setNodeAttribute(pullRequest.headRefName, 'isCurrent', true)
stackGraph.setNodeAttribute(pullRequest.head.ref, 'isCurrent', true)

bfsFromNode(
repoGraph,
pullRequest.headRefName,
pullRequest.head.ref,
(ref, attributes) => {
stackGraph.setNodeAttribute(ref, 'shouldPrint', true)
return attributes.type === 'perennial'
Expand All @@ -152,7 +152,7 @@ function getStackGraph(

dfsFromNode(
stackGraph,
pullRequest.headRefName,
pullRequest.head.ref,
(ref) => {
stackGraph.setNodeAttribute(ref, 'shouldPrint', true)
},
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ export type Octokit = ReturnType<typeof getOctokit>

export const pullRequestSchema = object({
number: number(),
baseRefName: string(),
headRefName: string(),
base: object({
ref: string(),
}),
head: object({
ref: string(),
}),
body: string().optional(),
})
export type PullRequest = InferType<typeof pullRequestSchema>
Expand Down

0 comments on commit cb324e8

Please sign in to comment.