add filtering to the workflows

This commit is contained in:
Gregory Gauthier 2026-02-06 16:09:17 +00:00
parent 2be324f75e
commit 59af636961
2 changed files with 9 additions and 7 deletions

View File

@ -26,7 +26,7 @@ jobs:
nc -h nc -h
echo "=== Debug: Setup complete ===" echo "=== Debug: Setup complete ==="
- name: Find deleted source files - name: Find deleted source files (deleted only)
id: deleted id: deleted
run: | run: |
echo "=== Debug: Starting deletion detection ===" echo "=== Debug: Starting deletion detection ==="
@ -35,6 +35,7 @@ jobs:
# Check if we have a parent commit # Check if we have a parent commit
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
echo "Parent commit exists; checking for deletions." echo "Parent commit exists; checking for deletions."
# Use --diff-filter=D to only get Deleted files (exclude Added/Modified)
DELETED_FILES=$(git diff --name-only --diff-filter=D HEAD~1 2>/dev/null | grep -E '\.(c|bas)$') DELETED_FILES=$(git diff --name-only --diff-filter=D HEAD~1 2>/dev/null | grep -E '\.(c|bas)$')
echo "Deleted files from last commit: '${DELETED_FILES}'" echo "Deleted files from last commit: '${DELETED_FILES}'"
else else

View File

@ -31,7 +31,7 @@ jobs:
nc -h nc -h
echo "=== Debug: Setup complete ===" echo "=== Debug: Setup complete ==="
- name: Find changed source files - name: Find changed source files (added/modified only)
id: files id: files
run: | run: |
echo "=== Debug: Starting file detection ===" echo "=== Debug: Starting file detection ==="
@ -39,9 +39,10 @@ jobs:
echo "Files in repo: $(ls -la)" echo "Files in repo: $(ls -la)"
echo "=== Debug: Checking for parent commit ===" echo "=== Debug: Checking for parent commit ==="
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
echo "Parent commit exists; running git diff." echo "Parent commit exists; running git diff for added/modified files only."
CHANGED_FILES=$(git diff --name-only HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' | head -1) # Use --diff-filter=AM to only get Added and Modified files (exclude Deleted)
echo "Changed files from last commit: '${CHANGED_FILES}'" CHANGED_FILES=$(git diff --name-only --diff-filter=AM HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' | head -1)
echo "Added/Modified files from last commit: '${CHANGED_FILES}'"
else else
echo "No parent commit; skipping diff." echo "No parent commit; skipping diff."
CHANGED_FILES="" CHANGED_FILES=""
@ -50,7 +51,7 @@ jobs:
# Fallback to all .c/.bas files if no changes or no previous commit # Fallback to all .c/.bas files if no changes or no previous commit
if [ -z "$CHANGED_FILES" ]; then if [ -z "$CHANGED_FILES" ]; then
echo "=== Debug: No changes found; running fallback find ===" echo "=== Debug: No added/modified files found; running fallback find ==="
# Find newest .c/.bas by modification time (sort -nr on %T@ timestamp) # Find newest .c/.bas by modification time (sort -nr on %T@ timestamp)
CHANGED_FILES=$(find . -type f \( -name "*.c" -o -name "*.bas" \) -printf '%T@ %p\n' 2>/dev/null | sort -nr | cut -d' ' -f2- | head -1) CHANGED_FILES=$(find . -type f \( -name "*.c" -o -name "*.bas" \) -printf '%T@ %p\n' 2>/dev/null | sort -nr | cut -d' ' -f2- | head -1)
echo "Fallback files (newest first): '${CHANGED_FILES}'" echo "Fallback files (newest first): '${CHANGED_FILES}'"
@ -58,7 +59,7 @@ jobs:
fi fi
if [ -z "$CHANGED_FILES" ]; then if [ -z "$CHANGED_FILES" ]; then
echo "No C/BAS files found; skipping workflow." echo "No added/modified C/BAS files found; skipping workflow."
exit 0 # Graceful skip, no failure exit 0 # Graceful skip, no failure
fi fi