Improve regex and add waveshare_epaper deprecation for testing

Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-26 00:59:35 +00:00
parent 71390c075e
commit b8ac92c537
3 changed files with 28 additions and 5 deletions
+10 -5
View File
@@ -389,10 +389,11 @@ jobs:
const labels = new Set(); const labels = new Set();
const deprecatedInfo = []; const deprecatedInfo = [];
// Compile regex once for better performance
const componentFileRegex = /^esphome\/components\/([^\/]+)\/.+\.py$/;
// Get files that are modified or added in components directory // Get files that are modified or added in components directory
const componentFiles = changedFiles.filter(file => const componentFiles = changedFiles.filter(file => componentFileRegex.test(file));
file.match(/^esphome\/components\/([^\/]+)\/.+\.py$/)
);
if (componentFiles.length === 0) { if (componentFiles.length === 0) {
return { labels, deprecatedInfo }; return { labels, deprecatedInfo };
@@ -400,8 +401,9 @@ jobs:
// Extract unique component names // Extract unique component names
const components = new Set(); const components = new Set();
const componentMatchRegex = /^esphome\/components\/([^\/]+)\//;
for (const file of componentFiles) { for (const file of componentFiles) {
const match = file.match(/^esphome\/components\/([^\/]+)\//); const match = file.match(componentMatchRegex);
if (match) { if (match) {
components.add(match[1]); components.add(match[1]);
} }
@@ -414,7 +416,10 @@ jobs:
const content = fs.readFileSync(initFile, 'utf8'); const content = fs.readFileSync(initFile, 'utf8');
// Look for DEPRECATED_COMPONENT = "message" or DEPRECATED_COMPONENT = 'message' // 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) { if (deprecatedMatch) {
labels.add('deprecated_component'); labels.add('deprecated_component');
@@ -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.
@@ -1 +1,2 @@
CODEOWNERS = ["@clydebarrow"] 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"