#/bin/bash [ -z "$MAYBE_GH" ] && export MAYBE_GH="gh" GH_ISSUE="${MAYBE_GH} issue" [ "${1}" = "-t" ] && shift 1 && GH_ISSUE="echo SKIPPING $GH_ISSUE" GIT_REV=$(git rev-parse HEAD) LINKS="https://github.com/logicmoo/logicmoo_workspace/commit/${GIT_REV} https://logicmoo.org:2082/gitlab/logicmoo/logicmoo_workspace/-/commit/${GIT_REV}" Add_LABELS="${7}" && [ ! -z "$Add_LABELS" ] && Add_LABELS=",$Add_LABELS" Rem_LABELS="${8}" && [ ! -z "$Rem_LABELS" ] && Rem_LABELS=",$Rem_LABELS" # foc_gh_issue 1${JUNIT_PACKAGE} 2${JUNIT_SHORTCLASS} 3${Test_9999} 4${TEST_RESULT} 5"${Title}" 6${BodyFile} function foc_gh_issue { [ -z "${GH_MASTER_ISSUE_INFO}" ] && export GH_MASTER_ISSUE_INFO=`gh issue list -l ${1} -L 1000 | sed -e "s/UTC /\n/g" | grep "unit_test"` [ -z "${GH_MASTER_ISSUE_INFO}" ] && export GH_MASTER_ISSUE_INFO=`gh issue list -l unit_test -L 2000 | sed -e "s/UTC /\n/g" | grep "unit_test"` ISSUE_INFO=$(echo "${GH_MASTER_ISSUE_INFO}" | grep "${1}.${2} " | grep ${3} | head -1) echo "ISSUE_INFO=${ISSUE_INFO}" ISSUE_ID=$(echo "${ISSUE_INFO}" | cut -f1) echo "ISSUE_ID=${ISSUE_ID}" ISSUE_OC=$(echo "${ISSUE_INFO}" | cut -f2) echo "ISSUE_OC=${ISSUE_OC}" if [ "${4}" = "SUCCESS" ]; then (if [ "${ISSUE_OC}" = "OPEN" ]; then echo "Updating Issue $ISSUE_INFO" if echo "${ISSUE_INFO}" | grep -q "Failing"; then $GH_ISSUE comment ${ISSUE_ID} -b "Fixed in ${LINKS}" $GH_ISSUE edit ${ISSUE_ID} -F ${6} --add-label "Passing$Add_LABELS" --remove-label "Failing,Regression$Rem_LABELS" else $GH_ISSUE edit ${ISSUE_ID} -F ${6} --add-label "Passing$Add_LABELS" --remove-label "Failing,Regression$Rem_LABELS" fi #$GH_ISSUE close ${ISSUE_ID} elif [ -z "${ISSUE_ID}" ]; then echo "Creating Issue For ${4} $ISSUE_INFO" $GH_ISSUE create -l "unit_test,${1},${2},${3},Passing$Add_LABELS" -t "${5}" -F ${6} else echo "NOT Editing Closed For ${4} Issue $ISSUE_INFO" $GH_ISSUE edit ${ISSUE_ID} -F ${6} --add-label "$Add_LABELS" --remove-label "$Rem_LABELS" fi) else (if [ "${ISSUE_OC}" = "CLOSED" ]; then echo "Reopening due to ${4} $ISSUE_INFO" $GH_ISSUE comment ${ISSUE_ID} -b "Regression in ${LINKS}" $GH_ISSUE reopen ${ISSUE_ID} $GH_ISSUE edit ${ISSUE_ID} -F ${6} --add-label "$Add_LABELS" --remove-label "$Rem_LABELS" elif [ -z "${ISSUE_ID}" ]; then #(gh api repos/logicmoo/logicmoo_workspace/labels -f name="${2}" -f color="fff000") #(gh api repos/logicmoo/logicmoo_workspace/labels -f name="${3}" -f color="ccc000") echo "Creating ${4} Issue $ISSUE_INFO" $GH_ISSUE create -l "unit_test,${1},${2},${3},Failing$Add_LABLES" -t "${5}" -F ${6} else echo "Editing Issue For ${4} $ISSUE_INFO" if echo "${ISSUE_INFO}" | grep -q "Passing"; then $GH_ISSUE comment ${ISSUE_ID} -b "Broken in ${LINKS}" $GH_ISSUE edit ${ISSUE_ID} -t "${5}" -F ${6} --remove-label "Passing$Rem_LABELS" --add-label "Failing,Regression$Add_LABELS" else $GH_ISSUE edit ${ISSUE_ID} -t "${5}" -F ${6} --remove-label "Passing$Rem_LABELS" --add-label "Failing$Add_LABELS" fi fi) fi } export foc_gh_issue foc_gh_issue ${1} ${2} ${3} ${4} "${5}" ${6}