Skip to content

Commit dbf7de6

Browse files
MATTER-7126 : Use docker for SLT CLI (#1126)
* MATTER-7126 : Use docker for SLT CLI (#1109)
1 parent 6111f25 commit dbf7de6

4 files changed

Lines changed: 47 additions & 15 deletions

File tree

‎.github/actions/cache-tools/action.yaml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,26 @@ runs:
3131
run: |
3232
echo "cache-key=silabs-zap-slt-tools-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}" >> $GITHUB_OUTPUT
3333
34-
- name: Restore ZAP and SLT tools cache
34+
- name: Restore ZAP, SLT and Tools cache
3535
id: cache
3636
uses: actions/cache/restore@v5
3737
with:
3838
path: |
3939
/tmp/zap-linux-x64
4040
/home/runner/.silabs/slt
4141
/home/runner/.local/bin/slt
42+
/home/runner/.local/bin/conan
43+
/home/runner/.local/bin/conan_engine
4244
key: ${{ steps.compute-cache-key.outputs.cache-key }}
4345

4446
- name: Set env and paths from cache
4547
if: steps.cache.outputs.cache-hit == 'true'
4648
shell: bash
4749
run: |
48-
echo "CONAN_HOME=~/.silabs/slt/installs/conan" >> $GITHUB_ENV
50+
echo "CONAN_HOME=/home/runner/.silabs/slt/installs/conan" >> $GITHUB_ENV
4951
echo "STUDIO_ADAPTER_PACK_PATH=/tmp/zap-linux-x64" >> $GITHUB_ENV
5052
echo "SLT_PATH=/home/runner/.local/bin/slt" >> $GITHUB_ENV
53+
echo "SLT_CI=true" >> $GITHUB_ENV
5154
echo "/tmp/zap-linux-x64" >> $GITHUB_PATH
5255
echo "/home/runner/.silabs/slt/bin" >> $GITHUB_PATH
5356
echo "/home/runner/.local/bin" >> $GITHUB_PATH
@@ -75,12 +78,14 @@ runs:
7578
if: steps.cache.outputs.cache-hit != 'true'
7679
uses: ./.github/actions/install-tools
7780

78-
- name: Save ZAP and SLT tools cache
81+
- name: Save ZAP, SLT and Tools cache
7982
if: steps.cache.outputs.cache-hit != 'true'
8083
uses: actions/cache/save@v5
8184
with:
8285
path: |
8386
/tmp/zap-linux-x64
8487
/home/runner/.silabs/slt
8588
/home/runner/.local/bin/slt
89+
/home/runner/.local/bin/conan
90+
/home/runner/.local/bin/conan_engine
8691
key: ${{ steps.compute-cache-key.outputs.cache-key }}

‎.github/actions/install-tools/action.yaml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,25 @@ runs:
1919
2020
- name: Setup SLT
2121
id: setup-action
22-
uses: SiliconLabsSoftware/action-setup-slt@v2
22+
shell: bash
23+
env:
24+
SLT_IMAGE: ghcr.io/siliconlabssoftware/slt-cli:1.2.2
25+
SLT_CI: "true"
26+
run: |
27+
INSTALL_PATH="$HOME/.local/bin"
28+
mkdir -p "$INSTALL_PATH"
29+
cid=$(docker create "$SLT_IMAGE")
30+
docker cp "$cid:/opt/silabs/slt/slt" "$INSTALL_PATH/slt"
31+
docker rm "$cid"
32+
chmod +x "$INSTALL_PATH/slt"
33+
echo "$INSTALL_PATH" >> $GITHUB_PATH
34+
echo "SLT_CI=true" >> $GITHUB_ENV
35+
36+
"$INSTALL_PATH/slt" install conan
37+
ln -fs "$HOME/.silabs/slt/engines/conan/conan_engine" "$INSTALL_PATH/conan_engine"
38+
ln -fs "$HOME/.silabs/slt/engines/conan/conan/conan" "$INSTALL_PATH/conan"
39+
echo "slt-path=$INSTALL_PATH/slt" >> $GITHUB_OUTPUT
40+
echo "conan-path=$INSTALL_PATH/conan" >> $GITHUB_OUTPUT
2341
2442
- name: Set Environment Variables
2543
shell: bash

‎requirements.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
python-dotenv
2-
dload
32
pyyaml

‎slc/sl_setup_env.py‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import logging
3939
import os
4040
import sys
41-
import dload
4241
import stat
4342
import subprocess
4443
import shutil
@@ -140,16 +139,27 @@ def remove_tools_directory(self):
140139
sys.exit(1)
141140
tools.mkdir(parents=True, exist_ok=True)
142141

142+
def _download_file(self, url, destination):
143+
"""Download url to destination with curl (www.silabs.com only allows curl for scripted downloads)."""
144+
subprocess.run(["curl", "-fsSL", url, "-o", destination], check=True)
145+
146+
def _download_and_extract_zip(self, url, destination):
147+
"""Download a ZIP archive and extract it into destination."""
148+
zip_path = destination + ".zip"
149+
try:
150+
self._download_file(url, zip_path)
151+
with ZipFile(zip_path, 'r') as zObject:
152+
zObject.extractall(path=destination)
153+
finally:
154+
if os.path.exists(zip_path):
155+
os.remove(zip_path)
156+
143157
def download_and_extract_slt_cli(self):
144158
"""Download and extract SLT CLI tool."""
145159
if not os.path.isfile(self.slt_cli_path):
146160
logging.info(f"Downloading and unzipping slt-cli...")
147-
slt_zip_path = os.path.join(self.tools_folder_path, "slt.zip")
148161
try:
149-
dload.save(self.slt_cli_url, slt_zip_path)
150-
with ZipFile(slt_zip_path, 'r') as zObject:
151-
zObject.extractall(path=self.tools_folder_path)
152-
os.remove(slt_zip_path)
162+
self._download_and_extract_zip(self.slt_cli_url, self.tools_folder_path)
153163
if self.platform != "win32":
154164
self._make_executable(self.slt_cli_path)
155165
except Exception as e:
@@ -178,18 +188,18 @@ def download_and_extract_zap(self, install_without_checking=False):
178188
try:
179189
if self.platform == "darwin":
180190
zap_zip = self.zap_path + ".zip"
181-
dload.save(zap_url, zap_zip)
191+
self._download_file(zap_url, zap_zip)
182192
subprocess.run(["unzip", zap_zip, "-d", self.zap_path], check=True)
183193
os.remove(zap_zip)
184194
self._make_executable(zap_cli_path)
185195
zap_root = os.path.join(self.zap_path, "zap.app", "Contents", "MacOS", "zap")
186196
self._make_executable(zap_root)
187197
elif self.platform == "linux":
188-
dload.save_unzip(zap_url, os.path.join(self.tools_folder_path, "zap"), delete_after=True)
198+
self._download_and_extract_zip(zap_url, self.zap_path)
189199
self._make_executable(zap_cli_path)
190-
self._make_executable(os.path.join(self.tools_folder_path, "zap", "zap"))
200+
self._make_executable(os.path.join(self.zap_path, "zap"))
191201
elif self.platform == "win32":
192-
dload.save_unzip(zap_url, os.path.join(self.tools_folder_path, "zap"), delete_after=True)
202+
self._download_and_extract_zip(zap_url, self.zap_path)
193203
except Exception as e:
194204
logging.error(f"Failed to download/extract zap: {e}")
195205
sys.exit(1)

0 commit comments

Comments
 (0)