forked from determined-ai/determined
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: handle cherry-pick marker label in release automation (determined…
…-ai#6911) Following on from determined-ai#6867, this adds some more steps to the release automation. The workflows now handle a special label that marks a PR as a fix to be cherry-picked for the current release. There's also scaffolding for some future steps for actually handling the cherry-picks; some of that implementation is left stubbed out for now, but I believe this should cover the full shape of the Actions lifecycle we have in mind. Remaining work will lie in filling in that implementation and updating rph to handle the human side of things.
- Loading branch information
Showing
4 changed files
with
427 additions
and
103 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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
import os | ||
from typing import Any | ||
|
||
import requests | ||
|
||
GRAPHQL_URL = "https://api.github.com/graphql" | ||
|
||
DEBUG = os.environ.get("DET_DEBUG") == "1" | ||
|
||
|
||
class GraphQLQuery(str): | ||
def __call__(self, **args: Any) -> Any: | ||
if DEBUG: | ||
print("================ GraphQL query") | ||
print(self.strip()) | ||
print(args) | ||
r = requests.post( | ||
GRAPHQL_URL, | ||
headers={"Authorization": "bearer " + os.environ["GITHUB_TOKEN"]}, | ||
json={"query": self, "variables": args}, | ||
) | ||
r.raise_for_status() | ||
j = r.json() | ||
if DEBUG: | ||
print(j) | ||
try: | ||
return j["data"] | ||
except Exception: | ||
print(j) | ||
raise | ||
|
||
|
||
get_repo_id = GraphQLQuery( | ||
""" | ||
query($owner: String!, $name: String!) { | ||
repository(owner: $owner, name: $name) { | ||
id | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_pr_id = GraphQLQuery( | ||
""" | ||
query($owner: String!, $repo: String!, $number: Int!) { | ||
repository(owner: $owner, name: $repo) { | ||
pullRequest(number: $number) { | ||
id | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
|
||
search_projects = GraphQLQuery( | ||
""" | ||
query($owner: String!, $q: String!) { | ||
organization(login: $owner) { | ||
projectsV2(query: $q, first: 100) { | ||
nodes { | ||
id | ||
title | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_project_status_field = GraphQLQuery( | ||
""" | ||
query($project: ID!) { | ||
node(id: $project) { | ||
... on ProjectV2 { | ||
field(name: "Status") { | ||
... on ProjectV2SingleSelectField { | ||
id | ||
options { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
create_issue = GraphQLQuery( | ||
""" | ||
mutation($repo: ID!, $title: String!, $body: String!) { | ||
createIssue(input: {repositoryId: $repo, title: $title, body: $body}) { | ||
issue { | ||
id | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
add_item_to_project = GraphQLQuery( | ||
""" | ||
mutation($project: ID!, $item: ID!) { | ||
addProjectV2ItemById(input: {projectId: $project, contentId: $item}) { | ||
item { | ||
id | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_status_field_info = GraphQLQuery( | ||
""" | ||
query($project: ID!) { | ||
node(id: $project) { | ||
... on ProjectV2 { | ||
field(name: "Status") { | ||
... on ProjectV2SingleSelectField { | ||
id | ||
options { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
set_project_item_status = GraphQLQuery( | ||
""" | ||
mutation($project: ID!, $item: ID!, $field: ID!, $value: String) { | ||
updateProjectV2ItemFieldValue( | ||
input: { | ||
projectId: $project, itemId: $item, fieldId: $field, value: {singleSelectOptionId: $value} | ||
} | ||
) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_pr_labels = GraphQLQuery( | ||
""" | ||
query($id: ID!) { | ||
node(id: $id) { | ||
... on PullRequest { | ||
labels(first: 100) { | ||
nodes { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_pr_merge_commit = GraphQLQuery( | ||
""" | ||
query($id: ID!) { | ||
node(id: $id) { | ||
... on PullRequest { | ||
mergeCommit { | ||
oid | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
get_pr_info = GraphQLQuery( | ||
""" | ||
query($id: ID!) { | ||
node(id: $id) { | ||
... on PullRequest { | ||
number | ||
title | ||
url | ||
repository { | ||
owner { | ||
login | ||
} | ||
name | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
|
||
get_pr_state = GraphQLQuery( | ||
""" | ||
query($id: ID!) { | ||
node(id: $id) { | ||
... on PullRequest { | ||
state | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
|
||
delete_project_item = GraphQLQuery( | ||
""" | ||
mutation($project: ID!, $item: ID!) { | ||
deleteProjectV2Item(input: {projectId: $project, itemId: $item}) { | ||
deletedItemId | ||
} | ||
} | ||
""" | ||
) |
Oops, something went wrong.