Skip to content

test: tighten probe-coverage grid bounds to measured headroom (#470) #929

test: tighten probe-coverage grid bounds to measured headroom (#470)

test: tighten probe-coverage grid bounds to measured headroom (#470) #929

Workflow file for this run

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
# Steering-quality evaluation (issue #458): runs the deterministic
# active-control simulation suite (src/astrameter/simulator/evaluation.py)
# on the PR base and head and posts the before/after metrics as a sticky
# PR comment. Purely informational — thresholds that must hold live in
# pytest regressions, not here.
steering-eval:
needs: [ lint ]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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: Run evaluation (head)
run: uv run python -m astrameter.simulator.evaluation --json head.json
# The base run uses the base commit's own harness + controller. Until
# the harness exists on the base branch this produces an empty
# baseline and the comment shows head-only numbers.
- name: Run evaluation (base)
if: github.event_name == 'pull_request'
run: |
git worktree add /tmp/steering-base "${{ github.event.pull_request.base.sha }}"
if [ -f /tmp/steering-base/src/astrameter/simulator/evaluation.py ]; then
(cd /tmp/steering-base \
&& uv sync --frozen --extra dev \
&& uv run python -m astrameter.simulator.evaluation --json "$GITHUB_WORKSPACE/base.json")
else
echo "[]" > "$GITHUB_WORKSPACE/base.json"
fi
- name: Render comparison
if: github.event_name == 'pull_request'
run: |
uv run python -m astrameter.simulator.evaluation \
--input head.json --compare base.json > steering-eval-comment.md
cat steering-eval-comment.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload metrics artifacts
uses: actions/upload-artifact@v4
with:
name: steering-eval
path: |
head.json
base.json
steering-eval-comment.md
if-no-files-found: ignore
# Forks get a read-only token; they still see the table in the job
# summary above.
- name: Post sticky PR comment
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- steering-eval -->';
const body = marker + '\n' +
fs.readFileSync('steering-eval-comment.md', 'utf8');
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});
const existing = comments.find(
c => c.body && c.body.startsWith(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
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