name: CI on: push: tags-ignore: - "v*" pull_request: workflow_dispatch: permissions: contents: read jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-python@v6 with: python-version: "3.12" - name: Validate JSON run: | python -m json.tool hacs.json > /dev/null python -m json.tool repository.json > /dev/null python -m json.tool custom_components/elegoo_spaghetti_detection/manifest.json > /dev/null python -m json.tool custom_components/elegoo_spaghetti_detection/translations/en.json > /dev/null - name: Validate Python syntax run: python -m compileall custom_components/elegoo_spaghetti_detection addon/rootfs/app - name: Validate YAML run: | python -m pip install pyyaml python - <<'PY' from pathlib import Path import yaml class Loader(yaml.SafeLoader): pass def unknown_constructor(loader, tag_suffix, node): if isinstance(node, yaml.MappingNode): return loader.construct_mapping(node) if isinstance(node, yaml.SequenceNode): return loader.construct_sequence(node) return loader.construct_scalar(node) Loader.add_multi_constructor("!", unknown_constructor) paths = [ Path("docker-compose.yaml"), Path("addon/config.yaml"), Path("custom_components/elegoo_spaghetti_detection/services.yaml"), Path(".github/workflows/ci.yaml"), Path(".github/workflows/hassfest.yaml"), Path(".github/workflows/validate.yaml"), Path(".github/dependabot.yml"), *Path("examples").glob("*.yaml"), ] for path in sorted(paths): with path.open("r", encoding="utf-8") as handle: yaml.load(handle, Loader=Loader) PY