Skip to content

Commit 125d79a

Browse files
jvigliottadavetsay
andauthored
Update templates to add more clarity in release plans (#224)
Co-authored-by: David Tsay <[email protected]>
1 parent a1b9468 commit 125d79a

File tree

5 files changed

+220
-3
lines changed

5 files changed

+220
-3
lines changed

.github/ISSUE_TEMPLATE/commitment.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
name: Commitment
2+
name: Requirement
33
about: Items in this category are considered significant to the functionality of the software, the workload of the subsystem or a promised commitment to customers or the MGSS Program Office
44
title: ''
5-
labels: commitment
5+
labels: commitment, requirement
66
assignees: ''
77

88
---
@@ -37,6 +37,9 @@ $$reporter:
3737
Is there an ask ticket number (ex. 322)?
3838
$$ask:
3939
40+
Is there a mcr ticket number (ex. 190)?
41+
$$mcr:
42+
4043
Time estimate (ex. 3 days or 8 hours)
4144
$$estimate:
4245

.github/ISSUE_TEMPLATE/defect-report.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ $$reporter:
4646
Is there an ask ticket number (ex. 322)?
4747
$$ask:
4848
49+
Is there a mcr ticket number (ex. 190)?
50+
$$mcr:
51+
4952
Time estimate (ex. 3 days or 8 hours)
5053
$$estimate:
5154

.github/ISSUE_TEMPLATE/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Documentation
33
about: A modification to the project's released documentation.
44
title: ''
5-
labels: documentation
5+
labels: documentation, other
66
assignees: ''
77

88
---

.github/ISSUE_TEMPLATE/improvement.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ $$reporter:
3333
Is there an ask ticket number (ex. 322)?
3434
$$ask:
3535
36+
Is there a mcr ticket number (ex. 190)?
37+
$$mcr:
38+
3639
Time estimate (ex. 3 days or 8 hours)
3740
$$estimate:
3841

issue-list-generator.sh

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Script Name: issue-list-generator.sh
2+
# Description: Generates a list of issues from a specified GitHub repository and formats them for Confluence.
3+
4+
# Requires:
5+
# - gh: GitHub CLI (https://github.com/cli/cli)
6+
# - jq: Command-line JSON processor (https://github.com/stedolan/jq)
7+
8+
# Usage:
9+
# sh ./issue-list-generator.sh -d "<default_charge_account>" -i "<improvement_charge_account>" -f "<defect_charge_account>"
10+
# Then in the confluence page, insert markup and select "Confluence Wiki" as the format and paste the output.
11+
12+
# Notes:
13+
# - Ensure you have the necessary permissions to access the GitHub repository.
14+
# - Customize the REPO, MILESTONE_NUMBERS, and LABELS variables as needed.
15+
16+
17+
# Change as needed
18+
REPO="NASA-AMMOS/openmct-mcws"
19+
MILESTONE_NUMBERS=("11")
20+
MILESTONE_TITLES=() # will be populated with titles mapped to milestone nnumbers
21+
LABELS=("commitment" "improvement" "defect" "sustaining" "other")
22+
23+
# Default charge accounts
24+
CHARGE_ACCOUNT_DEFAULT="N/A"
25+
CHARGE_ACCOUNT_IMPROVEMENT="N/A"
26+
CHARGE_ACCOUNT_DEFECT="N/A"
27+
28+
# Parse command-line arguments
29+
while getopts "d:i:f:" opt; do
30+
case $opt in
31+
d) CHARGE_ACCOUNT_DEFAULT="$OPTARG"
32+
;;
33+
i) CHARGE_ACCOUNT_IMPROVEMENT="$OPTARG"
34+
;;
35+
f) CHARGE_ACCOUNT_DEFECT="$OPTARG"
36+
;;
37+
\?) echo "Invalid option -$OPTARG" >&2
38+
exit 1
39+
;;
40+
esac
41+
done
42+
43+
# Fetch and store milestone titles from their numbers
44+
for i in "${!MILESTONE_NUMBERS[@]}"; do
45+
MILESTONE_TITLES[$i]=$(gh api repos/$REPO/milestones/${MILESTONE_NUMBERS[$i]} --jq '.title' -H "Accept: application/vnd.github.v3+json")
46+
done
47+
48+
# Get the heading based on the label
49+
get_heading() {
50+
case $1 in
51+
"commitment")
52+
echo "Requirements"
53+
;;
54+
"improvement")
55+
echo "Improvements"
56+
;;
57+
"defect")
58+
echo "Defect Repairs"
59+
;;
60+
"sustaining")
61+
echo "Sustaining Activities"
62+
;;
63+
"other")
64+
echo "Other"
65+
;;
66+
*)
67+
echo "Uknown"
68+
;;
69+
esac
70+
}
71+
72+
# Get Release Version by milestone
73+
get_release() {
74+
case $1 in
75+
"11")
76+
echo "MC 2512 Point Release 1"
77+
;;
78+
"12")
79+
echo "MC 2512 Point Release 2"
80+
;;
81+
"13")
82+
echo "MC 2512 Point Release 3"
83+
;;
84+
*)
85+
echo "Uknown"
86+
;;
87+
esac
88+
}
89+
90+
# Function to extract a variable from the issue body
91+
extract_variable() {
92+
local var_name=$1
93+
local issue_body=$2
94+
local value=$(echo "$issue_body" | sed -n "s/.*\$\$$var_name:\(.*\).*/\1/p" | tr -d '\n' | tr -d '\r')
95+
96+
if [[ "$var_name" == "ask" && -n "$value" ]]; then
97+
echo "[ASK-$value|https://jira.jpl.nasa.gov/browse/ASK-$value]"
98+
elif [[ "$var_name" == "mcr" && -n "$value" ]]; then
99+
echo "[MCR-$value|https://jira.jpl.nasa.gov/browse/MCR-$value]"
100+
elif [[ -n "$value" ]]; then
101+
echo "$value"
102+
elif [[ "$var_name" == "ask" || "$var_name" == "mcr" ]]; then
103+
echo ""
104+
else
105+
echo "N/A"
106+
fi
107+
}
108+
109+
# List issues for a specific label and format as a Confluence wiki table
110+
list_issues() {
111+
local label=$1
112+
local heading=$(get_heading $label)
113+
local columns
114+
local jq_filter='.[] | @base64'
115+
116+
# Constructing the milestone part of the URL
117+
local milestone_part=""
118+
for i in "${!MILESTONE_TITLES[@]}"; do
119+
if [[ -n "$milestone_part" ]]; then
120+
milestone_part+=","
121+
fi
122+
milestone_part+="\"${MILESTONE_TITLES[$i]}\""
123+
done
124+
125+
# Loop through provided milestones and pool the issues
126+
local issues=""
127+
for i in "${!MILESTONE_NUMBERS[@]}"; do
128+
local milestone_number=${MILESTONE_NUMBERS[i]}
129+
local issue_data=$(gh issue list --repo "$REPO" --milestone "$milestone_number" --label "$label" --state all --json number,title,url,labels,body --jq "$jq_filter")
130+
local planned_release=$(get_release $milestone_number)
131+
132+
while IFS= read -r line; do
133+
# Check if no issue
134+
if [ -z "$line" ]; then
135+
break
136+
fi
137+
138+
local issue_body=$(echo "$line" | base64 --decode | jq '.body')
139+
local issue_number=$(echo "$line" | base64 --decode | jq -r '.number')
140+
local issue_title=$(echo "$line" | base64 --decode | jq -r '.title')
141+
local issue_url=$(echo "$line" | base64 --decode | jq -r '.url')
142+
local ask=$(extract_variable "ask" "$issue_body")
143+
local mcr=$(extract_variable "mcr" "$issue_body")
144+
local related_issue=$(printf '%s%s%s' "$ask" "${ask:+${mcr:+, }}$mcr")
145+
local rationale=$(extract_variable "rationale" "$issue_body")
146+
local reporter=$(extract_variable "reporter" "$issue_body")
147+
local estimated_hours=$(extract_variable "estimate" "$issue_body")
148+
local requester=$(extract_variable "requester" "$issue_body")
149+
local doc_id=$(extract_variable "docid" "$issue_body")
150+
local issue_labels=$(echo "$line" | base64 --decode | jq -r '.labels | map(.name) | join(", ")')
151+
local criticality=$(echo "$issue_labels" | grep -o 'crit-[1-4]' | sed 's/crit-//' || echo "N/A")
152+
criticality=${criticality:-N/A}
153+
local is_security_related="n"
154+
if [[ $issue_labels == *"security"* ]]; then
155+
is_security_related="y"
156+
fi
157+
158+
# Select charge account based on label
159+
local charge_account=$CHARGE_ACCOUNT_DEFAULT
160+
if [[ "$label" == "improvement" ]]; then
161+
charge_account=$CHARGE_ACCOUNT_IMPROVEMENT
162+
elif [[ "$label" == "defect" ]]; then
163+
charge_account=$CHARGE_ACCOUNT_DEFECT
164+
fi
165+
166+
# Define columns and extract variables based on label
167+
case $label in
168+
"commitment")
169+
columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Rationale* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||"
170+
issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${rationale} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues"
171+
;;
172+
"improvement")
173+
columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||"
174+
issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues"
175+
;;
176+
"defect")
177+
columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Criticality* || *Release Version* ||"
178+
issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${criticality} | ${planned_release} |\n$issues"
179+
;;
180+
"sustaining")
181+
columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||"
182+
issues="| [$issue_number|$issue_url] | $issue_title | ${rationale} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues"
183+
;;
184+
"other")
185+
columns="|| *ID* || *Title* || *Doc-id* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||"
186+
issues="| [$issue_number|$issue_url] | $issue_title | ${doc_id} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues"
187+
;;
188+
esac
189+
done <<< "$issue_data"
190+
191+
done
192+
193+
echo "h3. $heading"
194+
echo "*Repository*: [openmct-mcws|https://github.com/NASA-AMMOS/openmct-mcws]"
195+
196+
if [[ -z "$issues" ]]; then
197+
echo None.
198+
else
199+
echo "$columns"
200+
echo "$issues"
201+
fi
202+
echo
203+
}
204+
205+
# Main Script
206+
for label in "${LABELS[@]}"; do
207+
list_issues "$label"
208+
done

0 commit comments

Comments
 (0)