CT002: relay mode bucket aggregation & adaptive consumer eviction #914
Workflow file for this run
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 Pipeline | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| tags: [ "*.*.*" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| run: uv sync --frozen --extra dev | |
| - name: Ruff check | |
| run: uv run ruff check . | |
| - name: Ruff format | |
| run: uv run ruff format --check . | |
| - name: Mypy | |
| run: uv run mypy src/ | |
| ct002-host-protocol: | |
| needs: [ lint ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install build tooling | |
| run: sudo apt-get update -qq && sudo apt-get install -y -qq cmake g++ | |
| - name: Install dependencies | |
| run: uv sync --frozen --extra dev | |
| - name: Run host-gcc protocol + wrappers + balancer parity tests | |
| run: uv run pytest tests/components/ct002/test_host_protocol.py -v | |
| # Discover the ct002 compile targets dynamically so adding a | |
| # tests/components/ct002/test.*.yaml file is automatically compiled in CI | |
| # without editing this workflow. | |
| ct002-esphome-yaml: | |
| needs: [ lint ] | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.find.outputs.matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Collect test YAML files | |
| id: find | |
| run: | | |
| matrix=$(ls tests/components/ct002/test.*.yaml | jq -R -s -c 'split("\n")[:-1]') | |
| echo "matrix=$matrix" >> "$GITHUB_OUTPUT" | |
| ct002-esphome-compile: | |
| needs: [ ct002-esphome-yaml ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| yaml: ${{ fromJSON(needs.ct002-esphome-yaml.outputs.matrix) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install ESPHome | |
| run: pip install esphome | |
| - name: Compile ${{ matrix.yaml }} | |
| run: esphome compile ${{ matrix.yaml }} | |
| ct002-host-e2e: | |
| needs: [ lint ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies (astrameter + esphome) | |
| run: | | |
| uv sync --frozen --extra dev | |
| uv tool install esphome | |
| # Build both host binaries in their own steps so a compile failure | |
| # shows up here (with full gcc output) rather than as an opaque pytest | |
| # timeout inside the module fixtures. The fixtures find the binaries | |
| # already built and skip recompiling. | |
| - name: Build ct002 host binary | |
| run: esphome compile tests/components/ct002/test.host.yaml | |
| - name: Build ct002 test-hooks (e2e control) binary | |
| run: esphome compile tests/components/ct002/test.e2e.host.yaml | |
| # All cross-backend suites are tagged `@pytest.mark.esphome_e2e` | |
| # (see pyproject.toml). Selecting by marker means new suites are | |
| # picked up automatically without editing this workflow. Their | |
| # `python` params also run in the `validate` job; the `esphome` | |
| # params only run where the esphome CLI + test-hooks binary exist. | |
| - name: Run host-platform E2E (cross-backend esphome suites) | |
| run: uv run pytest -m esphome_e2e -v | |
| # The codegen unit tests (test_codegen.py) `importorskip("esphome")` — | |
| # they import the esphome Python module to exercise the ct002 schema | |
| # validators directly, so they need esphome importable in the venv that | |
| # runs pytest (the `uv tool install` above only puts the CLI on PATH). | |
| # They're not `esphome_e2e`-marked, so without this they skip in every | |
| # job and never actually run. Install esphome into the project venv | |
| # last (so it can't perturb the e2e run above) and run them with | |
| # --no-sync so `uv run` doesn't drop esphome (it isn't in uv.lock). | |
| - name: Install esphome into venv for codegen tests | |
| run: uv pip install esphome | |
| - name: Run ct002 codegen unit tests (esphome schema validators) | |
| run: uv run --no-sync pytest tests/components/ct002/test_codegen.py -v | |
| validate: | |
| needs: [ lint ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: [ "3.10", "3.11", "3.12", "3.13" ] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-suffix: ${{ matrix.python-version }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install mosquitto (for MQTT integration tests) | |
| run: sudo apt-get update -qq && sudo apt-get install -y -qq mosquitto | |
| - name: Install dependencies | |
| run: uv sync --frozen --extra dev | |
| - name: Run tests | |
| run: uv run pytest --cov=astrameter --cov-report=xml --junitxml=test-results.xml | |
| - name: Upload test results | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.python-version }} | |
| path: test-results.xml | |
| - name: Upload coverage XML | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.python-version }} | |
| path: coverage.xml | |
| build: | |
| needs: [ validate ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - platform: linux/amd64 | |
| cache_scope: base-linux-amd64 | |
| - platform: linux/arm/v7 | |
| cache_scope: base-linux-arm-v7 | |
| - platform: linux/arm64 | |
| cache_scope: base-linux-arm64 | |
| uses: ./.github/workflows/build-image.yml | |
| with: | |
| registry: ghcr.io | |
| platform: ${{ matrix.config.platform }} | |
| cache_scope: ${{ matrix.config.cache_scope }} | |
| context: . | |
| dockerfile: ./Dockerfile | |
| image-suffix: "" | |
| digest-prefix: "digests-base-" | |
| push: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| merge: | |
| needs: [ build ] | |
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
| permissions: | |
| contents: read | |
| packages: write | |
| uses: ./.github/workflows/merge-manifests.yml | |
| with: | |
| registry: ghcr.io | |
| image-suffix: "" | |
| digest-prefix: "digests-base-" | |
| legacy-image-name: tomquist/b2500-meter | |
| build-addon: | |
| needs: [ validate ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| cache_scope: addon-linux-amd64 | |
| - platform: linux/arm64 | |
| cache_scope: addon-linux-arm64 | |
| uses: ./.github/workflows/build-image.yml | |
| with: | |
| registry: ghcr.io | |
| platform: ${{ matrix.platform }} | |
| cache_scope: ${{ matrix.cache_scope }} | |
| context: . | |
| dockerfile: ./ha_addon/Dockerfile | |
| build-args: | | |
| BUILD_FROM=ghcr.io/hassio-addons/base:17.0.1 | |
| image-suffix: "-addon" | |
| digest-prefix: "digests-addon-" | |
| push: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| merge-addon: | |
| needs: [ build-addon ] | |
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
| permissions: | |
| contents: read | |
| packages: write | |
| uses: ./.github/workflows/merge-manifests.yml | |
| with: | |
| registry: ghcr.io | |
| image-suffix: "-addon" | |
| digest-prefix: "digests-addon-" | |
| legacy-image-name: tomquist/b2500-meter |