Skip to content

Commit 5ec5f6c

Browse files
authored
Add continuous integration (#28)
* Standardize code style * Add continuous integration workflow
1 parent 30ef3e5 commit 5ec5f6c

File tree

21 files changed

+314
-13
lines changed

21 files changed

+314
-13
lines changed

.clang-format

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UseTab: Never
2+
IndentWidth: 4
3+
NamespaceIndentation: All
4+
AccessModifierOffset: -4
5+
BreakBeforeBraces: Allman
6+
AllowShortIfStatementsOnASingleLine: false
7+
AllowShortFunctionsOnASingleLine: false
8+
IndentCaseLabels: false
9+
SortIncludes: false
10+
ColumnLimit: 0

.github/workflows/ci.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: CI
2+
3+
# yamllint disable-line rule:truthy
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
esphome_version:
8+
description: "ESPHome PyPi Package version to use"
9+
required: false
10+
type: string
11+
push:
12+
branches: [main, dev]
13+
14+
pull_request:
15+
merge_group:
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
# yamllint disable-line rule:line-length
22+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
ci:
27+
name: ${{ matrix.name }}
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
max-parallel: 5
32+
matrix:
33+
include:
34+
- id: test
35+
file: tests/full.yaml
36+
name: Test tests/full.yaml
37+
pio_cache_key: full
38+
- id: test
39+
file: tests/base.yaml
40+
name: Test tests/base.yaml
41+
pio_cache_key: base
42+
- id: clang-format
43+
name: Run clang-format
44+
- id: yamllint
45+
name: Run yamllint
46+
- id: black-format
47+
name: Run black-format
48+
- id: isort
49+
name: Run isort
50+
51+
steps:
52+
- uses: actions/checkout@v3
53+
- name: Set up Python
54+
uses: actions/setup-python@v4
55+
id: python
56+
with:
57+
python-version: "3.9"
58+
59+
- name: Cache virtualenv
60+
uses: actions/cache@v3
61+
with:
62+
path: .venv
63+
# yamllint disable-line rule:line-length
64+
key: venv-${{ steps.python.outputs.python-version }}
65+
restore-keys: |
66+
venv-${{ steps.python.outputs.python-version }}
67+
- name: Set up virtualenv
68+
# yamllint disable rule:line-length
69+
run: |
70+
python -m venv .venv
71+
source .venv/bin/activate
72+
pip install -U pip
73+
pip install -r requirements.txt
74+
if [ ${{ github.event.inputs.esphome_version != '' }} == true ]; then pip install ESPHome==${{ github.event.inputs.esphome_version }}; else pip install -U ESPHome; fi
75+
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
76+
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
77+
# yamllint enable rule:line-length
78+
79+
# Use per check platformio cache because checks use different parts
80+
- name: Cache platformio
81+
uses: actions/cache@v3
82+
with:
83+
path: ~/.platformio
84+
# yamllint disable-line rule:line-length
85+
key: platformio-${{ matrix.pio_cache_key }}-${{ hashFiles('platformio.ini') }}
86+
if: matrix.id == 'test'
87+
88+
- run: esphome compile ${{ matrix.file }}
89+
if: matrix.id == 'test'
90+
env:
91+
# Also cache libdeps, store them in a ~/.platformio subfolder
92+
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps
93+
94+
- name: Run clang-format
95+
uses: jidicula/[email protected]
96+
with:
97+
clang-format-version: "13"
98+
check-path: "components"
99+
if: matrix.id == 'clang-format'
100+
101+
- name: Run yamllint
102+
if: matrix.id == 'yamllint'
103+
uses: frenck/[email protected]
104+
105+
- name: Run black-format
106+
if: matrix.id == 'black-format'
107+
uses: psf/black@stable
108+
with:
109+
options: "--check --verbose"
110+
version: "~= 24.1"
111+
112+
- name: Run isort
113+
if: matrix.id == 'isort'
114+
uses: isort/isort-action@master
115+
with:
116+
requirementsFiles: "requirements.txt"
117+
118+
ci-status:
119+
name: CI Status
120+
runs-on: ubuntu-latest
121+
needs: [ci]
122+
if: always()
123+
steps:
124+
- name: Successful deploy
125+
if: ${{ !(contains(needs.*.result, 'failure')) }}
126+
run: exit 0
127+
- name: Failing deploy
128+
if: ${{ contains(needs.*.result, 'failure') }}
129+
run: exit 1

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/psf/black-pre-commit-mirror
3+
rev: 24.1.0
4+
hooks:
5+
- id: black
6+
language_version: python3.11
7+
8+
- repo: https://github.com/pycqa/isort
9+
rev: 5.13.2
10+
hooks:
11+
- id: isort
12+
name: isort (python)
13+
14+
- repo: https://github.com/pre-commit/mirrors-clang-format
15+
rev: v17.0.6
16+
hooks:
17+
- id: clang-format

.yamllint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore: |
2+
venv/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ESPHome Smart Coffee (Philips Series 2200)
1+
# ESPHome Smart Coffee (Philips Series 2200) [![CI](https://github.com/TillFleisch/ESPHome-Philips-Smart-Coffee/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/TillFleisch/ESPHome-Philips-Smart-Coffee/actions/workflows/ci.yaml)
22

33
This project integrates a Philips Series 2200 Coffee Machine into into [Home Assistant](https://home-assistant.io) through [ESPHome](https://esphome.io).
44
This component has been developed on a Philips EP2220 and an ESP8266.

components/philips_action_button/action_button.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,20 @@ namespace esphome
5252
*
5353
* @param action Action to use
5454
*/
55-
void set_action(Action action) { action_ = action; };
55+
void set_action(Action action)
56+
{
57+
action_ = action;
58+
};
5659

5760
/**
5861
* @brief Reference to uart which is connected to the mainboard
5962
*
6063
* @param uart uart connected to mainboard
6164
*/
62-
void set_uart_device(uart::UARTDevice *uart) { mainboard_uart_ = uart; };
65+
void set_uart_device(uart::UARTDevice *uart)
66+
{
67+
mainboard_uart_ = uart;
68+
};
6369

6470
/**
6571
* @brief Sets the long press parameter on this button component.

components/philips_action_button/button.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import esphome.config_validation as cv
33
from esphome.components import button
44
from esphome.const import CONF_ID
5+
56
from ..philips_series_2200 import CONTROLLER_ID, PhilipsSeries2200
67

78
DEPENDENCIES = ["philips_series_2200"]

components/philips_bean_settings/bean_settings.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ namespace esphome
4444
*
4545
* @param source Source of the value
4646
*/
47-
void set_source(Source source) { source_ = source; };
47+
void set_source(Source source)
48+
{
49+
source_ = source;
50+
};
4851

4952
/**
5053
* @brief Sets the status sensor reference
@@ -60,7 +63,10 @@ namespace esphome
6063
*
6164
* @param uart uart connected to mainboard
6265
*/
63-
void set_uart_device(uart::UARTDevice *uart) { mainboard_uart_ = uart; };
66+
void set_uart_device(uart::UARTDevice *uart)
67+
{
68+
mainboard_uart_ = uart;
69+
};
6470

6571
/**
6672
* @brief Published the state if it's different form the currently published state.

components/philips_bean_settings/number.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import esphome.config_validation as cv
33
from esphome.components import number
44
from esphome.const import CONF_MODE
5+
56
from ..philips_series_2200 import CONTROLLER_ID, PhilipsSeries2200
67
from ..philips_status_sensor.text_sensor import STATUS_SENSOR_ID, StatusSensor
78

components/philips_power_switch/power.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ namespace esphome
9595
}
9696
}
9797

98-
} // namespace power_switch
98+
} // namespace philips_power_switch
9999
} // namespace philips_series_2200
100100
} // namespace esphome

0 commit comments

Comments
 (0)