-
Notifications
You must be signed in to change notification settings - Fork 51
165 lines (143 loc) · 4.34 KB
/
ci.yml
File metadata and controls
165 lines (143 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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/
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-"
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-"