|
10 | 10 | env: |
11 | 11 | PYTHON_VERSION: "3.13" |
12 | 12 | UV_CACHE_DIR: /tmp/.uv-cache |
| 13 | + # renovate: datasource=docker depName=ghcr.io/home-assistant/home-assistant |
| 14 | + HA_IMAGE_GHCR: "ghcr.io/home-assistant/home-assistant:2026.1.3" |
13 | 15 |
|
14 | 16 | jobs: |
15 | 17 | lint: |
|
28 | 30 | - name: Run ruff check |
29 | 31 | run: uv run ruff check src/ tests/ |
30 | 32 |
|
| 33 | + # Fast unit tests (no Docker, no HA instance needed) |
| 34 | + unit-tests: |
| 35 | + name: Unit Tests |
| 36 | + runs-on: ubuntu-latest |
| 37 | + container: |
| 38 | + image: ghcr.io/astral-sh/uv:0.9.30-python3.13-bookworm-slim |
| 39 | + timeout-minutes: 5 |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v6 |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: uv sync --all-extras --dev |
| 46 | + |
| 47 | + - name: Run unit tests |
| 48 | + run: uv run pytest tests/src/unit/ -n auto --tb=short -v |
| 49 | + |
31 | 50 | # Comprehensive E2E validation for all PRs |
32 | 51 | e2e-validation: |
33 | 52 | name: E2E Validation (${{ matrix.os }}) |
|
50 | 69 |
|
51 | 70 | - name: Set up Docker Buildx |
52 | 71 | uses: docker/setup-buildx-action@v3 |
| 72 | + with: |
| 73 | + cache-binary: true |
53 | 74 |
|
54 | 75 | - name: Install uv |
55 | 76 | uses: astral-sh/setup-uv@v7 |
|
62 | 83 | - name: Install dependencies |
63 | 84 | run: uv sync --all-extras --dev |
64 | 85 |
|
| 86 | + - name: Cache HA Docker image |
| 87 | + id: cache-ha-image |
| 88 | + uses: actions/cache@v4 |
| 89 | + with: |
| 90 | + path: /tmp/ha-image.tar |
| 91 | + key: ha-image-${{ env.HA_IMAGE_GHCR }}-${{ runner.arch }} |
| 92 | + |
| 93 | + - name: Load cached HA image |
| 94 | + if: steps.cache-ha-image.outputs.cache-hit == 'true' |
| 95 | + run: docker load -i /tmp/ha-image.tar |
| 96 | + |
| 97 | + - name: Pull HA image (GHCR → Docker Hub fallback) |
| 98 | + if: steps.cache-ha-image.outputs.cache-hit != 'true' |
| 99 | + run: | |
| 100 | + HA_VERSION="${HA_IMAGE_GHCR##*:}" |
| 101 | + HA_IMAGE_DOCKERHUB="homeassistant/home-assistant:${HA_VERSION}" |
| 102 | + for registry in "$HA_IMAGE_GHCR" "$HA_IMAGE_DOCKERHUB"; do |
| 103 | + echo "Trying $registry..." |
| 104 | + if docker pull "$registry"; then |
| 105 | + if [ "$registry" != "$HA_IMAGE_GHCR" ]; then |
| 106 | + docker tag "$registry" "$HA_IMAGE_GHCR" |
| 107 | + fi |
| 108 | + docker save "$HA_IMAGE_GHCR" -o /tmp/ha-image.tar |
| 109 | + echo "Pulled and cached from $registry" |
| 110 | + exit 0 |
| 111 | + fi |
| 112 | + echo "Failed to pull from $registry, trying next..." |
| 113 | + sleep 15 |
| 114 | + done |
| 115 | + echo "All registries failed" && exit 1 |
| 116 | +
|
65 | 117 | - name: Run full E2E test suite |
66 | 118 | run: | |
67 | 119 | echo "🚀 Running full E2E test suite with ${{ matrix.pytest_workers }} workers..." |
|
84 | 136 |
|
85 | 137 | - name: Set up Docker Buildx |
86 | 138 | uses: docker/setup-buildx-action@v3 |
| 139 | + with: |
| 140 | + cache-binary: true |
87 | 141 |
|
88 | 142 | - name: Install uv |
89 | 143 | uses: astral-sh/setup-uv@v7 |
|
0 commit comments