-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Standardize code style * Add continuous integration workflow
- Loading branch information
1 parent
426cf9c
commit d419a7e
Showing
25 changed files
with
377 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
UseTab: Never | ||
IndentWidth: 4 | ||
NamespaceIndentation: All | ||
AccessModifierOffset: -4 | ||
BreakBeforeBraces: Allman | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
IndentCaseLabels: false | ||
SortIncludes: false | ||
ColumnLimit: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: CI | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
esphome_version: | ||
description: "ESPHome PyPi Package version to use" | ||
required: false | ||
type: string | ||
push: | ||
branches: [main, dev] | ||
|
||
pull_request: | ||
merge_group: | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
# yamllint disable-line rule:line-length | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci: | ||
name: ${{ matrix.name }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 5 | ||
matrix: | ||
include: | ||
- id: test | ||
file: tests/full.yaml | ||
name: Test tests/full.yaml | ||
pio_cache_key: full | ||
- id: test | ||
file: tests/base.yaml | ||
name: Test tests/base.yaml | ||
pio_cache_key: base | ||
- id: clang-format | ||
name: Run clang-format | ||
- id: yamllint | ||
name: Run yamllint | ||
- id: black-format | ||
name: Run black-format | ||
- id: isort | ||
name: Run isort | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
id: python | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Cache virtualenv | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
# yamllint disable-line rule:line-length | ||
key: venv-${{ steps.python.outputs.python-version }} | ||
restore-keys: | | ||
venv-${{ steps.python.outputs.python-version }} | ||
- name: Set up virtualenv | ||
# yamllint disable rule:line-length | ||
run: | | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
pip install -U pip | ||
pip install -r requirements.txt | ||
if [ ${{ github.event.inputs.esphome_version != '' }} == true ]; then pip install ESPHome==${{ github.event.inputs.esphome_version }}; else pip install -U ESPHome; fi | ||
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH | ||
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV | ||
# yamllint enable rule:line-length | ||
|
||
# Use per check platformio cache because checks use different parts | ||
- name: Cache platformio | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.platformio | ||
# yamllint disable-line rule:line-length | ||
key: platformio-${{ matrix.pio_cache_key }}-${{ hashFiles('platformio.ini') }} | ||
if: matrix.id == 'test' | ||
|
||
- run: esphome compile ${{ matrix.file }} | ||
if: matrix.id == 'test' | ||
env: | ||
# Also cache libdeps, store them in a ~/.platformio subfolder | ||
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps | ||
|
||
- name: Run clang-format | ||
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: "13" | ||
check-path: "components" | ||
if: matrix.id == 'clang-format' | ||
|
||
- name: Run yamllint | ||
if: matrix.id == 'yamllint' | ||
uses: frenck/[email protected] | ||
|
||
- name: Run black-format | ||
if: matrix.id == 'black-format' | ||
uses: psf/black@stable | ||
with: | ||
options: "--check --verbose" | ||
version: "~= 24.1" | ||
|
||
- name: Run isort | ||
if: matrix.id == 'isort' | ||
uses: isort/isort-action@master | ||
with: | ||
requirementsFiles: "requirements.txt" | ||
|
||
ci-status: | ||
name: CI Status | ||
runs-on: ubuntu-latest | ||
needs: [ci] | ||
if: always() | ||
steps: | ||
- name: Successful deploy | ||
if: ${{ !(contains(needs.*.result, 'failure')) }} | ||
run: exit 0 | ||
- name: Failing deploy | ||
if: ${{ contains(needs.*.result, 'failure') }} | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
repos: | ||
- repo: https://github.com/psf/black-pre-commit-mirror | ||
rev: 24.1.0 | ||
hooks: | ||
- id: black | ||
language_version: python3.11 | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
|
||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v17.0.6 | ||
hooks: | ||
- id: clang-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,4 +406,4 @@ namespace esphome::ld2450 | |
|
||
flush(); | ||
} | ||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ namespace esphome::ld2450 | |
void control(const std::string &value); | ||
}; | ||
|
||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ namespace esphome::ld2450 | |
{ | ||
parent_->set_bluetooth_state(state); | ||
} | ||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ namespace esphome::ld2450 | |
void write_state(bool state) override; | ||
}; | ||
|
||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,4 @@ namespace esphome::ld2450 | |
ESPPreferenceObject pref_; | ||
}; | ||
|
||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ namespace esphome::ld2450 | |
{ | ||
parent_->set_tracking_mode(state); | ||
} | ||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ namespace esphome::ld2450 | |
void write_state(bool state) override; | ||
}; | ||
|
||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,4 +159,4 @@ namespace esphome::ld2450 | |
} | ||
return true; | ||
} | ||
} | ||
} // namespace esphome::ld2450 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[tool.black] | ||
target-version = ["py311"] | ||
[tool.isort] | ||
profile = "black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
esphome: | ||
name: ld2450 | ||
|
||
esp32: | ||
board: esp32dev | ||
|
||
external_components: | ||
- source: | ||
type: local | ||
path: ../components | ||
|
||
logger: | ||
baud_rate: 0 | ||
|
||
uart: | ||
id: uart_bus | ||
rx_pin: | ||
number: GPIO16 | ||
mode: | ||
input: true | ||
pullup: true | ||
tx_pin: | ||
number: GPIO17 | ||
mode: | ||
input: true | ||
pullup: true | ||
baud_rate: 256000 | ||
parity: NONE | ||
stop_bits: 1 | ||
data_bits: 8 | ||
|
||
LD2450: | ||
uart_id: uart_bus |
Oops, something went wrong.