From 8519062d7728f654f8f5a9f790ca769d8a1ce542 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Wed, 23 Oct 2024 16:53:12 -0700 Subject: [PATCH 1/6] update temlplates for more clarity and to work with new script --- .github/ISSUE_TEMPLATE/commitment.md | 3 +++ .github/ISSUE_TEMPLATE/defect-report.md | 3 +++ .github/ISSUE_TEMPLATE/improvement.md | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/commitment.md b/.github/ISSUE_TEMPLATE/commitment.md index 9e96650..559c775 100644 --- a/.github/ISSUE_TEMPLATE/commitment.md +++ b/.github/ISSUE_TEMPLATE/commitment.md @@ -37,6 +37,9 @@ $$reporter: Is there an ask ticket number (ex. 322)? $$ask: +Is there a mcr ticket number (ex. 190)? +$$mcr: + Time estimate (ex. 3 days or 8 hours) $$estimate: diff --git a/.github/ISSUE_TEMPLATE/defect-report.md b/.github/ISSUE_TEMPLATE/defect-report.md index 3339d99..ce07027 100644 --- a/.github/ISSUE_TEMPLATE/defect-report.md +++ b/.github/ISSUE_TEMPLATE/defect-report.md @@ -46,6 +46,9 @@ $$reporter: Is there an ask ticket number (ex. 322)? $$ask: +Is there a mcr ticket number (ex. 190)? +$$mcr: + Time estimate (ex. 3 days or 8 hours) $$estimate: diff --git a/.github/ISSUE_TEMPLATE/improvement.md b/.github/ISSUE_TEMPLATE/improvement.md index 833638e..6e2bb99 100644 --- a/.github/ISSUE_TEMPLATE/improvement.md +++ b/.github/ISSUE_TEMPLATE/improvement.md @@ -33,6 +33,9 @@ $$reporter: Is there an ask ticket number (ex. 322)? $$ask: +Is there a mcr ticket number (ex. 190)? +$$mcr: + Time estimate (ex. 3 days or 8 hours) $$estimate: From d9006c8aacb2bb26d786f7d4bc89967ba962df34 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 24 Oct 2024 13:06:46 -0700 Subject: [PATCH 2/6] adding our issue list generator script for tracking --- issue-list-generator.sh | 217 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100755 issue-list-generator.sh diff --git a/issue-list-generator.sh b/issue-list-generator.sh new file mode 100755 index 0000000..ffe2fbc --- /dev/null +++ b/issue-list-generator.sh @@ -0,0 +1,217 @@ +#!/bin/bash + +# Script Name: issue-list-generator.sh +# Description: Generates a list of issues from a specified GitHub repository and formats them for Confluence. + +# Requires: +# - gh: GitHub CLI (https://github.com/cli/cli) +# - jq: Command-line JSON processor (https://github.com/stedolan/jq) + +# Usage: +# sh ./issue-list-generator.sh -d "" -i "" -f "" +# Then in the confluence page, insert markup and select "Confluence Wiki" as the format and paste the output. + +# Notes: +# - Ensure you have the necessary permissions to access the GitHub repository. +# - Customize the REPO, MILESTONE_NUMBERS, and LABELS variables as needed. + + +# Change as needed +REPO="NASA-AMMOS/openmct-mcws" +MILESTONE_NUMBERS=("11") +MILESTONE_TITLES=() # will be populated with titles mapped to milestone nnumbers +LABELS=("commitment" "improvement" "defect" "sustaining" "documentation" "other") + +# Default charge accounts +CHARGE_ACCOUNT_DEFAULT="N/A" +CHARGE_ACCOUNT_IMPROVEMENT="N/A" +CHARGE_ACCOUNT_DEFECT="N/A" + +# Parse command-line arguments +while getopts "d:i:f:" opt; do + case $opt in + d) CHARGE_ACCOUNT_DEFAULT="$OPTARG" + ;; + i) CHARGE_ACCOUNT_IMPROVEMENT="$OPTARG" + ;; + f) CHARGE_ACCOUNT_DEFECT="$OPTARG" + ;; + \?) echo "Invalid option -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# Fetch and store milestone titles from their numbers +for i in "${!MILESTONE_NUMBERS[@]}"; do + MILESTONE_TITLES[$i]=$(gh api repos/$REPO/milestones/${MILESTONE_NUMBERS[$i]} --jq '.title' -H "Accept: application/vnd.github.v3+json") +done + +# Get the heading based on the label +get_heading() { + case $1 in + "commitment") + echo "Commitments" + ;; + "improvement") + echo "Improvements" + ;; + "defect") + echo "Defect Repairs" + ;; + "sustaining") + echo "Sustaining Activities" + ;; + "documentation") + echo "Documentation" + ;; + "other") + echo "Other" + ;; + *) + echo "Uknown" + ;; + esac +} + +# Get Release Version by milestone +get_release() { + case $1 in + "11") + echo "MC 2512 Point Release 1" + ;; + "12") + echo "MC 2512 Point Release 2" + ;; + "13") + echo "MC 2512 Point Release 3" + ;; + *) + echo "Uknown" + ;; + esac +} + +# Function to extract a variable from the issue body +extract_variable() { + local var_name=$1 + local issue_body=$2 + local value=$(echo "$issue_body" | sed -n "s/.*\$\$$var_name:\(.*\).*/\1/p" | tr -d '\n' | tr -d '\r') + + if [[ "$var_name" == "ask" && -n "$value" ]]; then + echo "[ASK-$value|https://jira.jpl.nasa.gov/browse/ASK-$value]" + elif [[ "$var_name" == "mcr" && -n "$value" ]]; then + echo "[MCR-$value|https://jira.jpl.nasa.gov/browse/MCR-$value]" + elif [[ -n "$value" ]]; then + echo "$value" + elif [[ "$var_name" == "ask" || "$var_name" == "mcr" ]]; then + echo "" + else + echo "N/A" + fi +} + +# List issues for a specific label and format as a Confluence wiki table +list_issues() { + local label=$1 + local heading=$(get_heading $label) + local columns + local jq_filter='.[] | @base64' + + # Constructing the milestone part of the URL + local milestone_part="" + for i in "${!MILESTONE_TITLES[@]}"; do + if [[ -n "$milestone_part" ]]; then + milestone_part+="," + fi + milestone_part+="\"${MILESTONE_TITLES[$i]}\"" + done + + # Loop through provided milestones and pool the issues + local issues="" + for i in "${!MILESTONE_NUMBERS[@]}"; do + local milestone_number=${MILESTONE_NUMBERS[i]} + local issue_data=$(gh issue list --repo "$REPO" --milestone "$milestone_number" --label "$label" --state all --json number,title,url,labels,body --jq "$jq_filter") + local planned_release=$(get_release $milestone_number) + + while IFS= read -r line; do + # Check if no issue + if [ -z "$line" ]; then + break + fi + + local issue_body=$(echo "$line" | base64 --decode | jq '.body') + local issue_number=$(echo "$line" | base64 --decode | jq -r '.number') + local issue_title=$(echo "$line" | base64 --decode | jq -r '.title') + local issue_url=$(echo "$line" | base64 --decode | jq -r '.url') + local ask=$(extract_variable "ask" "$issue_body") + local mcr=$(extract_variable "mcr" "$issue_body") + local related_issue=$(printf '%s%s%s' "$ask" "${ask:+${mcr:+, }}$mcr") + local rationale=$(extract_variable "rationale" "$issue_body") + local reporter=$(extract_variable "reporter" "$issue_body") + local estimated_hours=$(extract_variable "estimate" "$issue_body") + local requester=$(extract_variable "requester" "$issue_body") + local doc_id=$(extract_variable "docid" "$issue_body") + local issue_labels=$(echo "$line" | base64 --decode | jq -r '.labels | map(.name) | join(", ")') + local criticality=$(echo "$issue_labels" | grep -o 'crit-[1-4]' | sed 's/crit-//' || echo "N/A") + criticality=${criticality:-N/A} + local is_security_related="n" + if [[ $issue_labels == *"security"* ]]; then + is_security_related="y" + fi + + # Select charge account based on label + local charge_account=$CHARGE_ACCOUNT_DEFAULT + if [[ "$label" == "improvement" ]]; then + charge_account=$CHARGE_ACCOUNT_IMPROVEMENT + elif [[ "$label" == "defect" ]]; then + charge_account=$CHARGE_ACCOUNT_DEFECT + fi + + # Define columns and extract variables based on label + case $label in + "commitment") + columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Rationale* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${rationale} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" + ;; + "improvement") + columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" + ;; + "defect") + columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Criticality* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${related_issue} | ${reporter} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${criticality} | ${planned_release} |\n$issues" + ;; + "sustaining") + columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${rationale} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" + ;; + "documentation") + columns="|| *ID* || *Title* || *Doc-id* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${doc_id} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" + ;; + "other") + columns="|| *ID* || *Title* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" + issues="| [$issue_number|$issue_url] | $issue_title | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" + ;; + esac + done <<< "$issue_data" + + done + + echo "h3. $heading" + echo "*Repository*: [openmct-mcws|https://github.com/NASA-AMMOS/openmct-mcws]" + + if [[ -z "$issues" ]]; then + echo None. + else + echo "$columns" + echo "$issues" + fi + echo +} + +# Main Script +for label in "${LABELS[@]}"; do + list_issues "$label" +done From d9d8178982d52ad3d721f4fa388c3422f6f09986 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Wed, 6 Nov 2024 13:25:01 -0800 Subject: [PATCH 3/6] moving documentation section to other section --- .github/ISSUE_TEMPLATE/documentation.md | 2 +- issue-list-generator.sh | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md index 026d8b6..5084752 100644 --- a/.github/ISSUE_TEMPLATE/documentation.md +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -2,7 +2,7 @@ name: Documentation about: A modification to the project's released documentation. title: '' -labels: documentation +labels: documentation, other assignees: '' --- diff --git a/issue-list-generator.sh b/issue-list-generator.sh index ffe2fbc..03be0cf 100755 --- a/issue-list-generator.sh +++ b/issue-list-generator.sh @@ -20,7 +20,7 @@ REPO="NASA-AMMOS/openmct-mcws" MILESTONE_NUMBERS=("11") MILESTONE_TITLES=() # will be populated with titles mapped to milestone nnumbers -LABELS=("commitment" "improvement" "defect" "sustaining" "documentation" "other") +LABELS=("commitment" "improvement" "defect" "sustaining" "other") # Default charge accounts CHARGE_ACCOUNT_DEFAULT="N/A" @@ -62,9 +62,6 @@ get_heading() { "sustaining") echo "Sustaining Activities" ;; - "documentation") - echo "Documentation" - ;; "other") echo "Other" ;; @@ -186,14 +183,10 @@ list_issues() { columns="|| *ID* || *Title* || *Rational/Issue (PRS/ASK/MCR)* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" issues="| [$issue_number|$issue_url] | $issue_title | ${rationale} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" ;; - "documentation") + "other") columns="|| *ID* || *Title* || *Doc-id* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" issues="| [$issue_number|$issue_url] | $issue_title | ${doc_id} | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" ;; - "other") - columns="|| *ID* || *Title* || *Requester/Reporter* || *Estimated Hours* || *Charge Account* || *Security Related (y/n)* || *Release Version* ||" - issues="| [$issue_number|$issue_url] | $issue_title | ${requester} | ${estimated_hours} | ${charge_account} | ${is_security_related} | ${planned_release} |\n$issues" - ;; esac done <<< "$issue_data" From 80a967751bc63d0e91f95ff13ec075ca67bff100 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Wed, 6 Nov 2024 13:33:37 -0800 Subject: [PATCH 4/6] changing commitment to requirement --- .github/ISSUE_TEMPLATE/commitment.md | 2 +- issue-list-generator.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/commitment.md b/.github/ISSUE_TEMPLATE/commitment.md index 559c775..3fd0cd6 100644 --- a/.github/ISSUE_TEMPLATE/commitment.md +++ b/.github/ISSUE_TEMPLATE/commitment.md @@ -1,5 +1,5 @@ --- -name: Commitment +name: Requirement 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 title: '' labels: commitment diff --git a/issue-list-generator.sh b/issue-list-generator.sh index 03be0cf..199becc 100755 --- a/issue-list-generator.sh +++ b/issue-list-generator.sh @@ -51,7 +51,7 @@ done get_heading() { case $1 in "commitment") - echo "Commitments" + echo "Requirements" ;; "improvement") echo "Improvements" From 0ce73cbbf734d93aac6e0a055e827f920a1c1a99 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Wed, 6 Nov 2024 13:33:50 -0800 Subject: [PATCH 5/6] changing commitment to requirement --- .github/ISSUE_TEMPLATE/commitment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/commitment.md b/.github/ISSUE_TEMPLATE/commitment.md index 3fd0cd6..f7cac8f 100644 --- a/.github/ISSUE_TEMPLATE/commitment.md +++ b/.github/ISSUE_TEMPLATE/commitment.md @@ -2,7 +2,7 @@ name: Requirement 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 title: '' -labels: commitment +labels: commitment, requirement assignees: '' --- From f3afda4852afc0350594cf7ccaa0baa69b926c60 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 7 Nov 2024 09:57:39 -0800 Subject: [PATCH 6/6] for some reason bash header throwing off formatting --- issue-list-generator.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/issue-list-generator.sh b/issue-list-generator.sh index 199becc..cbb66a6 100755 --- a/issue-list-generator.sh +++ b/issue-list-generator.sh @@ -1,5 +1,3 @@ -#!/bin/bash - # Script Name: issue-list-generator.sh # Description: Generates a list of issues from a specified GitHub repository and formats them for Confluence.