From f15a8e9f475eef4f8f93d3c92244e34730699c74 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:55:12 -0300 Subject: [PATCH] ci(component): Check if examples declared and folders match --- .github/workflows/build_component.yml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build_component.yml b/.github/workflows/build_component.yml index f69532d021d..ae63278f9da 100644 --- a/.github/workflows/build_component.yml +++ b/.github/workflows/build_component.yml @@ -62,6 +62,42 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - run: bash ./.github/scripts/check-cmakelists.sh + check-examples: + name: Check Examples Match + runs-on: ubuntu-latest + if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Check examples consistency + run: | + # Get list of folders in idf_component_examples (excluding hidden files) + actual_examples=$(find idf_component_examples -maxdepth 1 -type d ! -path idf_component_examples | sed 's|idf_component_examples/||' | sort) + + # Extract example paths from idf_component.yml + declared_examples=$(grep -A 100 "^examples:" idf_component.yml | grep "path:" | sed 's/.*path: *\.\/idf_component_examples\///' | sort) + + echo "=== Examples in idf_component_examples folder ===" + echo "$actual_examples" + echo "" + echo "=== Examples declared in idf_component.yml ===" + echo "$declared_examples" + echo "" + + # Compare the two lists + if [ "$actual_examples" != "$declared_examples" ]; then + echo "❌ ERROR: Examples mismatch detected!" + echo "" + echo "Examples in folder but NOT in idf_component.yml:" + comm -23 <(echo "$actual_examples") <(echo "$declared_examples") | sed 's/^/ - /' + echo "" + echo "Examples in idf_component.yml but NOT in folder:" + comm -13 <(echo "$actual_examples") <(echo "$declared_examples") | sed 's/^/ - /' + exit 1 + else + echo "✅ All examples match correctly!" + fi + set-matrix: name: Set Matrix runs-on: ubuntu-latest