-
Notifications
You must be signed in to change notification settings - Fork 142
fix: replace searchAPI
usage with GraphQL
in findSRIssue
util
#907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
d8fb827
feat: add graphql query loader `loadGetSRIssuesQuery` to fetch SRIssues
babblebey 8945a63
chore: add new `RELEASE_FAIL_LABEL` constant
babblebey 70ca54f
feat: integrate issues fetch with graphql
babblebey 7f9875a
feat: add fallback to searchAPI for backward compatibility
babblebey f2c9b84
feat: integrated config label in SRIssues search
babblebey f8160f3
fix: error `getSRIssue` graphql query label param type
babblebey 63c1dc5
fix: undefined `data` property destructed from graphql reponse
babblebey 9189ccf
refactor: modified wrong `body` property in query
babblebey a478a2b
refactor: remove conditions from searchAPI fallback logic
babblebey 4bf11b0
refactor: replace `getSRIssues` graphql query `label` param with `fil…
babblebey 7be5548
feat: implement unique issue sorting to address fallback `backwardIss…
babblebey c95a52f
feat: modify `findSRIssue` integration in `success` script; add `logg…
babblebey 5c18493
feat: integrate opinionated `RELEASE_FAIL_LABEL` into `fail` script
babblebey cf6f182
chore: Questions and lint fixes
babblebey f4aec76
Merge branch 'master' into feat/gql-for-search-api
babblebey 9373a70
refactor: modified `findSRIssues` integration in `fail` script
babblebey 66437fd
Merge branch 'feat/gql-for-search-api' of https://github.com/semantic…
babblebey cbe47c7
test: fixed `findSRIssue` units test
babblebey 2efba0e
test: fixed `fail` unit tests
babblebey 91dec1c
test: fix integrations test
babblebey ba214de
test: fixed `success` unit tests
babblebey 50c3f9c
test: `Verify, release and notify success` fix attempt
babblebey 2f2b154
test: addressed `"Verify, release and notify success"` case in `integ…
babblebey b03fcd8
Merge branch 'master' into feat/gql-for-search-api
babblebey ebfbaf0
Merge branch 'master' of https://github.com/semantic-release/github i…
babblebey a0ac832
test: fix `success` units
babblebey f3a6bd6
test: fix `fail` units
babblebey 5a6d6dd
refactor: remove error object from searchAPI fallback error handle
babblebey 0e3c2dc
test: add new case `"Handle error in searchAPI fallback"`
babblebey fc19b40
Merge branch 'master' into feat/gql-for-search-api
babblebey 65adac0
Merge branch 'master' into feat/gql-for-search-api
babblebey 21dea8c
Merge branch 'master' into feat/gql-for-search-api
babblebey 1065e08
Revert "refactor: remove conditions from searchAPI fallback logic"
babblebey 2ce3efe
modified `RELEASE_FAIL_LABEL` value to `semantic-release`
babblebey b595743
test: fix cases for conditional `searchAPI` fallback consumption
babblebey e40128f
Merge branch 'master' into feat/gql-for-search-api
babblebey 9329cbc
Update lib/resolve-config.js
babblebey 15ba2ad
Merge branch 'master' into feat/gql-for-search-api
babblebey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,5 @@ | ||
export const ISSUE_ID = "<!-- semantic-release:github -->"; | ||
|
||
export const RELEASE_NAME = "GitHub release"; | ||
|
||
export const RELEASE_FAIL_LABEL = "release-failing"; |
This file contains hidden or 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 hidden or 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,11 +1,61 @@ | ||
import { ISSUE_ID } from "./definitions/constants.js"; | ||
import { uniqBy } from "lodash-es"; | ||
import { ISSUE_ID, RELEASE_FAIL_LABEL } from "./definitions/constants.js"; | ||
|
||
export default async (octokit, logger, title, labels, owner, repo) => { | ||
let issues = []; | ||
|
||
export default async (octokit, title, owner, repo) => { | ||
const { | ||
data: { items: issues }, | ||
} = await octokit.request("GET /search/issues", { | ||
q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`, | ||
repository: { | ||
issues: { nodes: issueNodes }, | ||
}, | ||
} = await octokit.graphql(loadGetSRIssuesQuery, { | ||
owner, | ||
repo, | ||
filter: { | ||
labels: (labels || []).concat([RELEASE_FAIL_LABEL]), | ||
}, | ||
}); | ||
|
||
return issues.filter((issue) => issue.body && issue.body.includes(ISSUE_ID)); | ||
issues.push(...issueNodes); | ||
|
||
/** | ||
* BACKWARD COMPATIBILITY: Fallback to the search API if the issue was not found in the GraphQL response. | ||
* This fallback will be removed in a future release | ||
*/ | ||
try { | ||
const { | ||
data: { items: backwardIssues }, | ||
} = await octokit.request("GET /search/issues", { | ||
q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`, | ||
}); | ||
issues.push(...backwardIssues); | ||
} catch (error) { | ||
logger.log( | ||
"An error occured fetching issue via fallback (with GH SearchAPI)", | ||
); | ||
} | ||
|
||
const uniqueSRIssues = uniqBy( | ||
issues.filter((issue) => issue.body && issue.body.includes(ISSUE_ID)), | ||
"number", | ||
); | ||
|
||
return uniqueSRIssues; | ||
}; | ||
|
||
/** | ||
* GraphQL Query to et the semantic-release issues for a repository. | ||
*/ | ||
const loadGetSRIssuesQuery = `#graphql | ||
query getSRIssues($owner: String!, $repo: String!, $filter: IssueFilters) { | ||
repository(owner: $owner, name: $repo) { | ||
issues(first: 100, states: OPEN, filterBy: $filter) { | ||
nodes { | ||
number | ||
title | ||
body | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.