mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 08:41:59 +00:00
Improve regex and add waveshare_epaper deprecation for testing
Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
15
.github/workflows/auto-label-pr.yml
vendored
15
.github/workflows/auto-label-pr.yml
vendored
@@ -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');
|
||||
|
||||
17
esphome/components/test_deprecated_example/README.md
Normal file
17
esphome/components/test_deprecated_example/README.md
Normal file
@@ -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"]
|
||||
DEPRECATED_COMPONENT = "The waveshare_epaper component is deprecated and no new models will be added. For new epaper displays use the epaper_spi component"
|
||||
|
||||
Reference in New Issue
Block a user