Closed sladyn98 closed 2 years ago
I tried running this query
{
repository(owner: "jenkinsci", name:"custom-distribution-service"){
url
pullRequest(number: 162){
number
url
author {
login
url
}
commits(last: 1){
nodes{
commit{
commitUrl
oid
status {
state
contexts {
state
targetUrl
description
context
}
}
}
}
}
}
}
}
This was the data i got returned and as we can see it returns the status check for the commit
{
"data": {
"repository": {
"url": "https://github.com/jenkinsci/custom-distribution-service",
"pullRequest": {
"number": 162,
"url": "https://github.com/jenkinsci/custom-distribution-service/pull/162",
"author": {
"login": "sladyn98",
"url": "https://github.com/sladyn98"
},
"commits": {
"nodes": [
{
"commit": {
"commitUrl": "https://github.com/jenkinsci/custom-distribution-service/commit/4648520244d8879c60ddcb2b53b78c6164b4715b",
"oid": "4648520244d8879c60ddcb2b53b78c6164b4715b",
"status": {
"state": "FAILURE",
"contexts": [
{
"state": "ERROR",
"targetUrl": "https://ci.jenkins.io/job/Tools/job/custom-distribution-service/job/PR-162/7/display/redirect",
"description": "The build of this commit was aborted",
"context": "continuous-integration/jenkins/pr-merge"
}
]
}
}
}
]
}
}
}
}
}
You may also want to try some PRs with a lot of different status checks:
Yeah I guess this is the issue so if I try to get the status of a repo I am not a collaborator for or dont have write access to the status returns null
{
"data": {
"repository": {
"url": "https://github.com/es-shims/Promise.any",
"pullRequest": {
"number": 9,
"url": "https://github.com/es-shims/Promise.any/pull/9",
"author": {
"login": "ljharb",
"url": "https://github.com/ljharb"
},
"commits": {
"nodes": [
{
"commit": {
"commitUrl": "https://github.com/es-shims/Promise.any/commit/660317fd059f9b83980181ea1067b99d94c40351",
"oid": "660317fd059f9b83980181ea1067b99d94c40351",
"status": null
}
}
]
}
}
Edit: I do not think it would be an issue for us since the query user would have write access and the token
hm, interesting. I can provide you a token if needed that has commit status read permissions, but I’d expect it to be globally readable.
@ljharb yeah, since the API is built in a way to provide statuses to only authenticated tokens with certain permissions. The CLI tool could start off with the token and then do the later stuff using that token. Does Not harm us to have 5000 requests per hour with an authenticated token
https://www.npmjs.com/package/hawk-fetch Created a small npm package to get the status object in the response. Maybe we can extend the functionality of the package to later parse the statuses and do something with it.
We need to fetch the following information a) Status b) Context of the status check c) If all checks have passed