mirror of
https://github.com/esphome/esphome.git
synced 2026-11-18 19:15:59 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0faeb52441 | ||
|
|
930cef71d2 |
No files matched your search
@@ -128,51 +128,6 @@ helper; `AGENTS.md` section 4 and the `component-codegen` skill have the detail.
|
||||
| action or condition class that only forwards to the parent | `register_apply_action` / `register_apply_condition` |
|
||||
| enum-to-string `switch` returning literals | `PROGMEM_STRING_TABLE` with `get_log_str` / `get_progmem_str` |
|
||||
| `if (x := config.get(CONF_X)) is not None: cg.add(var.set_x(x))` | `cg.add_optional(var.set_x, config.get(CONF_X))`, when the setter takes the value unchanged |
|
||||
| `x = (x & ~mask) \| (on ? mask : 0)` or a bit-reversal loop | `assign_bits(x, mask, on)`, `reverse_bits(x)` (`esphome/core/helpers.h`) |
|
||||
| `x < lo ? lo : (x > hi ? hi : x)` | `std::clamp(x, lo, hi)` |
|
||||
| I2C read, mask, write by hand; private 16-bit register byte helpers | `update_register`, `update_register16`, `read_byte_reg16`, `write_byte_reg16` |
|
||||
| custom validator that checks which keys are set, or one schema with model checks | `cv.has_exactly_one_key`, `cv.has_at_most_one_key`, `cv.Inclusive`/`cv.Exclusive`, `cv.typed_schema` per model |
|
||||
|
||||
|
||||
## Cleanups automated reviews keep missing
|
||||
|
||||
Multi-pass cleanup reviews of contributor PRs find these again and again, and single-pass reviews
|
||||
almost never flag them. Look for each one explicitly; the matching `AGENTS.md` section 4 entry has the
|
||||
detail.
|
||||
|
||||
- **Copies within the PR** (the most common finding): two functions, branches, platform files or tests
|
||||
that differ in a constant or two. Ask for one helper, loop or table.
|
||||
- **State that copies other state:** a `write_pending_` bool beside a timer (use the return value of
|
||||
`cancel_timeout(ID)`), a `has_x_` bool beside `x_` (use `NAN` or a sentinel), an enum that can be worked
|
||||
out from stored fields.
|
||||
- **Dead guards:** null checks on members codegen always sets, `is_failed()` checks in `loop()`, range
|
||||
checks the schema already enforces, `default:` in a `switch` over every value of an `enum class` the
|
||||
component sets itself (not one cast from bus data), calls that set a member to its default
|
||||
(`set_cs_pin(nullptr)`).
|
||||
- **Member layout:** field order that leaves padding, `int`/`uint32_t` for values that fit a `uint8_t`,
|
||||
an `enum class` without `: uint8_t`, several `bool` members that could share a byte. Each costs RAM per
|
||||
instance.
|
||||
- **C++ work that belongs in codegen:** scaling, clamping, checksums or register bytes computed at boot
|
||||
from config values; ask for the plain value from `to_code`.
|
||||
- **Two `switch` ladders for one mapping:** encode and decode of the same value pairs should share one
|
||||
`static constexpr` table (`PROGMEM` on ESP8266).
|
||||
- **Compile-time constants:** `static const` or `#define` with a constant value (use `static constexpr`),
|
||||
constant tables not in `PROGMEM`, unused constants.
|
||||
- **Code for one model or feature compiled into every build:** ask for a `cg.add_define()` emitted only
|
||||
when the config uses it, with the runtime check inside the `#ifdef`.
|
||||
- **Failure handling:** `mark_failed()` outside `setup()` (runtime failures set a warning that the next
|
||||
success clears), an error enum that only picks a log message.
|
||||
- **Logging** that does not follow https://developers.esphome.io/architecture/logging/: `ESP_LOGD` on every
|
||||
reading, "Setting up" or "initialized" lines in `setup()`, a `dump_config()` made of single-line
|
||||
`ESP_LOGCONFIG` calls where related lines fit one call, a name helper that returns `const char *` instead
|
||||
of `const LogString *`.
|
||||
- **Leaf classes** that are not `final`.
|
||||
- **Unused helpers, includes and imports** left behind; lint does not catch most of them.
|
||||
- **Comments that restate the code** or tell its history: a block comment that walks through the next
|
||||
ten lines, a docstring that repeats the signature, a derivation that a one-line note plus a datasheet
|
||||
section would cover.
|
||||
- **Tests:** near-identical test functions that differ only in inputs (ask for `pytest.mark.parametrize`
|
||||
or a table-driven gtest), tests that repeat another test, test YAML that sets options to their defaults.
|
||||
|
||||
## Python conventions
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
// Requests a Copilot code review on a pull request. A failed request only
|
||||
// warns: Copilot review is advisory and must never block the PR.
|
||||
//
|
||||
// GitHub answers a request it will not act on (one made by an identity without
|
||||
// a Copilot seat, which includes GITHUB_TOKEN and GitHub Apps when the PR
|
||||
// author has no Copilot access) with a success and no review, so the timeline
|
||||
// is read back to confirm the request was recorded.
|
||||
|
||||
const COPILOT_REVIEWER = "copilot-pull-request-reviewer[bot]";
|
||||
// The timeline names the reviewer by its display login; the reviews API uses
|
||||
// the bot account.
|
||||
const COPILOT_LOGINS = new Set(["Copilot", COPILOT_REVIEWER]);
|
||||
|
||||
module.exports = async ({ github, context, core }) => {
|
||||
const pull = context.payload.pull_request;
|
||||
if (pull.user?.type === "Bot") {
|
||||
core.info(`#${pull.number} was opened by a bot; skipping the Copilot review.`);
|
||||
return;
|
||||
}
|
||||
await requestCopilotReview({ github, core, ...context.repo, prNumber: pull.number });
|
||||
};
|
||||
|
||||
async function requestCopilotReview({ github, core, owner, repo, prNumber }) {
|
||||
const readTimeline = () =>
|
||||
github.paginate(github.rest.issues.listEventsForTimeline, {
|
||||
owner,
|
||||
repo,
|
||||
issue_number: prNumber,
|
||||
per_page: 100,
|
||||
});
|
||||
const { login: requester, stop } = await identify({ github, core });
|
||||
if (stop) return;
|
||||
let before = null;
|
||||
if (requester) {
|
||||
try {
|
||||
before = await readTimeline();
|
||||
} catch (err) {
|
||||
core.warning(
|
||||
`Could not read the timeline of #${prNumber}, so the request goes unconfirmed: ${err.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
try {
|
||||
await github.rest.pulls.requestReviewers({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: prNumber,
|
||||
reviewers: [COPILOT_REVIEWER],
|
||||
});
|
||||
} catch (err) {
|
||||
core.warning(`Could not request a Copilot review on #${prNumber}: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
if (!before) return;
|
||||
let events;
|
||||
try {
|
||||
events = await readTimeline();
|
||||
} catch (err) {
|
||||
core.warning(
|
||||
`Requested a Copilot review on #${prNumber} but could not confirm it: ${err.message}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const seen = new Set(before.map((event) => event.id));
|
||||
const copilotRequests = events.filter(
|
||||
(event) =>
|
||||
event.event === "review_requested" &&
|
||||
COPILOT_LOGINS.has(event.requested_reviewer?.login)
|
||||
);
|
||||
// Ours is a request this token's account filed that was not there before.
|
||||
if (
|
||||
copilotRequests.some(
|
||||
(event) => event.actor?.login === requester && !seen.has(event.id)
|
||||
)
|
||||
) {
|
||||
core.info(`Requested a Copilot review on #${prNumber}.`);
|
||||
return;
|
||||
}
|
||||
// The latest request or removal decides whether a review is still queued.
|
||||
const last = events
|
||||
.filter(
|
||||
(event) =>
|
||||
(event.event === "review_requested" ||
|
||||
event.event === "review_request_removed") &&
|
||||
COPILOT_LOGINS.has(event.requested_reviewer?.login)
|
||||
)
|
||||
.at(-1);
|
||||
if (last?.event === "review_requested" && !reviewedSince(events, last.created_at)) {
|
||||
core.info(
|
||||
`A Copilot review requested by ${last.actor?.login} is still pending on #${prNumber}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
core.warning(
|
||||
`GitHub accepted the Copilot review request on #${prNumber} but recorded none; ` +
|
||||
`${requester} likely has no Copilot seat.`
|
||||
);
|
||||
}
|
||||
|
||||
// The account the token belongs to: { login }, {} when it can't be told
|
||||
// (the request goes ahead unconfirmed), or { stop: true } when the token is rejected.
|
||||
async function identify({ github, core }) {
|
||||
try {
|
||||
const { data } = await github.rest.users.getAuthenticated();
|
||||
return { login: data.login };
|
||||
} catch (err) {
|
||||
// An expired or revoked token fails loudly so someone rotates it.
|
||||
if (err.status === 401) {
|
||||
core.setFailed(
|
||||
`COPILOT_REVIEW_TOKEN was rejected (${err.message}); rotate esphome-review-bot's token.`
|
||||
);
|
||||
return { stop: true };
|
||||
}
|
||||
core.warning(
|
||||
`Could not identify the requesting account, so the request goes unconfirmed: ${err.message}`
|
||||
);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function reviewedSince(events, since) {
|
||||
return events.some(
|
||||
(event) =>
|
||||
event.event === "reviewed" &&
|
||||
COPILOT_LOGINS.has(event.user?.login) &&
|
||||
Date.parse(event.submitted_at) >= Date.parse(since)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "request-copilot-review",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "node --test tests/*.test.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const requestCopilotReview = require('../index');
|
||||
|
||||
const REPO = { owner: 'esphome', repo: 'esphome' };
|
||||
|
||||
const OLD = '2020-01-01T00:00:00Z';
|
||||
const LATER = '2020-01-01T00:05:00Z';
|
||||
// The account the workflow's token belongs to.
|
||||
const REQUESTER = 'esphome-review-bot';
|
||||
// "ours" is a request filed by REQUESTER; anything else stands for the ruleset or a maintainer.
|
||||
const copilotRequest = (id, by, createdAt = LATER) => ({
|
||||
id,
|
||||
event: 'review_requested',
|
||||
actor: { login: by === 'ours' ? REQUESTER : 'someone', type: 'User' },
|
||||
requested_reviewer: { login: 'Copilot' },
|
||||
created_at: createdAt,
|
||||
});
|
||||
const copilotReview = (id, submittedAt, login = 'Copilot') => ({
|
||||
id,
|
||||
event: 'reviewed',
|
||||
user: { login },
|
||||
submitted_at: submittedAt,
|
||||
});
|
||||
const copilotRemoval = (id) => ({
|
||||
id,
|
||||
event: 'review_request_removed',
|
||||
requested_reviewer: { login: 'Copilot' },
|
||||
created_at: LATER,
|
||||
});
|
||||
|
||||
// `before` and `after` are the timeline reads around the request, `timeline` sets both, and
|
||||
// `timelineError` makes that read throw.
|
||||
function makeGithub(opts = {}) {
|
||||
const calls = [];
|
||||
const reads = [
|
||||
{ name: 'before', events: opts.timeline ?? opts.before ?? [] },
|
||||
{ name: 'after', events: opts.timeline ?? opts.after ?? [copilotRequest(1, 'ours')] },
|
||||
];
|
||||
const listEventsForTimeline = () => {};
|
||||
return {
|
||||
calls,
|
||||
github: {
|
||||
paginate: async (fn) => {
|
||||
assert.equal(fn, listEventsForTimeline);
|
||||
const read = reads.shift();
|
||||
assert.ok(read, 'the timeline is read at most twice');
|
||||
if (opts.timelineError === read.name) throw new Error('secondary rate limit');
|
||||
return read.events;
|
||||
},
|
||||
rest: {
|
||||
users: {
|
||||
getAuthenticated: async () => {
|
||||
if (opts.whoamiStatus) {
|
||||
throw Object.assign(new Error('Bad credentials'), { status: opts.whoamiStatus });
|
||||
}
|
||||
return { data: { login: REQUESTER } };
|
||||
},
|
||||
},
|
||||
issues: { listEventsForTimeline },
|
||||
pulls: {
|
||||
requestReviewers: async (args) => {
|
||||
if (opts.fail) throw new Error('Reviews may only be requested from collaborators');
|
||||
calls.push(args);
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function makeCore() {
|
||||
const warnings = [];
|
||||
const infos = [];
|
||||
const failures = [];
|
||||
return {
|
||||
warnings,
|
||||
infos,
|
||||
failures,
|
||||
core: {
|
||||
info: (m) => void infos.push(m),
|
||||
warning: (m) => void warnings.push(m),
|
||||
setFailed: (m) => void failures.push(m),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function run(githubOpts, type = 'User') {
|
||||
const { github, calls } = makeGithub(githubOpts);
|
||||
const { core, infos, warnings, failures } = makeCore();
|
||||
const context = { repo: REPO, payload: { pull_request: { number: 9, user: { type } } } };
|
||||
await requestCopilotReview({ github, context, core });
|
||||
return { calls, infos, warnings, failures };
|
||||
}
|
||||
|
||||
test('a PR event requests a Copilot review', async () => {
|
||||
const { calls, infos, warnings } = await run();
|
||||
assert.deepEqual(calls, [{ ...REPO, pull_number: 9, reviewers: ['copilot-pull-request-reviewer[bot]'] }]);
|
||||
assert.deepEqual(warnings, []);
|
||||
assert.match(infos[0], /Requested a Copilot review on #9/);
|
||||
});
|
||||
|
||||
test('bot PRs are skipped', async () => {
|
||||
const { calls } = await run({}, 'Bot');
|
||||
assert.deepEqual(calls, []);
|
||||
});
|
||||
|
||||
test('a failed request warns instead of failing', async () => {
|
||||
const { warnings, failures } = await run({ fail: true });
|
||||
assert.match(warnings[0], /Could not request a Copilot review on #9/);
|
||||
assert.deepEqual(failures, []);
|
||||
});
|
||||
|
||||
test('an accepted request GitHub never recorded warns', async () => {
|
||||
const { warnings } = await run({ after: [{ id: 1, event: 'labeled' }] });
|
||||
assert.match(warnings[0], /recorded none/);
|
||||
});
|
||||
|
||||
test('a request filed by another account does not confirm ours', async () => {
|
||||
const { warnings } = await run({ after: [copilotRequest(1, 'other'), copilotReview(2, LATER)] });
|
||||
assert.match(warnings[0], /recorded none/);
|
||||
});
|
||||
|
||||
test('an earlier request by the same account does not confirm this one', async () => {
|
||||
const { warnings } = await run({ timeline: [copilotRequest(1, 'ours', OLD), copilotReview(2, LATER)] });
|
||||
assert.match(warnings[0], /recorded none/);
|
||||
});
|
||||
|
||||
test('a Copilot review still pending is logged, not warned', async () => {
|
||||
const { infos, warnings } = await run({ timeline: [copilotReview(1, OLD), copilotRequest(2, 'other')] });
|
||||
assert.deepEqual(warnings, []);
|
||||
assert.match(infos[0], /requested by someone is still pending on #9/);
|
||||
});
|
||||
|
||||
test('a Copilot request that was removed is not pending', async () => {
|
||||
const { warnings } = await run({ timeline: [copilotRequest(1, 'other'), copilotRemoval(2)] });
|
||||
assert.match(warnings[0], /recorded none/);
|
||||
});
|
||||
|
||||
test('a completed review under the bot account login ends the pending request', async () => {
|
||||
const timeline = [
|
||||
copilotRequest(1, 'other', OLD),
|
||||
copilotReview(2, LATER, 'copilot-pull-request-reviewer[bot]'),
|
||||
];
|
||||
const { warnings } = await run({ timeline });
|
||||
assert.match(warnings[0], /recorded none/);
|
||||
});
|
||||
|
||||
test('a failed timeline read after the request warns instead of failing', async () => {
|
||||
const { calls, warnings } = await run({ timelineError: 'after' });
|
||||
assert.equal(calls.length, 1);
|
||||
assert.match(warnings[0], /could not confirm it: secondary rate limit/);
|
||||
});
|
||||
|
||||
test('a failed baseline read still requests the review, unconfirmed', async () => {
|
||||
const { calls, warnings } = await run({ timelineError: 'before' });
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(warnings.length, 1);
|
||||
assert.match(warnings[0], /goes unconfirmed: secondary rate limit/);
|
||||
});
|
||||
|
||||
test('a rejected token fails the run so it gets rotated', async () => {
|
||||
const { calls, failures } = await run({ whoamiStatus: 401 });
|
||||
assert.equal(calls.length, 0);
|
||||
assert.match(failures[0], /COPILOT_REVIEW_TOKEN was rejected/);
|
||||
});
|
||||
|
||||
test('a failed account lookup still requests the review, unconfirmed', async () => {
|
||||
const { calls, warnings, failures } = await run({ whoamiStatus: 502 });
|
||||
assert.equal(calls.length, 1);
|
||||
assert.deepEqual(failures, []);
|
||||
assert.equal(warnings.length, 1);
|
||||
assert.match(warnings[0], /Could not identify the requesting account/);
|
||||
});
|
||||
@@ -74,6 +74,9 @@ workflows:
|
||||
- 'docker/login-action@v4.8.0'
|
||||
- 'docker/setup-buildx-action@v4.4.1'
|
||||
- 'pypa/gh-action-pypi-publish@v1.14.3'
|
||||
'.github/workflows/request-copilot-review.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/github-script@v9.0.0'
|
||||
'.github/workflows/stale.yml': []
|
||||
'.github/workflows/status-check-labels.yml':
|
||||
- 'actions/github-script@v9.0.0'
|
||||
|
||||
@@ -25,3 +25,14 @@ jobs:
|
||||
- name: Run tests
|
||||
working-directory: .github/scripts/auto-label-pr
|
||||
run: npm test
|
||||
|
||||
test-request-copilot-review:
|
||||
name: Test request-copilot-review script
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code from GitHub
|
||||
uses: actions/checkout@v7.0.1
|
||||
|
||||
- name: Run tests
|
||||
working-directory: .github/scripts/request-copilot-review
|
||||
run: npm test
|
||||
@@ -0,0 +1,57 @@
|
||||
name: Request Copilot review
|
||||
|
||||
# Requests a Copilot code review when a ready pull request against dev is
|
||||
# opened, reopened or marked ready for review; like the ruleset, not on every
|
||||
# push. The ruleset reviews these too, but it runs the review as the PR author
|
||||
# (or whoever marked it ready), so a contributor without Copilot access gets
|
||||
# none. This runs it as esphome-review-bot, which needs a Copilot seat and
|
||||
# Triage on this repo. COPILOT_REVIEW_TOKEN is an org secret holding its
|
||||
# fine-grained token (Pull requests read and write) and expires: when it is
|
||||
# rejected the run fails, and an org owner signs in as the bot, creates a new
|
||||
# one and replaces the secret.
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- ready_for_review
|
||||
branches:
|
||||
- dev
|
||||
- copilot-review-test-base
|
||||
|
||||
permissions: {}
|
||||
|
||||
# Overlapping runs could each take the other's request as their own confirmation.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
request:
|
||||
name: Request Copilot review
|
||||
runs-on: ubuntu-latest
|
||||
# Forks have no review bot token, bot PRs (Dependabot) get no repo secrets,
|
||||
# and drafts are not reviewed.
|
||||
if: >-
|
||||
github.repository == 'esphome/esphome'
|
||||
&& github.event.pull_request.user.type != 'Bot'
|
||||
&& !github.event.pull_request.draft
|
||||
permissions:
|
||||
contents: read # to check out the script below
|
||||
steps:
|
||||
# Checks out the base repo (trusted) only to load the script below,
|
||||
# never the PR's code - this job holds the review bot's token.
|
||||
- name: Checkout scripts
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
sparse-checkout: .github/scripts/request-copilot-review
|
||||
persist-credentials: false
|
||||
|
||||
- name: Request Copilot review
|
||||
uses: actions/github-script@v9.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.COPILOT_REVIEW_TOKEN }}
|
||||
script: |
|
||||
const script = require('./.github/scripts/request-copilot-review/index.js');
|
||||
await script({ github, context, core });
|
||||
@@ -247,7 +247,6 @@ file does, and it is the authority when they disagree. The most useful starting
|
||||
`DS_BCD_CALENDAR` or `PCF_BCD_CALENDAR`.
|
||||
* **Bus helpers:** UART drains with `read_available(on_byte)` and `discard_available()`, text lines with
|
||||
`LineReader<N>`, fixed-length binary frames with `FrameReader<N, HEADER...>`; I2C has `update_register`,
|
||||
`update_register16`, `read_byte_reg16` and `write_byte_reg16` for 16-bit register addresses,
|
||||
`write_registers` (PROGMEM `I2CRegValue` table), `check_chip_id` and `read_bytes_16_le`.
|
||||
`if (!this->status_comm_result(ok)) return;` sets or clears the warning; an earlier step of a multi-step
|
||||
poll uses `status_comm_check(ok)`, which only sets it, so the last step must clear it; in `setup()`,
|
||||
@@ -312,27 +311,6 @@ file does, and it is the authority when they disagree. The most useful starting
|
||||
text::Text *source_{nullptr};
|
||||
};
|
||||
```
|
||||
* **No state that copies other state:** a flag that mirrors a timer, a `has_x_` bool beside `x_`, or an enum
|
||||
that can be worked out from fields already stored is a second source of truth. Use the source:
|
||||
`pending = this->cancel_timeout(ID)`, an unset value of `NAN` or an out-of-range sentinel.
|
||||
* **No dead guards:** do not check what the caller or core already guarantees: a member that codegen always
|
||||
sets, `is_failed()` in `loop()` (core stops calling it), a value the config validation already limits, a
|
||||
`default:` in a `switch` over every value of an `enum class` the component sets itself (keep it when the
|
||||
value is cast from bus data).
|
||||
* **Member layout:** order fields so the compiler adds no padding (usually largest first), store small codes
|
||||
as `uint8_t`, declare `enum class X : uint8_t`, and pack flags into one byte.
|
||||
* **Work out constants in Python:** math that only depends on the configuration (register bytes, scale
|
||||
factors, thresholds, checksums) is done in `to_code` and passed as a plain value, not done in C++ at
|
||||
boot.
|
||||
* **One table for both directions:** a value that is encoded and decoded through the same mapping uses one
|
||||
`static constexpr` (`PROGMEM` on ESP8266) table of `{value, code}` pairs, not two `switch` ladders.
|
||||
* **Logging:** follow https://developers.esphome.io/architecture/logging/ for log levels and `dump_config()`.
|
||||
In short: a reading is logged with `ESP_LOGV`, not `ESP_LOGD` on every update; `setup()` logs no
|
||||
"Setting up" or "initialized" line (core logs setup); `dump_config()` combines related lines into one
|
||||
`ESP_LOGCONFIG` call, within the 512-byte log buffer.
|
||||
* **Leaf classes are `final`:** a component or entity class nothing derives from is declared `final`.
|
||||
* **No copies within the PR:** two functions, branches or platform files that differ in a constant or two
|
||||
become one helper, loop or table; helpers, includes and imports nothing uses are deleted.
|
||||
|
||||
* **Component Code Generation:** every component's `__init__.py` defines `DOMAIN` (its own name, checked by
|
||||
CI). Hub entities go in platform files (`sensor.py`, ...) that take the hub's id, not under the hub's own
|
||||
@@ -379,8 +357,7 @@ file does, and it is the authority when they disagree. The most useful starting
|
||||
`script/test_build_components -c <component>`. Never define buses directly in test YAML: include the
|
||||
shared packages from `tests/test_build_components/common/` with dict-style `packages:`. Test file naming,
|
||||
`validate.*.yaml` config-only tests, CI grouping, C++ unit tests and integration tests are in the
|
||||
`component-tests` skill. Tests that differ only in their inputs are one `pytest.mark.parametrize` test
|
||||
or a table-driven gtest.
|
||||
`component-tests` skill.
|
||||
|
||||
* **Debugging and Troubleshooting:**
|
||||
* **Debug Tools:**
|
||||
|
||||
@@ -385,7 +385,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
# Adds a define and IDF component for legacy `audio_decoder.cpp`.
|
||||
if data.flac_support:
|
||||
cg.add_define("USE_AUDIO_FLAC_SUPPORT")
|
||||
add_idf_component(name="esphome/micro-flac", ref="0.3.1")
|
||||
add_idf_component(name="esphome/micro-flac", ref="0.3.0")
|
||||
_emit_memory_pair(
|
||||
data.flac.buffer_memory,
|
||||
"CONFIG_MICRO_FLAC_PREFER_PSRAM",
|
||||
|
||||
@@ -10,7 +10,7 @@ dependencies:
|
||||
esphome/micro-decoder:
|
||||
version: 0.4.0
|
||||
esphome/micro-flac:
|
||||
version: 0.3.1
|
||||
version: 0.3.0
|
||||
esphome/micro-mp3:
|
||||
version: 0.4.0
|
||||
esphome/micro-opus:
|
||||
|
||||
Reference in new issue
Block a user