mirror of
https://github.com/esphome/esphome.git
synced 2026-05-10 05:37:55 +08:00
62d0c25a2b
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run CodSpeed benchmarks (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Stale / stale (push) Has been cancelled
Lock closed issues and PRs / lock (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Publish Release / version-notifier (push) Has been cancelled
Synchronise Device Classes from Home Assistant / Sync Device Classes (push) Has been cancelled
97 lines
3.4 KiB
YAML
97 lines
3.4 KiB
YAML
name: PR Title Check
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, edited, synchronize, reopened]
|
|
branches-ignore:
|
|
- release
|
|
- beta
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
jobs:
|
|
check:
|
|
name: Validate PR title
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
script: |
|
|
const {
|
|
detectComponents,
|
|
hasCoreChanges,
|
|
hasDashboardChanges,
|
|
hasGitHubActionsChanges,
|
|
} = require('./.github/scripts/detect-tags.js');
|
|
|
|
const title = context.payload.pull_request.title;
|
|
const author = context.payload.pull_request.user.login;
|
|
|
|
// Skip bot PRs (e.g. dependabot) - they have their own title format
|
|
if (author === 'dependabot[bot]') {
|
|
return;
|
|
}
|
|
|
|
// Block titles starting with "word:" or "word(scope):" patterns
|
|
const commitStylePattern = /^\w+(\(.*?\))?[!]?\s*:/;
|
|
if (commitStylePattern.test(title)) {
|
|
core.setFailed(
|
|
`PR title should not start with a "prefix:" style format.\n` +
|
|
`Please use the format: [component] Brief description\n`
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Get changed files to detect tags
|
|
const files = await github.paginate(github.rest.pulls.listFiles, {
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number,
|
|
});
|
|
const filenames = files.map(f => f.filename);
|
|
|
|
// Detect tags from changed files using shared logic
|
|
const tags = new Set();
|
|
|
|
for (const comp of detectComponents(filenames)) {
|
|
tags.add(comp);
|
|
}
|
|
if (hasCoreChanges(filenames)) tags.add('core');
|
|
if (hasDashboardChanges(filenames)) tags.add('dashboard');
|
|
if (hasGitHubActionsChanges(filenames)) tags.add('ci');
|
|
|
|
if (tags.size === 0) {
|
|
return;
|
|
}
|
|
|
|
// Check for angle brackets not wrapped in backticks.
|
|
// Astro docs MDX treats bare < as JSX component opening tags.
|
|
const stripped = title.replace(/`[^`]*`/g, '');
|
|
if (/[<>]/.test(stripped)) {
|
|
core.setFailed(
|
|
'PR title contains `<` or `>` not wrapped in backticks.\n' +
|
|
'Astro docs MDX interprets bare `<` as JSX components.\n' +
|
|
'Please wrap angle brackets with backticks, e.g.: [component] Add `<feature>` support'
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Check title starts with [tag] prefix
|
|
const bracketPattern = /^\[\w+\]/;
|
|
if (!bracketPattern.test(title)) {
|
|
const suggestion = [...tags].map(c => `[${c}]`).join('');
|
|
// Skip if the suggested prefix would be too long for a readable title
|
|
if (suggestion.length > 40) {
|
|
return;
|
|
}
|
|
core.setFailed(
|
|
`PR modifies: ${[...tags].join(', ')}\n` +
|
|
`Title must start with a [tag] prefix.\n` +
|
|
`Suggested: ${suggestion} <description>`
|
|
);
|
|
}
|