Commit 72e5dc99 authored by clabby's avatar clabby

Update to use CI PAT token

parent 95cf06ba
......@@ -7,10 +7,10 @@ FAIL_INVALID_FMT=false
VERBOSE=false
# Github API access token (Optional - necessary for private repositories.)
GH_API_TOKEN=""
GH_API_TOKEN="${CI_TODO_CHECKER_PAT:-""}"
AUTH=""
if [[ $GH_API_TOKEN != "" ]]; then
AUTH="Authorization: token $TOKEN"
AUTH="Authorization: token $GH_API_TOKEN"
fi
# Default org and repo
......@@ -49,30 +49,12 @@ for arg in "$@"; do
esac
done
spinner() {
local pid=$1
local delay=0.05
local spinstr='|/-\'
echo -n "Loading TODOs... "
while [ "$(ps a | awk '{print $1}' | rg $pid)" ]; do
local temp=${spinstr#?}
printf " [${GREEN}%c${NC}] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
}
{
# Use ripgrep to search for the pattern in all files within the repo
todos=$(rg -o --with-filename -n -g '!ops/scripts/todo-checker.sh' 'TODO\(([^)]+)\): [^,;]*')
# Use ripgrep to search for the pattern in all files within the repo
todos=$(rg -o --with-filename -n -g '!ops/scripts/todo-checker.sh' 'TODO\(([^)]+)\): [^,;]*')
# Print a newline
echo ""
# Check each TODO comment in the repo
IFS=$'\n' # Set Internal Field Separator to newline for iteration
for todo in $todos; do
# Check each TODO comment in the repo
IFS=$'\n' # Set Internal Field Separator to newline for iteration
for todo in $todos; do
# Extract the text inside the parenthesis
FILE=$(echo $todo | awk -F':' '{print $1}')
LINE_NUM=$(echo $todo | awk -F':' '{print $2}')
......@@ -130,16 +112,16 @@ spinner() {
((OPEN_COUNT++))
TITLE=$(echo "$RESPONSE" | jq -r .title)
OPEN_ISSUES+=("$REPO_FULL/issues/$ISSUE_NUM|$TITLE|$FILE:$LINE_NUM")
done
done
# Print summary
if [[ $NOT_FOUND_COUNT -gt 0 ]]; then
# Print summary
if [[ $NOT_FOUND_COUNT -gt 0 ]]; then
echo -e "${YELLOW}[Warning]:${NC} ${CYAN}$NOT_FOUND_COUNT${NC} TODOs referred to issues that were not found."
fi
if [[ $MISMATCH_COUNT -gt 0 ]]; then
fi
if [[ $MISMATCH_COUNT -gt 0 ]]; then
echo -e "${YELLOW}[Warning]:${NC} ${CYAN}$MISMATCH_COUNT${NC} TODOs did not match the expected pattern. Run with ${RED}\`--verbose\`${NC} to show details."
fi
if [[ $OPEN_COUNT -gt 0 ]]; then
fi
if [[ $OPEN_COUNT -gt 0 ]]; then
echo -e "${GREEN}[Info]:${NC} ${CYAN}$OPEN_COUNT${NC} TODOs refer to issues that are still open."
echo -e "${GREEN}[Info]:${NC} Open issue details:"
printf "\n${PURPLE}%-50s${NC} ${GREY}|${NC} ${GREEN}%-55s${NC} ${GREY}|${NC} ${YELLOW}%-30s${NC}\n" "Repository & Issue" "Title" "Location"
......@@ -163,14 +145,6 @@ spinner() {
printf "${CYAN}%-50s${NC} ${GREY}|${NC} %-55s ${GREY}|${NC} ${YELLOW}%-30s${NC}\n" "$REPO_ISSUE" "$TITLE" "$LOC"
done
fi
} &
# Save the Process ID of the job you started in the background
PID=$!
# Start the spinner with the background job's Process ID
spinner $PID
fi
# Wait for the background job to finish
wait $PID
echo -e "${GREEN}[Info]:${NC} Done checking issues."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment