Skip to content

Commit

Permalink
#1: try different logic for finding workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Jan 6, 2025
1 parent e85bf50 commit a55151e
Showing 1 changed file with 57 additions and 14 deletions.
71 changes: 57 additions & 14 deletions ci/check_repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,67 @@ TSSTART=$(date +%s)
echo "$ORG/$REPOSITORY > Cloning repository...";
git clone https://github.com/$ORG/$REPOSITORY $WORKING_DIR/$REPOSITORY >/dev/null 2>&1

# Ckeck workflows (files exist as expected and contain correct workflow)
for w in "${EXPECTED_WORKFLOWS[@]}"
do
WORKFLOW_FILE="$WORKING_DIR/$REPOSITORY/.github/workflows/$w.yml"
if [ ! -f "$WORKFLOW_FILE" ]; then
echo "[error] Missing workflow file '$w.yml' at $WORKFLOW_FILE"
((N_ERRORS++))
else
# Check that the correct workflow is used
if ! grep -q "uses: DARMA-tasking/$w" "$WORKFLOW_FILE"; then
echo "[error] Workflow file '$w.yml' does not contain 'uses: DARMA-tasking/$w'"
((N_ERRORS++))
else
echo "[ok] workflow file '$w.yml is correct"
# Directory containing workflow files
WORKFLOWS_DIR="$WORKING_DIR/$REPOSITORY/.github/workflows"
FOUND_WORKFLOWS=()

# Check workflows
if [ ! -d "$WORKFLOWS_DIR" ]; then
echo "[error] Workflow directory '$WORKFLOWS_DIR' does not exist."
exit 1
fi

for file in "$WORKFLOWS_DIR"/*.yml; do
if [ ! -f "$file" ]; then
continue
fi
for w in "${EXPECTED_WORKFLOWS[@]}"; do
if grep -q "uses: DARMA-tasking/$w" "$file"; then
if [[ ! " ${FOUND_WORKFLOWS[@]} " =~ " $w " ]]; then
FOUND_WORKFLOWS+=("$w")
echo "[ok] Found workflow '$w' in file '$file'"
fi
fi
done
# Exit if all workflows are found
if [ ${#FOUND_WORKFLOWS[@]} -eq ${#EXPECTED_WORKFLOWS[@]} ]; then
echo "[ok] All expected workflows found."
break
fi
done

# Ensure all workflows were found
if [ ${#FOUND_WORKFLOWS[@]} -ne ${#EXPECTED_WORKFLOWS[@]} ]; then
echo "[error] Missing workflows:"
for w in "${EXPECTED_WORKFLOWS[@]}"; do
if [[ ! " ${FOUND_WORKFLOWS[@]} " =~ " $w " ]]; then
echo " - $w"
((N_ERRORS++))
fi
done
else
echo "[ok] All expected workflows are present."
fi


# Check workflows (files exist as expected and contain correct workflow)
# for w in "${EXPECTED_WORKFLOWS[@]}"
# do
# WORKFLOW_FILE="$WORKING_DIR/$REPOSITORY/.github/workflows/$w.yml"
# if [ ! -f "$WORKFLOW_FILE" ]; then
# echo "[error] Missing workflow file '$w.yml' at $WORKFLOW_FILE"
# ((N_ERRORS++))
# else
# # Check that the correct workflow is used
# if ! grep -q "uses: DARMA-tasking/$w" "$WORKFLOW_FILE"; then
# echo "[error] Workflow file '$w.yml' does not contain 'uses: DARMA-tasking/$w'"
# ((N_ERRORS++))
# else
# echo "[ok] workflow file '$w.yml' is correct"
# fi
# fi
# done

# Finalize
TSEND=$(date +%s)
TSDURATION=$(( $TSEND - $TSSTART ))
Expand Down

0 comments on commit a55151e

Please sign in to comment.