10000 Add CI to only use markdown extension for integrations by silamon · Pull Request #39283 · home-assistant/home-assistant.io · GitHub
[go: up one dir, main page]

Skip to content

Add CI to only use markdown extension for integrations #39283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ jobs:
with:
node-version: 20
cache: "npm"
- name: Check for .md files and suggest renaming
run: |
echo "Checking for .md files in source/_integrations..."
MD_FILES=$(find source/_integrations -type f -name "*.md")
if [ -n "$MD_FILES" ]; then
echo "Found the following .md files:"
echo "$MD_FILES"
echo "⚠️ Please rename these files from .md to .markdown"
exit 1
fi
Comment on lines +17 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle missing source/_integrations directory to avoid false failures

If the source/_integrations folder doesn’t exist, the find command will error out and cause the step to fail even when there are no .md files. Guard against a missing directory or redirect find’s stderr so the workflow only fails when unwanted .md files are truly present.

Proposed diff:

-  MD_FILES=$(find source/_integrations -type f -name "*.md")
+  if [ -d "source/_integrations" ]; then
+    MD_FILES=$(find source/_integrations -type f -name "*.md" 2>/dev/null)
+  else
+    MD_FILES=""
+  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check for .md files and suggest renaming
run: |
echo "Checking for .md files in source/_integrations..."
MD_FILES=$(find source/_integrations -type f -name "*.md")
if [ -n "$MD_FILES" ]; then
echo "Found the following .md files:"
echo "$MD_FILES"
echo "⚠️ Please rename these files from .md to .markdown"
exit 1
fi
- name: Check for .md files and suggest renaming
run: |
echo "Checking for .md files in source/_integrations..."
if [ -d "source/_integrations" ]; then
MD_FILES=$(find source/_integrations -type f -name "*.md" 2>/dev/null)
else
MD_FILES=""
fi
if [ -n "$MD_FILES" ]; then
echo "Found the following .md files:"
echo "$MD_FILES"
echo "⚠️ Please rename these files from .md to .markdown"
exit 1
fi
🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 17 to 26, the script fails if the
source/_integrations directory is missing because the find command errors out.
Modify the script to first check if the directory exists before running find, or
redirect find's stderr to /dev/null to suppress errors. This ensures the step
only fails when .md files are actually found, preventing false failures due to a
missing directory.

Comment on lines +17 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Guard against missing source/_integrations directory to prevent CI failures
If the source/_integrations directory doesn’t exist yet, find will error out under set -e and abort the job prematurely. Wrap the lookup in a directory check or suppress find errors so CI only fails when .md files are present—not when the path is absent.

       - name: Check for .md files and suggest renaming
         run: |
-          echo "Checking for .md files in source/_integrations..."
-          MD_FILES=$(find source/_integrations -type f -name "*.md")
+          echo "Checking for .md files in source/_integrations..."
+          if [ -d source/_integrations ]; then
+            MD_FILES=$(find source/_integrations -type f -name "*.md" 2>/dev/null)
+          else
+            MD_FILES=""
+          fi
           if [ -n "$MD_FILES" ]; then
             echo "Found the following .md files:"
             echo "$MD_FILES"

Alternatively, to quickly suppress errors:

-          MD_FILES=$(find source/_integrations -type f -name "*.md")
+          MD_FILES=$(find source/_integrations -type f -name "*.md" 2>/dev/null || true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check for .md files and suggest renaming
run: |
echo "Checking for .md files in source/_integrations..."
MD_FILES=$(find source/_integrations -type f -name "*.md")
if [ -n "$MD_FILES" ]; then
echo "Found the following .md files:"
echo "$MD_FILES"
echo "⚠️ Please rename these files from .md to .markdown"
exit 1
fi
- name: Check for .md files and suggest renaming
run: |
echo "Checking for .md files in source/_integrations..."
if [ -d source/_integrations ]; then
MD_FILES=$(find source/_integrations -type f -name "*.md" 2>/dev/null)
else
MD_FILES=""
fi
if [ -n "$MD_FILES" ]; then
echo "Found the following .md files:"
echo "$MD_FILES"
echo "⚠️ Please rename these files from .md to .markdown"
exit 1
fi
🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 17 to 26, the script uses `find` on
the source/_integrations directory without checking if it exists, causing CI
failures if the directory is missing. Modify the script to first check if the
source/_integrations directory exists before running `find`, or suppress errors
from `find` so the job only fails when .md files are found, not when the
directory is absent.

- name: Install dependencies
run: npm install
env:
Expand Down
0