generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: make roadmap issues mini dashboards (#2520)
- Loading branch information
Showing
3 changed files
with
185 additions
and
3 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 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 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,140 @@ | ||
#!/bin/bash | ||
|
||
label="$1" | ||
issue_number="$2" | ||
if [ -z "$label" ] || [ -z "$issue_number" ]; then | ||
echo "Error: Both label and issue number must be provided." | ||
echo "Usage: $0 <label> <issue_number>" | ||
exit 1 | ||
fi | ||
|
||
map_to_markdown() { | ||
echo 'map("- #\(.number) \(.labels | map(select(.name != "run-all")) | map("https://github.com/TBD54566975/ftl/labels/\(.name | gsub(" ";"%20"))") | join(" "))")[]' | ||
} | ||
|
||
list_issues() { | ||
gh issue list "$@" --label "$label" --json number,labels | jq -r "$(map_to_markdown)" | sort -n | ||
} | ||
|
||
search_issues() { | ||
gh search issues --label "$label" --state open --repo TBD54566975/ftl --json number,labels "$@" | jq -r "$(map_to_markdown)" | sort -n | ||
} | ||
|
||
list_prioritized_issues() { | ||
gh issue list "$@" --label "$label" --json number,labels | jq '.[]' | jq -s ' | ||
map( | ||
. as $issue | | ||
($issue.labels | map(select(.name == "P0")) | length > 0) as $p0 | | ||
($issue.labels | map(select(.name == "P1")) | length > 0) as $p1 | | ||
($issue.labels | map(select(.name == "P2")) | length > 0) as $p2 | | ||
($issue.labels | map(select(.name == "P3")) | length > 0) as $p3 | | ||
$issue + {priority: (if $p0 then 0 elif $p1 then 1 elif $p2 then 2 elif $p3 then 3 else 4 end)} | ||
) | | ||
sort_by(.priority) | | ||
map(del(.priority)) | ||
' | jq -r "$(map_to_markdown)" | ||
} | ||
# | ||
list_issues_and_prs() { | ||
user="$1" | ||
shift | ||
|
||
issues="$(gh issue list --label "$label" -a "$user" "$@" --json number,labels,closedAt)" | ||
if [ -z "$issues" ] || [ "$issues" = "[]" ]; then | ||
return | ||
fi | ||
|
||
prs="$(gh pr list -A "$user" "$@" --json number,labels,mergedAt | jq '[.[] | .["closedAt"] = .mergedAt | del(.mergedAt)]')" | ||
combined="$(echo "$issues" "$prs" | jq -rs 'add | sort_by(.closedAt) | reverse')" | ||
echo "$combined" | jq -r "$(map_to_markdown)" | ||
} | ||
|
||
update_issue_template() { | ||
update_issue <<EOF | ||
<!-- This file is generated by scripts/update-workflow-issue. Do not edit manually. --> | ||
$( | ||
issues="$(list_issues --label P0)" | ||
test -z "$issues" && exit 0 | ||
echo "### https://github.com/TBD54566975/ftl/labels/P0" | ||
echo | ||
echo "> [!WARNING]" | ||
echo "> These issues are P0 and need immediate attention." | ||
echo "$issues" | ||
) | ||
### Active and recent issues | ||
$( | ||
if [ "$(uname -o)" = "GNU/Linux" ] || date --help | grep -q "GNU"; then | ||
date="$(date -d "- 5 days" +%Y-%m-%d)" | ||
else | ||
date="$(date -v "-5d" +%Y-%m-%d)" | ||
fi | ||
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/TBD54566975/teams/ftl-team/members | jq -r '.[].login' | grep -v dhanji | sort | while read -r member; do | ||
issues_and_prs=$(list_issues_and_prs "$member") | ||
closed_issues_and_prs="$(list_issues_and_prs "$member" -s closed -S "closed:>$date")" | ||
if [ -n "$issues_and_prs" ] || [ -n "$closed_issues_and_prs" ]; then | ||
echo "@$member [🔎](https://github.com/TBD54566975/ftl/issues/assigned/$member)" | ||
echo "$issues_and_prs" | ||
echo "$closed_issues_and_prs" | ||
echo | ||
fi | ||
done | ||
) | ||
$( | ||
issues="$(list_issues --label triage)" | ||
test -z "$issues" && exit 0 | ||
echo "### https://github.com/TBD54566975/ftl/labels/triage" | ||
echo | ||
echo "$issues" | ||
) | ||
### https://github.com/TBD54566975/ftl/labels/next | ||
$( | ||
issues="$(list_prioritized_issues --label next)" | ||
if test -z "$issues"; then | ||
echo "> [!WARNING]" | ||
echo "> There are no issues labelled for upcoming work." | ||
exit 0 | ||
fi | ||
echo "$issues" | ||
) | ||
$( | ||
issues="$(list_issues --label epic)" | ||
test -z "$issues" && exit 0 | ||
echo "### https://github.com/TBD54566975/ftl/labels/epic" | ||
echo "$issues" | ||
) | ||
$( | ||
echo "### Backlog" | ||
echo | ||
issues="$(search_issues --no-assignee -- -label:next -label:triage -label:roadmap)" | ||
if [ -n "$issues" ]; then | ||
echo "$issues" | ||
else | ||
echo "> [!NOTE]" | ||
echo "> There are no issues." | ||
fi | ||
) | ||
EOF | ||
} | ||
|
||
update_issue() { | ||
if test -z "$NOOP"; then | ||
gh issue edit -F - "$issue_number" | ||
else | ||
cat | ||
fi | ||
} | ||
|
||
update_issue_template "$issue_number" "$label" |