-
Notifications
You must be signed in to change notification settings - Fork 27
327 lines (303 loc) · 14.3 KB
/
build.yaml
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: CHIP wheels build
on:
push:
branches:
- main
- release
tags:
- '**'
pull_request:
jobs:
build_prepare:
name: Prepare build
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
steps:
- name: Checkout build repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Get version
id: version
shell: bash
run: |
version="${{ github.ref_name }}"
today="$(date --utc '+%Y-%m-%d')"
midnight_timestamp="$(date --utc +%s --date=$today)"
calver_date="$(date --utc --date=$today '+%Y.%-m.dev%-d')"
if [ "${{ github.event_name }}" == "push" ]; then
if [[ "${version}" = "main" ]]; then
# Pushes to main branch are considered dev builds
commit_count="$(git rev-list --count --since=$midnight_timestamp HEAD)"
commit_count="$(printf "%02d" ${commit_count})"
version="${calver_date}${commit_count}"
fi
elif [ "${{ github.event_name }}" == "pull_request" ]; then
version="${calver_date}+pr${version%%/*}"
fi
echo "Building version $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Checkout submodules
working-directory: ./connectedhomeip/
run: scripts/checkout_submodules.py --shallow --platform linux
- name: Apply patches
working-directory: ./connectedhomeip/
run: |
for patch in ../*.patch
do
echo "Applying ${patch}"
patch -p1 < $patch
done
- name: Bootstrap
working-directory: ./connectedhomeip/
run: bash scripts/bootstrap.sh -p all,linux
- name: ZAP Code pre-generation
working-directory: ./connectedhomeip/
run: scripts/run_in_build_env.sh "scripts/codepregen.py ./zzz_pregenerated/"
- name: Create Matter SDK tar
run: |
tar -caf ../connectedhomeip.tar.zst --exclude ./connectedhomeip/.environment --use-compress-program=zstdmt .
mv ../connectedhomeip.tar.zst ./connectedhomeip.tar.zst
- name: Store Matter SDK as artifact
uses: actions/upload-artifact@v4
with:
name: matter-sdk-${{ github.run_id }}
path: ./connectedhomeip.tar.zst
build_linux_build_container:
name: Build Linux container for Python wheels
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write # Required for pushing containers to the registry
outputs:
container_image: ${{ steps.set_container_tag.outputs.container_image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure we can compare changes
- name: Determine Container Tag and Build Necessity
id: set_container_tag
run: |
build_needed=false
tag="${{ github.ref_name }}"
if [ "${{ github.event_name }}" == "push" ]; then
if git diff --name-only ${{ github.event.before }} HEAD | grep -E '^Dockerfile'; then
echo "Dockerfile or related files changed; building container."
build_needed=true
fi
elif [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull_request, use base_ref/head_ref
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then
echo "Forked PR detected; using base branch container."
tag="${{ github.base_ref }}"
else
tag="${{ github.head_ref }}"
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^Dockerfile'; then
echo "Dockerfile or related files changed; building container."
build_needed=true
fi
fi
fi
echo "Using container with tag: ${tag}"
echo "container_image=ghcr.io/${{ github.repository }}/chip-wheels-builder:${tag}" >> $GITHUB_OUTPUT
echo "build_needed=${build_needed}" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
if: ${{ env.build_needed == 'true' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ env.build_needed == 'true' }}
- name: Enable containerd snapshotter for multi-platform builds
uses: depot/use-containerd-snapshotter-action@v1
if: ${{ env.build_needed == 'true' }}
- name: Build and Push Docker Container
if: ${{ env.build_needed == 'true' }}
run: |
image="${{ steps.set_container_tag.outputs.container_image }}"
docker buildx build --platform linux/amd64,linux/arm64 -t ${image} --push .
build_linux_python_lib:
name: Build Python wheels for Linux (${{ matrix.arch.name }})
needs:
- build_prepare
- build_linux_build_container
strategy:
matrix:
arch:
- name: x86_64
runner: ubuntu-22.04
- name: aarch64
runner: ARM64
runs-on: ${{ matrix.arch.runner }}
permissions:
contents: write # for actions/upload-release-asset to upload release asset
defaults:
run:
working-directory: ./connectedhomeip/
container:
image: ${{ needs.build_linux_build_container.outputs.container_image }}
volumes:
- "/tmp/log_output:/tmp/test_logs"
options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
steps:
- name: Restore Matter SDK from artifacts
uses: actions/download-artifact@v4
with:
name: matter-sdk-${{ github.run_id }}
- name: Extract Matter SDK from tar
working-directory: ./
run: |
rm -rf connectedhomeip/
tar -xaf ./connectedhomeip.tar.zst --use-compress-program=zstdmt .
git config --global --add safe.directory "*"
- name: Bootstrap
run: bash scripts/bootstrap.sh -p all,linux
- name: Setup Build, Run Build and Run Tests
run: |
scripts/build/gn_gen.sh --args=" \
chip_project_config_include_dirs=[\"//..\"] \
chip_crypto=\"boringssl\"
enable_rtti=true \
chip_config_memory_debug_checks=false \
chip_config_memory_debug_dmalloc=false \
chip_exchange_node_id_logging=true \
chip_mdns=\"minimal\" \
chip_minmdns_default_policy=\"libnl\" \
chip_python_version=\"${{ needs.build_prepare.outputs.version }}\" \
chip_python_package_prefix=\"home-assistant-chip\" \
chip_python_platform_tag=\"manylinux_2_31\" \
chip_code_pre_generated_directory=\"$(pwd)/zzz_pregenerated\" \
"
scripts/run_in_build_env.sh "ninja -C ./out chip-repl"
- name: Run Python library specific unit tests
run: |
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-manylinux_2_31_${{ matrix.arch.name }}.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_clusters-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_repl-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl'
scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: chip-wheels-linux-${{ matrix.arch.name }}
path: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels as release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_PYPI }}
TWINE_REPOSITORY: "pypi"
run: |
python3 -m pip install twine build
python3 -m twine upload out/controller/python/home_assistant_chip_clusters-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl --skip-existing
python3 -m twine upload out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-manylinux_2_31_${{ matrix.arch.name }}.whl --skip-existing
python3 -m twine upload out/controller/python/home_assistant_chip_repl-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl --skip-existing
- name: Upload wheels to Test PyPI
if: ${{ github.ref == 'refs/heads/main' }}
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_TESTPYPI }}
TWINE_REPOSITORY: "testpypi"
run: |
python3 -m pip install twine build
python3 -m twine upload out/controller/python/home_assistant_chip_clusters-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl --skip-existing
python3 -m twine upload out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-manylinux_2_31_${{ matrix.arch.name }}.whl --skip-existing
python3 -m twine upload out/controller/python/home_assistant_chip_repl-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl --skip-existing
build_macos_python_lib:
name: Build Python wheels for macOS (${{ matrix.arch.name }})
needs: build_prepare
strategy:
matrix:
arch:
- name: arm64
runner: macos-14
runs-on: ${{ matrix.arch.runner }}
permissions:
contents: write # for actions/upload-release-asset to upload release asset
defaults:
run:
working-directory: ./connectedhomeip/
steps:
- name: Checkout build repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Checkout submodules
working-directory: ./connectedhomeip/
run: scripts/checkout_submodules.py --shallow --platform darwin
- name: Apply patches
working-directory: ./connectedhomeip/
run: |
for patch in ../*.patch
do
echo "Applying ${patch}"
patch -p1 < $patch
done
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Bootstrap
working-directory: ./connectedhomeip/
run: bash scripts/bootstrap.sh -p all,darwin
- name: Setup Build, Run Build and Run Tests
run: |
scripts/build/gn_gen.sh --args=" \
chip_crypto=\"boringssl\"
enable_rtti=true \
chip_config_memory_debug_checks=false \
chip_config_memory_debug_dmalloc=false \
chip_mdns=\"minimal\" \
chip_minmdns_default_policy=\"default\" \
chip_python_version=\"${{ needs.build_prepare.outputs.version }}\" \
chip_python_package_prefix=\"home-assistant-chip\" \
chip_python_platform_tag=\"macosx_14_0\" \
"
scripts/run_in_build_env.sh "ninja -C ./out chip-repl"
- name: Run Python library specific unit tests
run: |
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-macosx_14_0_${{ matrix.arch.name }}.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_clusters-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/home_assistant_chip_repl-${{ needs.build_prepare.outputs.version }}-py3-none-any.whl'
scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: chip-wheels-macosx-${{ matrix.arch.name }}
path: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels as release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: connectedhomeip/out/controller/python/*.whl
- name: Upload wheels to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_PYPI }}
TWINE_REPOSITORY: "pypi"
run: |
python3 -m pip install twine build
python3 -m twine upload out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-macosx_14_0_${{ matrix.arch.name }}.whl --skip-existing
- name: Upload wheels to Test PyPI
if: ${{ github.ref == 'refs/heads/main' }}
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_TESTPYPI }}
TWINE_REPOSITORY: "testpypi"
run: |
python3 -m pip install twine build
python3 -m twine upload out/controller/python/home_assistant_chip_core-${{ needs.build_prepare.outputs.version }}-cp37-abi3-macosx_14_0_${{ matrix.arch.name }}.whl --skip-existing