-
Notifications
You must be signed in to change notification settings - Fork 848
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
Improved bug board automatization #6071
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,71 @@ jobs: | |
name: Waiting for Engineering | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request | ||
&& contains(github.event.issue.labels.*.name, 'waiting-for-author') | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install jq | ||
- name: Get board column of issue | ||
id: extract_board_column | ||
continue-on-error: true | ||
run: | | ||
# The following GraphQL query requests all issues from a project. It uses the repository | ||
# to locate the issue and get the reference to the project. Then, a filter is applied | ||
# (number: $project) to get the reference to the desired project (i.e., the bug board). | ||
# Now, all issues from this project are requested. The reason for fetching all issues is | ||
# because the current implementation of the GitHub GraphQL API for projects does not | ||
# support server-side filters for issues and we can not restrict the query to our issue. | ||
# Therefore, we fetch all issues and apply a filter on the client side in the next step. | ||
gh api graphql --paginate -F issue=$ISSUE -F project=$PROJECT -F owner=$OWNER -F repo=$REPO -f query=' | ||
query board_column($issue: Int!, $project: Int!, $owner: String!, $repo: String!, $endCursor: String) { | ||
repository(owner: $owner, name: $repo) { | ||
Comment on lines
+59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the search endpoint can help for filtering? I used something like this in my script to find the PRs:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @akuzm I agree. Most GraphQL endpoints allow filtering (e.g., you can search for issues, repositories, PRs..) and this is how GraphQL should work. You could use the search endpoint to find the project, but then you don't have the ability to select a particular issue in this project. I tried a lot of things and read a lot of discussions around it. It seems the ProjectV2 part of the GraphQL-API cannot do server-side filtering of issues at the moment. Furthermore, there is no REST-API available for the ProjectV2 section that could be used as an alternative. |
||
issue(number: $issue) { | ||
projectV2(number: $project) { | ||
items(first: 100, after: $endCursor) { | ||
nodes { | ||
fieldValueByName(name: "Status") { | ||
... on ProjectV2ItemFieldSingleSelectValue { | ||
name | ||
} | ||
} | ||
content { | ||
... on Issue { | ||
id | ||
title | ||
number | ||
repository { | ||
name | ||
owner { | ||
login | ||
} | ||
} | ||
} | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
' > api_result | ||
# Get board column for issue | ||
board_column=$(jq -r ".data.repository.issue.projectV2.items.nodes[] | | ||
select (.content.number == $ISSUE and .content.repository.name == \"$REPO\" and .content.repository.owner.login == \"$OWNER\") | | ||
.fieldValueByName.name" api_result) | ||
echo "Issue is in column: $board_column" | ||
echo "issue_board_column=$board_column" >> "$GITHUB_OUTPUT" | ||
env: | ||
OWNER: timescale | ||
REPO: ${{ github.event.repository.name }} | ||
PROJECT: 55 | ||
ISSUE: ${{ github.event.issue.number }} | ||
GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} | ||
|
||
- name: Check if organization member | ||
uses: tspascoal/get-user-teams-membership@v2 | ||
id: checkUserMember | ||
|
@@ -51,13 +114,15 @@ jobs: | |
team: 'database-eng' | ||
GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} | ||
- name: Remove waiting-for-author label | ||
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false' }} | ||
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false' | ||
&& steps.extract_board_column.outputs.issue_board_column == 'Waiting for Author' }} | ||
uses: andymckay/labeler@3a4296e9dcdf9576b0456050db78cfd34853f260 | ||
with: | ||
remove-labels: 'waiting-for-author, no-activity' | ||
repo-token: ${{ secrets.ORG_AUTOMATION_TOKEN }} | ||
- name: Move to waiting for engineering column | ||
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false' }} | ||
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false' | ||
&& steps.extract_board_column.outputs.issue_board_column == 'Waiting for Author' }} | ||
uses: leonsteinhaeuser/project-beta-automations@v2.0.0 | ||
with: | ||
gh_token: ${{ secrets.ORG_AUTOMATION_TOKEN }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like something that might be useful to turn into a github action, preferably put in https://github.com/timescale/build-actions. This would allow it to be used from both this repository and the timescale-tune repository.