CI #1677
This file contains hidden or 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
name: CI | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: 0 12 * * * | |
permissions: | |
contents: read | |
env: | |
FORCE_COLOR: 1 | |
DEFAULT_PYTHON: "3.11" | |
PYUPGRADE_TARGET: "--py311-plus" | |
concurrency: | |
# yamllint disable-line rule:line-length | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
yamllint: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run yamllint | |
uses: frenck/action-yamllint@v1 | |
with: | |
config: .yamllint | |
bundle: | |
name: Bundle external component and ESPHome | |
runs-on: ubuntu-24.04 | |
outputs: | |
repo-hash: ${{ github.sha }} | |
steps: | |
- name: Check out this project | |
uses: actions/[email protected] | |
- name: Check out code from ESPHome project | |
uses: actions/[email protected] | |
with: | |
repository: esphome/esphome | |
ref: dev | |
path: esphome | |
- name: Copy external component into the esphome project | |
run: | | |
cd esphome | |
cp -r ../components/* esphome/components/ | |
git config user.name "ci" | |
git config user.email "[email protected]" | |
git add . | |
git commit -a -m "Add external component" | |
ln -sf ../venv venv | |
- name: Archive prepared repository | |
uses: pyTooling/upload-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
include-hidden-files: true | |
retention-days: 1 | |
common: | |
name: Create common environment | |
runs-on: ubuntu-24.04 | |
needs: bundle | |
outputs: | |
cache-key: ${{ steps.cache-key.outputs.key }} | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Generate cache-key | |
id: cache-key | |
run: echo key="${{ hashFiles('esphome/requirements.txt', 'esphome/requirements_test.txt') }}" >> $GITHUB_OUTPUT | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
# yamllint disable-line rule:line-length | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ steps.cache-key.outputs.key }} | |
- name: Create Python virtual environment | |
if: steps.cache-venv.outputs.cache-hit != 'true' | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
python --version | |
cd esphome | |
pip install -r requirements.txt -r requirements_test.txt | |
pip install -e . | |
pip install yq | |
ruff: | |
name: Check ruff | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Run Ruff | |
run: | | |
. venv/bin/activate | |
ruff format esphome tests | |
- name: Suggested changes | |
run: script/ci-suggest-changes | |
if: always() | |
flake8: | |
name: Check flake8 | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- 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-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- 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-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- 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-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Register matcher | |
run: echo "::add-matcher::.github/workflows/matchers/ci-custom.json" | |
- name: Do not suggest to move consts | |
run: | | |
sed -i 's#if len(uses) < 3:#if len(uses) < 8:#' script/ci-custom.py | |
git update-index --assume-unchanged script/ci-custom.py | |
- name: Run script/ci-custom | |
run: | | |
. ../venv/bin/activate | |
script/ci-custom.py | |
clang-format: | |
name: Check clang-format | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Install clang-format | |
run: | | |
. venv/bin/activate | |
pip install clang-format -c requirements_dev.txt | |
- name: Run clang-format | |
run: | | |
. venv/bin/activate | |
script/clang-format -i | |
- name: Suggested changes | |
run: script/ci-suggest-changes | |
if: always() | |
clang-tidy: | |
name: ${{ matrix.name }} | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
defaults: | |
run: | |
working-directory: esphome | |
strategy: | |
fail-fast: false | |
max-parallel: 2 | |
matrix: | |
include: | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP8266 | |
options: --environment esp8266-arduino-tidy --grep USE_ESP8266 | |
pio_cache_key: tidyesp8266 | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP32 Arduino 1/4 | |
options: --environment esp32-arduino-tidy --split-num 4 --split-at 1 | |
pio_cache_key: tidyesp32 | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP32 Arduino 2/4 | |
options: --environment esp32-arduino-tidy --split-num 4 --split-at 2 | |
pio_cache_key: tidyesp32 | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP32 Arduino 3/4 | |
options: --environment esp32-arduino-tidy --split-num 4 --split-at 3 | |
pio_cache_key: tidyesp32 | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP32 Arduino 4/4 | |
options: --environment esp32-arduino-tidy --split-num 4 --split-at 4 | |
pio_cache_key: tidyesp32 | |
- id: clang-tidy | |
name: Run script/clang-tidy for ESP32 IDF | |
options: --environment esp32-idf-tidy --grep USE_ESP_IDF | |
pio_cache_key: tidyesp32-idf | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Update index to make "git diff-index" happy | |
run: git update-index -q --really-refresh | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Cache platformio | |
if: github.ref == 'refs/heads/dev' | |
uses: actions/[email protected] | |
with: | |
path: ~/.platformio | |
key: platformio-${{ matrix.pio_cache_key }} | |
- name: Cache platformio | |
if: github.ref != 'refs/heads/dev' | |
uses: actions/cache/[email protected] | |
with: | |
path: ~/.platformio | |
key: platformio-${{ matrix.pio_cache_key }} | |
- name: Register problem matchers | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/gcc.json" | |
echo "::add-matcher::.github/workflows/matchers/clang-tidy.json" | |
- name: Run 'pio run --list-targets -e esp32-idf-tidy' | |
if: matrix.name == 'Run script/clang-tidy for ESP32 IDF' | |
run: | | |
. venv/bin/activate | |
mkdir -p .temp | |
pio run --list-targets -e esp32-idf-tidy | |
- name: Run clang-tidy | |
run: | | |
. venv/bin/activate | |
script/clang-tidy --all-headers --fix ${{ matrix.options }} ../components | |
env: | |
# Also cache libdeps, store them in a ~/.platformio subfolder | |
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps | |
- name: Suggested changes | |
run: script/ci-suggest-changes | |
# yamllint disable-line rule:line-length | |
if: always() | |
esphome-config: | |
name: Validate example configurations | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Register matcher | |
run: echo "::add-matcher::.github/workflows/matchers/esphome-config.json" | |
- name: Switch packages to local files for testing | |
run: | | |
. venv/bin/activate | |
for YAML in $(grep -l "^packages:" *.yaml); do | |
yq -i -y '.packages = "!include packages.local.yaml"' $YAML | |
sed -i "s/'!include packages.local.yaml'/!include packages.local.yaml/" $YAML | |
done | |
- name: Validate example configurations | |
run: | | |
. venv/bin/activate | |
echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > secrets.yaml | |
for YAML in esp*.yaml; do | |
esphome -s external_components_source components config $YAML | |
done | |
- name: Validate test configurations | |
run: | | |
. venv/bin/activate | |
echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > tests/secrets.yaml | |
for YAML in tests/esp*.yaml; do | |
esphome -s external_components_source ../components config $YAML | |
done | |
esphome-compile: | |
name: Build example configurations | |
runs-on: ubuntu-24.04 | |
needs: | |
- bundle | |
- common | |
steps: | |
- name: Download prepared repository | |
uses: pyTooling/download-artifact@v4 | |
with: | |
name: bundle | |
path: . | |
- name: Restore Python | |
uses: ./.github/actions/restore-python | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
cache-key: ${{ needs.common.outputs.cache-key }} | |
- name: Switch packages to local files for testing | |
run: | | |
. venv/bin/activate | |
for YAML in $(grep -l "^packages:" *.yaml); do | |
yq -i -y '.packages = "!include packages.local.yaml"' $YAML | |
sed -i "s/'!include packages.local.yaml'/!include packages.local.yaml/" $YAML | |
done | |
- name: Compile example configurations | |
run: | | |
. venv/bin/activate | |
echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > secrets.yaml | |
for YAML in esp*faker.yaml esp32-ble-example-multiple-devices.yaml; do | |
esphome -s external_components_source components compile $YAML | |
done | |
- name: Compile test configurations | |
run: | | |
. venv/bin/activate | |
echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > tests/secrets.yaml | |
esphome -s external_components_source ../components compile tests/esp32c6-compatibility-test.yaml |