From b8ac92c537daa1b536358048650bdc8e5c5b2938 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 00:59:35 +0000 Subject: [PATCH] Improve regex and add waveshare_epaper deprecation for testing Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- .github/workflows/auto-label-pr.yml | 15 ++++++++++----- .../test_deprecated_example/README.md | 17 +++++++++++++++++ esphome/components/waveshare_epaper/__init__.py | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 esphome/components/test_deprecated_example/README.md diff --git a/.github/workflows/auto-label-pr.yml b/.github/workflows/auto-label-pr.yml index 241b64f55a..e5f42b0824 100644 --- a/.github/workflows/auto-label-pr.yml +++ b/.github/workflows/auto-label-pr.yml @@ -389,10 +389,11 @@ jobs: const labels = new Set(); const deprecatedInfo = []; + // Compile regex once for better performance + const componentFileRegex = /^esphome\/components\/([^\/]+)\/.+\.py$/; + // Get files that are modified or added in components directory - const componentFiles = changedFiles.filter(file => - file.match(/^esphome\/components\/([^\/]+)\/.+\.py$/) - ); + const componentFiles = changedFiles.filter(file => componentFileRegex.test(file)); if (componentFiles.length === 0) { return { labels, deprecatedInfo }; @@ -400,8 +401,9 @@ jobs: // Extract unique component names const components = new Set(); + const componentMatchRegex = /^esphome\/components\/([^\/]+)\//; for (const file of componentFiles) { - const match = file.match(/^esphome\/components\/([^\/]+)\//); + const match = file.match(componentMatchRegex); if (match) { components.add(match[1]); } @@ -414,7 +416,10 @@ jobs: const content = fs.readFileSync(initFile, 'utf8'); // Look for DEPRECATED_COMPONENT = "message" or DEPRECATED_COMPONENT = 'message' - const deprecatedMatch = content.match(/DEPRECATED_COMPONENT\s*=\s*["'](.+?)["']/s); + // Support both single and double quotes, and handle escaped quotes + const doubleQuoteMatch = content.match(/DEPRECATED_COMPONENT\s*=\s*"((?:[^"\\]|\\.)*)"/); + const singleQuoteMatch = content.match(/DEPRECATED_COMPONENT\s*=\s*'((?:[^'\\]|\\.)*)'/); + const deprecatedMatch = doubleQuoteMatch || singleQuoteMatch; if (deprecatedMatch) { labels.add('deprecated_component'); diff --git a/esphome/components/test_deprecated_example/README.md b/esphome/components/test_deprecated_example/README.md new file mode 100644 index 0000000000..3f5d266192 --- /dev/null +++ b/esphome/components/test_deprecated_example/README.md @@ -0,0 +1,17 @@ +# Test Deprecated Component + +This is a test component to validate the `deprecated_component` label functionality in the auto-label workflow. + +## Purpose + +This component demonstrates how the `DEPRECATED_COMPONENT` constant should be used: + +1. The component is still functional and usable +2. It's deprecated and not actively maintained +3. Users should migrate to an alternative when possible + +## Usage + +This is different from components that use `cv.invalid()`, which are completely unusable. + +Components with `DEPRECATED_COMPONENT` are still functional but discouraged for new projects. diff --git a/esphome/components/waveshare_epaper/__init__.py b/esphome/components/waveshare_epaper/__init__.py index c58ce8a01e..8bf5ca542f 100644 --- a/esphome/components/waveshare_epaper/__init__.py +++ b/esphome/components/waveshare_epaper/__init__.py @@ -1 +1,2 @@ CODEOWNERS = ["@clydebarrow"] +DEPRECATED_COMPONENT = "The waveshare_epaper component is deprecated and no new models will be added. For new epaper displays use the epaper_spi component"