2022-09-06 05:48:01 +02:00
|
|
|
---
|
2020-07-14 14:34:44 +02:00
|
|
|
name: CI
|
|
|
|
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable-line rule:truthy
|
2020-07-14 14:34:44 +02:00
|
|
|
on:
|
|
|
|
push:
|
2021-07-15 21:30:04 +02:00
|
|
|
branches: [dev, beta, release]
|
2020-07-14 14:34:44 +02:00
|
|
|
|
|
|
|
pull_request:
|
2023-02-26 21:13:45 +01:00
|
|
|
merge_group:
|
2020-07-14 14:34:44 +02:00
|
|
|
|
2021-10-26 10:55:27 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2023-05-17 06:28:09 +02:00
|
|
|
env:
|
|
|
|
DEFAULT_PYTHON: "3.9"
|
|
|
|
PYUPGRADE_TARGET: "--py39-plus"
|
|
|
|
CLANG_FORMAT_VERSION: "13.0.1"
|
|
|
|
|
2021-11-25 22:02:39 +01:00
|
|
|
concurrency:
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable-line rule:line-length
|
2021-11-25 22:02:39 +01:00
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-07-14 14:34:44 +02:00
|
|
|
jobs:
|
2023-05-17 06:28:09 +02:00
|
|
|
common:
|
|
|
|
name: Create common environment
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
|
|
|
uses: actions/setup-python@v4.6.0
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
id: cache-venv
|
|
|
|
uses: actions/cache@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Create Python virtual environment
|
|
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
python -m venv venv
|
|
|
|
. venv/bin/activate
|
|
|
|
python --version
|
|
|
|
pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt
|
|
|
|
pip install -e .
|
|
|
|
|
|
|
|
yamllint:
|
|
|
|
name: yamllint
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Run yamllint
|
2023-06-01 03:17:57 +02:00
|
|
|
uses: frenck/action-yamllint@v1.4.1
|
2023-05-17 06:28:09 +02:00
|
|
|
|
|
|
|
black:
|
|
|
|
name: Check black
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Run black
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
black --verbose esphome tests
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
|
|
|
if: always()
|
|
|
|
|
|
|
|
flake8:
|
|
|
|
name: Check flake8
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Run flake8
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
flake8 esphome
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
|
|
|
if: always()
|
|
|
|
|
|
|
|
pylint:
|
|
|
|
name: Check pylint
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Run pylint
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
pylint -f parseable --persistent=n esphome
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
|
|
|
if: always()
|
|
|
|
|
|
|
|
pyupgrade:
|
|
|
|
name: Check pyupgrade
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Run pyupgrade
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
pyupgrade ${{ env.PYUPGRADE_TARGET }} `find esphome -name "*.py" -type f`
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
|
|
|
if: always()
|
|
|
|
|
|
|
|
ci-custom:
|
|
|
|
name: Run script/ci-custom
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Register matcher
|
|
|
|
run: echo "::add-matcher::.github/workflows/matchers/ci-custom.json"
|
|
|
|
- name: Run script/ci-custom
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
script/ci-custom.py
|
|
|
|
script/build_codeowners.py --check
|
|
|
|
|
|
|
|
pytest:
|
|
|
|
name: Run pytest
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Register matcher
|
|
|
|
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
|
|
|
|
- name: Run pytest
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
pytest -vv --tb=native tests
|
|
|
|
|
|
|
|
clang-format:
|
|
|
|
name: Check clang-format
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Install clang-format
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
pip install clang-format==${{ env.CLANG_FORMAT_VERSION }}
|
|
|
|
- name: Run clang-format
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
script/clang-format -i
|
|
|
|
git diff-index --quiet HEAD --
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
|
|
|
if: always()
|
|
|
|
|
|
|
|
compile-tests:
|
|
|
|
name: Run YAML test ${{ matrix.file }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
- black
|
|
|
|
- ci-custom
|
|
|
|
- clang-format
|
|
|
|
- flake8
|
|
|
|
- pylint
|
|
|
|
- pytest
|
|
|
|
- pyupgrade
|
|
|
|
- yamllint
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
max-parallel: 2
|
|
|
|
matrix:
|
2023-05-21 22:08:33 +02:00
|
|
|
file: [1, 2, 3, 3.1, 4, 5, 6, 7, 8]
|
2023-05-17 06:28:09 +02:00
|
|
|
steps:
|
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
|
|
|
with:
|
|
|
|
path: venv
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
- name: Cache platformio
|
|
|
|
uses: actions/cache@v3.3.1
|
|
|
|
with:
|
|
|
|
path: ~/.platformio
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
key: platformio-test${{ matrix.file }}-${{ hashFiles('platformio.ini') }}
|
|
|
|
- name: Run esphome compile tests/test${{ matrix.file }}.yaml
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
esphome compile tests/test${{ matrix.file }}.yaml
|
|
|
|
|
|
|
|
clang-tidy:
|
2021-07-15 21:30:04 +02:00
|
|
|
name: ${{ matrix.name }}
|
2020-07-14 14:34:44 +02:00
|
|
|
runs-on: ubuntu-latest
|
2023-05-17 06:28:09 +02:00
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
- black
|
|
|
|
- ci-custom
|
|
|
|
- clang-format
|
|
|
|
- flake8
|
|
|
|
- pylint
|
|
|
|
- pytest
|
|
|
|
- pyupgrade
|
|
|
|
- yamllint
|
2020-07-14 14:34:44 +02:00
|
|
|
strategy:
|
2020-09-29 19:50:06 +02:00
|
|
|
fail-fast: false
|
2023-05-17 06:28:09 +02:00
|
|
|
max-parallel: 2
|
2020-07-14 14:34:44 +02:00
|
|
|
matrix:
|
2021-07-15 21:30:04 +02:00
|
|
|
include:
|
2021-09-20 09:07:38 +02:00
|
|
|
- id: clang-tidy
|
|
|
|
name: Run script/clang-tidy for ESP8266
|
2022-01-05 21:30:15 +01:00
|
|
|
options: --environment esp8266-arduino-tidy --grep USE_ESP8266
|
2021-09-20 09:07:38 +02:00
|
|
|
pio_cache_key: tidyesp8266
|
|
|
|
- id: clang-tidy
|
2022-01-05 21:30:15 +01:00
|
|
|
name: Run script/clang-tidy for ESP32 Arduino 1/4
|
|
|
|
options: --environment esp32-arduino-tidy --split-num 4 --split-at 1
|
2021-09-20 09:07:38 +02:00
|
|
|
pio_cache_key: tidyesp32
|
|
|
|
- id: clang-tidy
|
2022-01-05 21:30:15 +01:00
|
|
|
name: Run script/clang-tidy for ESP32 Arduino 2/4
|
|
|
|
options: --environment esp32-arduino-tidy --split-num 4 --split-at 2
|
2021-09-20 09:07:38 +02:00
|
|
|
pio_cache_key: tidyesp32
|
|
|
|
- id: clang-tidy
|
2022-01-05 21:30:15 +01:00
|
|
|
name: Run script/clang-tidy for ESP32 Arduino 3/4
|
|
|
|
options: --environment esp32-arduino-tidy --split-num 4 --split-at 3
|
2021-09-20 09:07:38 +02:00
|
|
|
pio_cache_key: tidyesp32
|
|
|
|
- id: clang-tidy
|
2022-01-05 21:30:15 +01:00
|
|
|
name: Run script/clang-tidy for ESP32 Arduino 4/4
|
|
|
|
options: --environment esp32-arduino-tidy --split-num 4 --split-at 4
|
2021-09-20 09:07:38 +02:00
|
|
|
pio_cache_key: tidyesp32
|
2021-09-20 11:47:51 +02:00
|
|
|
- id: clang-tidy
|
2022-01-05 21:30:15 +01:00
|
|
|
name: Run script/clang-tidy for ESP32 IDF
|
2021-09-20 11:47:51 +02:00
|
|
|
options: --environment esp32-idf-tidy --grep USE_ESP_IDF
|
|
|
|
pio_cache_key: tidyesp32-idf
|
2021-07-15 21:30:04 +02:00
|
|
|
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2023-05-17 06:28:09 +02:00
|
|
|
- name: Check out code from GitHub
|
|
|
|
uses: actions/checkout@v3.5.2
|
|
|
|
- name: Restore Python virtual environment
|
|
|
|
uses: actions/cache/restore@v3.3.1
|
2020-07-14 14:34:44 +02:00
|
|
|
with:
|
2023-05-17 06:28:09 +02:00
|
|
|
path: venv
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable-line rule:line-length
|
2023-05-17 06:28:09 +02:00
|
|
|
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
|
|
# Use per check platformio cache because checks use different parts
|
2021-09-20 09:07:38 +02:00
|
|
|
- name: Cache platformio
|
2023-05-17 06:28:09 +02:00
|
|
|
uses: actions/cache@v3.3.1
|
2020-07-14 14:34:44 +02:00
|
|
|
with:
|
|
|
|
path: ~/.platformio
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable-line rule:line-length
|
2021-09-20 09:07:38 +02:00
|
|
|
key: platformio-${{ matrix.pio_cache_key }}-${{ hashFiles('platformio.ini') }}
|
2020-07-14 14:34:44 +02:00
|
|
|
|
2023-05-17 06:28:09 +02:00
|
|
|
- name: Install clang-tidy
|
|
|
|
run: sudo apt-get install clang-tidy-11
|
2020-07-15 01:37:30 +02:00
|
|
|
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Register problem matchers
|
|
|
|
run: |
|
2021-07-15 21:30:04 +02:00
|
|
|
echo "::add-matcher::.github/workflows/matchers/gcc.json"
|
2021-09-20 09:07:38 +02:00
|
|
|
echo "::add-matcher::.github/workflows/matchers/clang-tidy.json"
|
2020-07-15 14:00:02 +02:00
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
- name: Run clang-tidy
|
|
|
|
run: |
|
2023-05-17 06:28:09 +02:00
|
|
|
. venv/bin/activate
|
2021-09-20 09:07:38 +02:00
|
|
|
script/clang-tidy --all-headers --fix ${{ matrix.options }}
|
|
|
|
env:
|
|
|
|
# Also cache libdeps, store them in a ~/.platformio subfolder
|
|
|
|
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps
|
|
|
|
|
|
|
|
- name: Suggested changes
|
|
|
|
run: script/ci-suggest-changes
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable-line rule:line-length
|
2023-05-17 06:28:09 +02:00
|
|
|
if: always()
|
2023-02-14 00:54:38 +01:00
|
|
|
|
|
|
|
ci-status:
|
|
|
|
name: CI Status
|
|
|
|
runs-on: ubuntu-latest
|
2023-05-17 06:28:09 +02:00
|
|
|
needs:
|
|
|
|
- common
|
|
|
|
- black
|
|
|
|
- ci-custom
|
|
|
|
- clang-format
|
|
|
|
- flake8
|
|
|
|
- pylint
|
|
|
|
- pytest
|
|
|
|
- pyupgrade
|
|
|
|
- yamllint
|
|
|
|
- compile-tests
|
|
|
|
- clang-tidy
|
2023-02-14 00:54:38 +01:00
|
|
|
if: always()
|
|
|
|
steps:
|
2023-05-17 06:28:09 +02:00
|
|
|
- name: Success
|
2023-02-14 00:54:38 +01:00
|
|
|
if: ${{ !(contains(needs.*.result, 'failure')) }}
|
|
|
|
run: exit 0
|
2023-05-17 06:28:09 +02:00
|
|
|
- name: Failure
|
2023-02-14 00:54:38 +01:00
|
|
|
if: ${{ contains(needs.*.result, 'failure') }}
|
|
|
|
run: exit 1
|