Iand/updating recipe validation workflow (#4406)
This commit is contained in:
@@ -64,25 +64,25 @@ jobs:
|
|||||||
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
||||||
run: sudo apt-get update && sudo apt-get install -y jq
|
run: sudo apt-get update && sudo apt-get install -y jq
|
||||||
|
|
||||||
- name: Find changed recipe files in PR
|
- name: Find recipe files in PR (new or modified)
|
||||||
id: find_recipes
|
id: find_recipes
|
||||||
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
echo "Looking for changed recipe files in PR..."
|
echo "Looking for recipe files in PR (new or modified)..."
|
||||||
|
|
||||||
# Get the list of changed files in this PR
|
# Get the list of changed/new files in this PR
|
||||||
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then
|
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then
|
||||||
# For synchronize events, check files changed since the previous commit
|
# For synchronize events, check files changed since the previous commit
|
||||||
echo "📝 Synchronize event - checking files changed since previous commit"
|
echo "📝 Synchronize event - checking files changed/added since previous commit"
|
||||||
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }})
|
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }})
|
||||||
else
|
else
|
||||||
# For opened/reopened, check all files in the PR
|
# For opened/reopened, check all files in the PR (new and modified)
|
||||||
echo "📝 PR opened/reopened - checking all files in PR"
|
echo "📝 PR opened/reopened - checking all new/modified files in PR"
|
||||||
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD)
|
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Filter for recipe files only that were changed
|
# Filter for recipe files only that were changed or added
|
||||||
RECIPE_FILES=$(echo "$CHANGED_FILES" | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
RECIPE_FILES=$(echo "$CHANGED_FILES" | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
||||||
|
|
||||||
if [ -z "$RECIPE_FILES" ]; then
|
if [ -z "$RECIPE_FILES" ]; then
|
||||||
|
|||||||
@@ -43,43 +43,59 @@ jobs:
|
|||||||
keyring: false
|
keyring: false
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Check if recipe files changed in this PR
|
- name: Check if recipe files changed in this push
|
||||||
id: recipe_changes
|
id: recipe_changes
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
echo "🔍 Checking if recipe files were modified in this PR..."
|
echo "🔍 Checking if recipe files were modified in this push..."
|
||||||
|
|
||||||
# Get the list of changed files in this PR
|
# Get the list of changed files in this specific push
|
||||||
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}..HEAD)
|
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then
|
||||||
|
# For synchronize events, check files changed since the previous commit
|
||||||
|
echo "📝 Synchronize event - checking files changed since previous commit"
|
||||||
|
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }})
|
||||||
|
else
|
||||||
|
# For opened/reopened, check all files in the PR
|
||||||
|
echo "📝 PR opened/reopened - checking all files in PR"
|
||||||
|
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD)
|
||||||
|
fi
|
||||||
|
|
||||||
echo "All changed files in PR:"
|
echo "Changed files in this push:"
|
||||||
echo "$CHANGED_FILES"
|
echo "$CHANGED_FILES"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Check if any recipe files were changed
|
# Check if any recipe files were changed
|
||||||
if echo "$CHANGED_FILES" | grep -q "^documentation/src/pages/recipes/data/recipes/.*\.(yaml|yml)$"; then
|
if echo "$CHANGED_FILES" | grep -q "^documentation/src/pages/recipes/data/recipes/"; then
|
||||||
echo "recipe_files_changed=true" >> "$GITHUB_OUTPUT"
|
echo "recipe_files_changed=true" >> "$GITHUB_OUTPUT"
|
||||||
echo "✅ Recipe files were modified in this PR - proceeding with validation"
|
echo "✅ Recipe files were modified in this push - proceeding with validation"
|
||||||
else
|
else
|
||||||
echo "recipe_files_changed=false" >> "$GITHUB_OUTPUT"
|
echo "recipe_files_changed=false" >> "$GITHUB_OUTPUT"
|
||||||
echo "ℹ️ No recipe files were modified in this PR - skipping validation"
|
echo "ℹ️ No recipe files were modified in this push - skipping validation"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Find changed recipe files in PR
|
- name: Find recipe files in PR (new or modified)
|
||||||
id: find_changed_recipes
|
id: find_changed_recipes
|
||||||
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
if: steps.recipe_changes.outputs.recipe_files_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "🔍 Finding recipe files changed in this PR..."
|
set -e
|
||||||
|
echo "Looking for recipe files in PR (new or modified)..."
|
||||||
|
|
||||||
# Get the list of changed files in this PR
|
# Get the list of changed/new files in this PR
|
||||||
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}..HEAD)
|
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then
|
||||||
|
# For synchronize events, check files changed since the previous commit
|
||||||
|
echo "📝 Synchronize event - checking files changed/added since previous commit"
|
||||||
|
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }})
|
||||||
|
else
|
||||||
|
# For opened/reopened, check all files in the PR (new and modified)
|
||||||
|
echo "📝 PR opened/reopened - checking all new/modified files in PR"
|
||||||
|
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD)
|
||||||
|
fi
|
||||||
|
|
||||||
# Filter for recipe files only
|
# Filter for recipe files only that were changed or added
|
||||||
RECIPE_FILES=$(echo "$CHANGED_FILES" | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
RECIPE_FILES=$(echo "$CHANGED_FILES" | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
||||||
|
|
||||||
if [ -z "$RECIPE_FILES" ]; then
|
if [ -z "$RECIPE_FILES" ]; then
|
||||||
echo "❌ No recipe files found in the PR changes!"
|
echo "No changed recipe files found in PR"
|
||||||
echo "📁 Please add your recipe to: documentation/src/pages/recipes/data/recipes/"
|
|
||||||
echo "validation_status=no_files" >> $GITHUB_OUTPUT
|
echo "validation_status=no_files" >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -102,15 +118,16 @@ jobs:
|
|||||||
|
|
||||||
# First pass: Basic YAML validation
|
# First pass: Basic YAML validation
|
||||||
while IFS= read -r RECIPE_FILE; do
|
while IFS= read -r RECIPE_FILE; do
|
||||||
|
BASE_RECIPE_FILENAME=$(basename "$RECIPE_FILE"
|
||||||
if [ -f "$RECIPE_FILE" ]; then
|
if [ -f "$RECIPE_FILE" ]; then
|
||||||
echo "🔍 Validating: $RECIPE_FILE"
|
echo "🔍 Validating: $RECIPE_FILE"
|
||||||
if OUTPUT=$(goose recipe validate "$RECIPE_FILE" 2>&1); then
|
if OUTPUT=$(goose recipe validate "$RECIPE_FILE" 2>&1); then
|
||||||
echo "✅ Valid: $RECIPE_FILE"
|
echo "✅ Valid: $BASE_RECIPE_FILENAME"
|
||||||
VALIDATION_OUTPUT="${VALIDATION_OUTPUT}✅ $RECIPE_FILE: VALID\n"
|
VALIDATION_OUTPUT="${VALIDATION_OUTPUT}✅ $BASE_RECIPE_FILENAME: VALID\n"
|
||||||
else
|
else
|
||||||
echo "❌ Invalid: $RECIPE_FILE"
|
echo "❌ Invalid: $BASE_RECIPE_FILENAME"
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
VALIDATION_OUTPUT="${VALIDATION_OUTPUT}❌ $RECIPE_FILE: INVALID\n\`\`\`\n$OUTPUT\n\`\`\`\n"
|
VALIDATION_OUTPUT="${VALIDATION_OUTPUT}❌ $BASE_RECIPE_FILENAME: INVALID\n\`\`\`\n$OUTPUT\n\`\`\`\n"
|
||||||
ALL_VALID=false
|
ALL_VALID=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user