Commit 72e5dc99 authored by clabby's avatar clabby

Update to use CI PAT token

parent 95cf06ba
...@@ -7,10 +7,10 @@ FAIL_INVALID_FMT=false ...@@ -7,10 +7,10 @@ FAIL_INVALID_FMT=false
VERBOSE=false VERBOSE=false
# Github API access token (Optional - necessary for private repositories.) # Github API access token (Optional - necessary for private repositories.)
GH_API_TOKEN="" GH_API_TOKEN="${CI_TODO_CHECKER_PAT:-""}"
AUTH="" AUTH=""
if [[ $GH_API_TOKEN != "" ]]; then if [[ $GH_API_TOKEN != "" ]]; then
AUTH="Authorization: token $TOKEN" AUTH="Authorization: token $GH_API_TOKEN"
fi fi
# Default org and repo # Default org and repo
...@@ -49,30 +49,12 @@ for arg in "$@"; do ...@@ -49,30 +49,12 @@ for arg in "$@"; do
esac esac
done done
spinner() { # Use ripgrep to search for the pattern in all files within the repo
local pid=$1 todos=$(rg -o --with-filename -n -g '!ops/scripts/todo-checker.sh' 'TODO\(([^)]+)\): [^,;]*')
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\(([^)]+)\): [^,;]*')
# Print a newline # Check each TODO comment in the repo
echo "" 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 # Extract the text inside the parenthesis
FILE=$(echo $todo | awk -F':' '{print $1}') FILE=$(echo $todo | awk -F':' '{print $1}')
LINE_NUM=$(echo $todo | awk -F':' '{print $2}') LINE_NUM=$(echo $todo | awk -F':' '{print $2}')
...@@ -130,16 +112,16 @@ spinner() { ...@@ -130,16 +112,16 @@ spinner() {
((OPEN_COUNT++)) ((OPEN_COUNT++))
TITLE=$(echo "$RESPONSE" | jq -r .title) TITLE=$(echo "$RESPONSE" | jq -r .title)
OPEN_ISSUES+=("$REPO_FULL/issues/$ISSUE_NUM|$TITLE|$FILE:$LINE_NUM") OPEN_ISSUES+=("$REPO_FULL/issues/$ISSUE_NUM|$TITLE|$FILE:$LINE_NUM")
done done
# Print summary # Print summary
if [[ $NOT_FOUND_COUNT -gt 0 ]]; then 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." echo -e "${YELLOW}[Warning]:${NC} ${CYAN}$NOT_FOUND_COUNT${NC} TODOs referred to issues that were not found."
fi fi
if [[ $MISMATCH_COUNT -gt 0 ]]; then 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." 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 fi
if [[ $OPEN_COUNT -gt 0 ]]; then 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} ${CYAN}$OPEN_COUNT${NC} TODOs refer to issues that are still open."
echo -e "${GREEN}[Info]:${NC} Open issue details:" 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" 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() { ...@@ -163,14 +145,6 @@ spinner() {
printf "${CYAN}%-50s${NC} ${GREY}|${NC} %-55s ${GREY}|${NC} ${YELLOW}%-30s${NC}\n" "$REPO_ISSUE" "$TITLE" "$LOC" printf "${CYAN}%-50s${NC} ${GREY}|${NC} %-55s ${GREY}|${NC} ${YELLOW}%-30s${NC}\n" "$REPO_ISSUE" "$TITLE" "$LOC"
done done
fi 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
# Wait for the background job to finish echo -e "${GREEN}[Info]:${NC} Done checking issues."
wait $PID
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