Update Matter SDK to e402b96fff
#537
This file contains 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: CHIP wheels build | |
on: | |
push: | |
branches: | |
- main | |
- release | |
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 | |
else | |
echo "No changes to Dockerfile; using container from base branch." | |
tag="${{ github.base_ref }}" | |
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 |