Skip to content

Commit

Permalink
Merge pull request #817 from snyk/feat/allow_native_pr_experience
Browse files Browse the repository at this point in the history
feat: allow GitHub native PR experience calls through the Broker
  • Loading branch information
aarlaud authored Aug 21, 2024
2 parents b8d603d + 3aa8892 commit 8552340
Show file tree
Hide file tree
Showing 12 changed files with 611 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client-templates/github-com/accept.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,24 @@
"method": "POST",
"path": "/graphql",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}"
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
}
]
}
18 changes: 18 additions & 0 deletions client-templates/github-enterprise/accept.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,24 @@
"method": "POST",
"path": "/graphql",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}"
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
}
]
}
18 changes: 18 additions & 0 deletions client-templates/github-server-app/accept.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,24 @@
"method": "POST",
"path": "/graphql",
"origin": "https://${GITHUB_GRAPHQL}"
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_API}"
}
]
}
18 changes: 18 additions & 0 deletions defaultFilters/github-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,24 @@
"method": "POST",
"path": "/graphql",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}"
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
}
]
}
30 changes: 30 additions & 0 deletions defaultFilters/github-server-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,36 @@
"scheme": "bearer",
"token": "${GHSA_ACCESS_TOKEN}"
}
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_API}",
"auth": {
"scheme": "bearer",
"token": "${GHSA_ACCESS_TOKEN}"
}
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_API}",
"auth": {
"scheme": "bearer",
"token": "${GHSA_ACCESS_TOKEN}"
}
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_API}",
"auth": {
"scheme": "bearer",
"token": "${GHSA_ACCESS_TOKEN}"
}
}
]
}
18 changes: 18 additions & 0 deletions defaultFilters/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,24 @@
"method": "POST",
"path": "/graphql",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}"
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
}
]
}
18 changes: 18 additions & 0 deletions test/fixtures/accept/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@
"values": ["application/vnd.github.v4.sha"]
}
]
},
{
"//": "create a general pull request comment",
"method": "POST",
"path": "/repos/:name/:repo/issues/:issueNumber/comments",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "update a general pull request comment",
"method": "PATCH",
"path": "/repos/:name/:repo/issues/comments/:commentId",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
},
{
"//": "create a pull request review",
"method": "POST",
"path": "/repos/:name/:repo/pulls/:pullRef/reviews",
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
}
]
}
25 changes: 25 additions & 0 deletions test/fixtures/client/github/graphql/find-pull-request-threads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
repository(owner: "test-org", name: "test-repo") {
pullRequest(number: 1) {
reviewThreads(first: 10) {
nodes {
id,
comments(first:1) {
nodes {
id,
pullRequestReview {
id
}
}
}
},
pageInfo {
hasNextPage,
hasPreviousPage,
endCursor,
startCursor
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation
{
resolveReviewThread(input: { threadId: "thread_id" }) {
thread {
comments(first: 1) {
nodes {
id
}
}
}
}
}
10 changes: 10 additions & 0 deletions test/fixtures/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
"//": "query to find open snyk pull requests, allowing auto dependency upgrade pull requests to open no more than a limited amount of pull requests",
"path": "query",
"regex": "{\\s*search\\(\\s*query: \"repo:[a-zA-Z0-9-_.]+\\/[a-zA-Z0-9-_.]+ is:pr state:[a-zA-Z]+ head:snyk-\\s*(is:[a-zA-Z]+)?\", type: ISSUE, last: [0-9]+\\s*\\)\\s*{\\s*edges {\\s*node {\\s*\\.\\.\\. on PullRequest {\\s*url\\s*title\\s*createdAt\\s*headRefName\\s*state\\s*mergeable\\s*body\\s*repository\\s*{\\s*name\\s*}\\s*}\\s*}\\s*}\\s*}\\s*rateLimit\\s*{\\s*limit\\s*cost\\s*remaining\\s*resetAt\\s*}\\s*}\\s*"
},
{
"//": "query for pull request review threads",
"path": "query",
"regex": ".*{\\s*reviewThreads\\(first:\\s*\\d+\\)\\s*{.*"
},
{
"//": "resolve pull request review thread",
"path": "query",
"regex": "mutation\\s*{\\s*resolveReviewThread\\(input:\\s*{\\s*threadId:\\s*\"[a-zA-Z0-9-_.]+\"\\s*}\\)\\s*{.*"
}
]
},
Expand Down
Loading

0 comments on commit 8552340

Please sign in to comment.