-
Notifications
You must be signed in to change notification settings - Fork 27
176 lines (167 loc) · 8.95 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
name: CHIP wheels build
on: push
env:
matter_sdk_ref: v1.2.0.1
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@v3
with:
fetch-depth: 0
- name: Get version
id: version
shell: bash
run: |
version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}')
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then
version="${{ github.event.inputs.version }}"
elif [[ "${version}" =~ (main|dev) ]]; then
today="$(date --utc '+%Y-%m-%d')"
midnight_timestamp="$(date --utc +%s --date=$today)"
calver_date="$(date --utc --date=$today '+%Y.%-m.dev%-d')"
commit_count="$(git rev-list --count --since=$midnight_timestamp HEAD)"
commit_count="$(printf "%02d" ${commit_count})"
version="${calver_date}${commit_count}"
elif [[ "${{ github.ref }}" =~ ^refs/heads/ ]]; then
today="$(date --utc '+%Y-%m-%d')"
midnight_timestamp="$(date --utc +%s --date=$today)"
calver_date="$(date --utc --date=$today '+%Y.%-m.dev%-d')"
# Remove invalid chars
localversion="${version}"
localversion="${localversion//-/}"
localversion="${localversion//_/}"
version="${calver_date}+${localversion}"
fi
echo "Building version $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Checkout CHIP SDK repository
uses: actions/checkout@v3
with:
repository: project-chip/connectedhomeip
ref: ${{ env.matter_sdk_ref }}
path: ./project-chip
- name: Checkout submodules
working-directory: ./project-chip
run: scripts/checkout_submodules.py --shallow --platform linux
- name: Apply patches
working-directory: ./project-chip
run: |
for patch in ../*.patch
do
echo "Applying ${patch}"
patch -p1 < $patch
done
- name: Bootstrap
working-directory: ./project-chip
run: bash scripts/bootstrap.sh
- name: ZAP Code pre-generation
working-directory: ./project-chip
run: scripts/run_in_build_env.sh "scripts/codepregen.py ./zzz_pregenerated/"
- name: Create Matter SDK tar
working-directory: ./project-chip
run: tar -caf ../project-chip.tar.zst --exclude .environment --use-compress-program=zstdmt .
- name: Store Matter SDK as artifact
uses: actions/upload-artifact@v3
with:
name: matter-sdk-${{ github.run_id }}
path: ./project-chip.tar.zst
build_linux_python_lib:
name: Build Python wheels for Linux (${{ matrix.arch.name }})
needs: build_prepare
strategy:
matrix:
arch:
- name: x86_64
container: ghcr.io/project-chip/chip-build:1
runner: ubuntu-22.04
- name: aarch64
container: docker.io/agners/aarch64-chip-build:1
runner: ARM64
runs-on: ${{ matrix.arch.runner }}
permissions:
contents: write # for actions/upload-release-asset to upload release asset
defaults:
run:
working-directory: ./project-chip
container:
image: ${{ matrix.arch.container }}
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@v3
with:
name: matter-sdk-${{ github.run_id }}
- name: Extract Matter SDK from tar
working-directory: ./
run: |
rm -rf project-chip
mkdir -p project-chip
cd project-chip
apt update && apt install zstd
tar -xaf ../project-chip.tar.zst --use-compress-program=zstdmt .
git config --global --add safe.directory "*"
rm -rf out/
- name: Bootstrap
run: bash scripts/bootstrap.sh
- name: Setup Build, Run Build and Run Tests
run: |
scripts/build/gn_gen.sh --args=" \
enable_rtti=true \
enable_pylib=true \
chip_config_memory_debug_checks=false \
chip_config_memory_debug_dmalloc=false \
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@v3
with:
name: chip-wheels-${{ matrix.arch.name }}
path: project-chip/out/controller/python/*.whl
- name: Upload wheels as release assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: project-chip/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