mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-03-03 15:24:09 +01:00
Add CI: ESPHome config validation and YAML lint
- yamllint on all YAML files with ESPHome-friendly rules (allows True/False, long lines for lambdas, no forced document-start) - ESPHome config validation on changed mcu-*.yaml files per push/PR Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
45
.github/workflows/ci.yml
vendored
Normal file
45
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
yamllint:
|
||||||
|
name: YAML lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ibiqlik/action-yamllint@v3
|
||||||
|
with:
|
||||||
|
config_file: .yamllint.yml
|
||||||
|
file_or_dir: "*.yaml common/**/*.yaml"
|
||||||
|
|
||||||
|
validate:
|
||||||
|
name: ESPHome config validation
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get changed device configs
|
||||||
|
id: changed
|
||||||
|
uses: tj-actions/changed-files@v46
|
||||||
|
with:
|
||||||
|
files: "mcu-*.yaml"
|
||||||
|
|
||||||
|
- name: Install ESPHome
|
||||||
|
if: steps.changed.outputs.any_changed == 'true'
|
||||||
|
run: pip install esphome
|
||||||
|
|
||||||
|
- name: Prepare secrets
|
||||||
|
if: steps.changed.outputs.any_changed == 'true'
|
||||||
|
run: cp secrets.yaml.default secrets.yaml
|
||||||
|
|
||||||
|
- name: Validate changed configs
|
||||||
|
if: steps.changed.outputs.any_changed == 'true'
|
||||||
|
run: |
|
||||||
|
for f in ${{ steps.changed.outputs.all_changed_files }}; do
|
||||||
|
echo "Validating $f..."
|
||||||
|
esphome config "$f"
|
||||||
|
done
|
||||||
22
.yamllint.yml
Normal file
22
.yamllint.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
# ESPHome uses True/False (Python style) and yes/no
|
||||||
|
truthy:
|
||||||
|
allowed-values: ["true", "false", "True", "False", "yes", "no"]
|
||||||
|
check-keys: false
|
||||||
|
|
||||||
|
# Lambdas and long substitutions can exceed 80 chars
|
||||||
|
line-length:
|
||||||
|
max: 200
|
||||||
|
level: warning
|
||||||
|
|
||||||
|
# Not all files use --- document start marker
|
||||||
|
document-start: disable
|
||||||
|
|
||||||
|
# Some files have trailing spaces; warn only
|
||||||
|
trailing-spaces: enable
|
||||||
|
|
||||||
|
# Allow comments without a space after # in some cases (e.g. # noqa)
|
||||||
|
comments:
|
||||||
|
min-spaces-before-comment: 1
|
||||||
Reference in New Issue
Block a user