Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ name: Publish Docker
on:
push:
paths:
- '.github/workflows/docker-publish.yml'
- 'docker/*'
- ".github/workflows/docker-publish.yml"
- "docker/*"

workflow_dispatch:
inputs:
push_images:
required: false
type: boolean
default: false
push_images:
required: false
description: "Push the images"
type: boolean
default: false
tools:
required: false
description: "Build the tools image"
type: boolean
default: false

jobs:
publish-matter-extension-dependencies-image:
Expand All @@ -23,7 +29,7 @@ jobs:
id-token: write
steps:
# Checkout repository
- uses: actions/checkout@v4
- uses: actions/checkout@v5

# Login to GitHub Container Registry
- name: Login to GitHub Container Registry
Expand All @@ -36,18 +42,22 @@ jobs:
# Set version variable for tagging the image by reading from docker/version file
- name: Read and print version from docker/version file
run: |
SISDK_Tag=$(grep '^SISDK_Tag=' docker/version | cut -d'=' -f2)
WiFI_SDK_Tag=$(grep '^WiFI_SDK_Tag=' docker/version | cut -d'=' -f2)
VERSION="SiSDK${SISDK_Tag}_WiFi_SDK${WiFI_SDK_Tag}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Parsed VERSION: $VERSION"

# Call docker/build.sh and pass version as an argument
if [[ "${{ github.event.inputs.tools }}" == "false" ]]; then
SISDK_Tag=$(grep '^SISDK_Tag=' docker/version | cut -d'=' -f2)
WiFI_SDK_Tag=$(grep '^WiFI_SDK_Tag=' docker/version | cut -d'=' -f2)
VERSION="SiSDK${SISDK_Tag}_WiFi_SDK${WiFI_SDK_Tag}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Parsed VERSION: $VERSION"
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Version Mismatch: Hardcoded Tag Overrides Computation

The VERSION environment variable is set conditionally but never used. The subsequent build step at line 55 uses a hardcoded tag "25Q4-Tools" instead of the computed VERSION, making this entire step pointless and wasting CI resources parsing the version file.

Fix in Cursor Fix in Web


# Call docker/sdks/build.sh and pass version as an argument
- name: Build and push Docker image
if: ${{ github.event.inputs.tools == false }}
run: |
chmod +x docker/sdks/build.sh
./docker/sdks/build.sh --tag "$VERSION" --push
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unintended Image Pushing

The build step always passes --push flag regardless of the push_images input value. The workflow defines a push_images input but never uses it, so images are always pushed even when push_images is false.

Fix in Cursor Fix in Web

- name: Build and push tools Docker image
if: ${{ github.event.inputs.tools == true }}
run: |
chmod +x docker/build.sh
if [[ "${{ github.event.inputs.push_images }}" == "true" ]]; then
./docker/build.sh --tag "$VERSION" --push
else
./docker/build.sh --tag "$VERSION"
fi
chmod +x docker/tools/build.sh
./docker/tools/build.sh --tag "25Q4-Tools" --push
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Push control ignored

The build step always passes --push flag regardless of the push_images input value. The workflow defines a push_images input but never uses it, so images are always pushed even when push_images is false.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Build Workflow Ignores Config, Incomplete Images.

The workflow unconditionally builds only the tools image with a hardcoded tag, ignoring both the push_images input parameter and the VERSION environment variable set in the previous step. This prevents building SDK images and makes the conditional version parsing logic unused.

Fix in Cursor Fix in Web

59 changes: 5 additions & 54 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,6 @@
#!/usr/bin/env bash

set -e

# Usage: ./build.sh --tag <version> [--push]
PUSH_IMAGE=false
while [[ $# -gt 0 ]]; do
case "$1" in
--tag)
TAG="$2"
shift 2
;;
--push)
PUSH_IMAGE=true
shift
;;
*)
echo "Usage: $0 --tag <version> [--push]"
exit 1
;;
esac
done

if [[ -z "$TAG" ]]; then
echo "ERROR: --tag argument required. Usage: $0 --tag <version> [--push]"
exit 1
fi

# Example TAG: SiSDKv2024.12.1-0.de_WiFi_SDKv3.4.1
# Extract SISDK_Tag and WiFI_SDK_Tag from TAG
SISDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK\([^_]*\)_WiFi_SDK.*$/\1/p')
WiFI_SDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK[^_]*_WiFi_SDK\(.*\)$/\1/p')

if [[ -z "$SISDK_Tag" || -z "$WiFI_SDK_Tag" ]]; then
echo "ERROR: Could not parse SISDK_Tag or WiFI_SDK_Tag from version tag: $TAG"
exit 1
fi

echo "Parsed SISDK_Tag: $SISDK_Tag"
echo "Parsed WiFI_SDK_Tag: $WiFI_SDK_Tag"

# Compose image tag
IMAGE_NAME="ghcr.io/siliconlabssoftware/matter_extension_dependencies"

# Build the Docker image, passing build args
docker build \
--build-arg SISDK_Tag="$SISDK_Tag" \
--build-arg WiFI_SDK_Tag="$WiFI_SDK_Tag" \
-f docker/Dockerfile \
-t "${IMAGE_NAME}:${TAG}" .

# Push the image only if --push was provided
if [[ "$PUSH_IMAGE" == "true" ]]; then
docker push "${IMAGE_NAME}:${TAG}"
# Call docker/sdks/build.sh and pass version as an argument
if [[ "${{ github.event.inputs.tools }}" == "false" ]]; then
./docker/sdks/build.sh --tag "$VERSION"
else
./docker/tools/build.sh --tag "$VERSION"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Fragile External Variable Dependency

The $VERSION variable is referenced but never defined in the script. The script expects this variable to be set in the environment, but there's no guarantee it will be available when the script runs.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Syntax and Undefined Variable Break Script

The script uses GitHub Actions template syntax ${{ github.event.inputs.tools }} which only works within GitHub Actions workflow files. When executed as a standalone shell script, this becomes a literal string that never equals "false", causing the else branch to always execute. Additionally, the VERSION variable is referenced but never defined, causing the script to pass an empty tag argument.

Fix in Cursor Fix in Web

fi
File renamed without changes.
55 changes: 55 additions & 0 deletions docker/sdks/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

set -e

# Usage: ./build.sh --tag <version> [--push]
PUSH_IMAGE=false
while [[ $# -gt 0 ]]; do
case "$1" in
--tag)
TAG="$2"
shift 2
;;
--push)
PUSH_IMAGE=true
shift
;;
*)
echo "Usage: $0 --tag <version> [--push]"
exit 1
;;
esac
done

if [[ -z "$TAG" ]]; then
echo "ERROR: --tag argument required. Usage: $0 --tag <version> [--push]"
exit 1
fi

# Example TAG: SiSDKv2024.12.1-0.de_WiFi_SDKv3.4.1
# Extract SISDK_Tag and WiFI_SDK_Tag from TAG
SISDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK\([^_]*\)_WiFi_SDK.*$/\1/p')
WiFI_SDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK[^_]*_WiFi_SDK\(.*\)$/\1/p')

if [[ -z "$SISDK_Tag" || -z "$WiFI_SDK_Tag" ]]; then
echo "ERROR: Could not parse SISDK_Tag or WiFI_SDK_Tag from version tag: $TAG"
exit 1
fi

echo "Parsed SISDK_Tag: $SISDK_Tag"
echo "Parsed WiFI_SDK_Tag: $WiFI_SDK_Tag"

# Compose image tag
IMAGE_NAME="ghcr.io/siliconlabssoftware/matter_extension_dependencies"

# Build the Docker image, passing build args
docker build \
--build-arg SISDK_Tag="$SISDK_Tag" \
--build-arg WiFI_SDK_Tag="$WiFI_SDK_Tag" \
-f docker/Dockerfile \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Dockerfile Path Mismatch

The Dockerfile path -f docker/Dockerfile is incorrect. Based on the file structure, it should be -f docker/sdks/Dockerfile to reference the SDK-specific Dockerfile in the docker/sdks/ subdirectory.

Fix in Cursor Fix in Web

-t "${IMAGE_NAME}:${TAG}" .

# Push the image only if --push was provided
if [[ "$PUSH_IMAGE" == "true" ]]; then
docker push "${IMAGE_NAME}:${TAG}"
fi
File renamed without changes.
106 changes: 106 additions & 0 deletions docker/tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Set build argument for base image version
ARG VERSION=latest

# Stage 1: Build dependencies and download SDKs/tools
FROM ghcr.io/project-chip/chip-build:${VERSION} AS build
LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip

# Install required packages for cloning and extracting SDKs
RUN set -x \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
git \
git-lfs \
zip \
tar \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& : # last line

# Set UTF-8 locale to ensure unzip handles non-ASCII filenames correctly
# util/third_party/ot-br-posix/third_party/cpp-httplib/repo/test/www/#U65e5#U672c#U8a9eDir/#U65e5#U672c#U8a9eFile.txt
ENV LANG=C.UTF-8

# - name: Setup SLT
# id: setup-action
# uses: SiliconLabsSoftware/action-setup-slt@main
#Setup SLT
RUN set -x \
&& curl https://www.silabs.com/documents/public/software/slt-cli-1.0.0-linux-x64.zip --output /tmp/slt-cli-1.0.0-linux-x64.zip \
&& unzip /tmp/slt-cli-1.0.0-linux-x64.zip -d /tmp/slt-cli \
&& rm /tmp/slt-cli-1.0.0-linux-x64.zip \
&& chmod +x /tmp/slt-cli/slt \
&& : # last line

ENV PATH="${PATH}:/tmp/slt-cli"
ENV SLT_CI=true

RUN set -x \
&& echo "slt-version=$(slt --version)" \
&& echo "slt-path=$(which slt)" \
&& : # last line


RUN set -x \
&& slt install foo --engine conan || true \
&& CONAN_ENGINE_PATH="$HOME/.silabs/slt/engines/conan/conan_engine" \
&& CONAN_PATH="$HOME/.silabs/slt/engines/conan/conan/conan" \
&& INSTALL_PATH="$HOME/.local/bin" \
&& if [ -f "$CONAN_ENGINE_PATH" ]; then \
ln -s "$CONAN_ENGINE_PATH" "$INSTALL_PATH/conan_engine" \
else \
echo "Error: conan_engine not found at $CONAN_ENGINE_PATH" \
exit 1 \
fi \
&& echo "conan-engine-version=$(conan_engine --version)" \
&& echo "conan-engine-path=$(which conan_engine)" \
&& if [ -f "$CONAN_PATH" ]; then \
ln -s "$CONAN_PATH" "$INSTALL_PATH/conan" \
else \
echo "Error: conan not found at $CONAN_PATH" \
fi \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing dependency doesn't halt build.

When conan is not found at the expected path, the error message is printed but the script continues without exiting (missing exit 1), unlike the conan_engine check above. This inconsistency means the build continues even when conan installation fails.

Fix in Cursor Fix in Web

&& echo "conan-version=$(conan --version)" \
&& echo "conan-path=$(which conan)" \
&& echo "CONAN_HOME=$HOME/.silabs/slt/installs/conan" \
&& : # last line

ENV CONAN_HOME=$HOME/.silabs/slt/installs/conan

RUN set -x \
&& slt install slc-cli \
&& SLC_CLI_PATH=$(slt where slc-cli) \
&& echo "SLC_CLI_PATH=$SLC_CLI_PATH" \
&& JAVA_HOME=$(slt where java21) \
&& echo "JAVA_HOME=$JAVA_HOME" \
&& echo "$SLC_CLI_PATH" >> $GITHUB_PATH \
&& if [ -n "$JAVA_HOME" ]; then \
echo "$JAVA_HOME/jre/bin" >> $GITHUB_PATH \
fi \
&& : # last line

ENV SLC_CLI_PATH=$(slt where slc-cli)
ENV JAVA_HOME=$(slt where java21)
ENV PATH="${PATH}:${SLC_CLI_PATH}"
ENV PATH="${PATH}:${JAVA_HOME}/jre/bin"


RUN set -x \
&& slt install commander \
&& COMMANDER_PATH=$(slt where commander) \
&& echo "COMMANDER_PATH=$COMMANDER_PATH" \
&& echo "$COMMANDER_PATH" >> $GITHUB_PATH \
&& : # last line

ENV COMMANDER_PATH=$(slt where commander)
ENV PATH="${PATH}:${COMMANDER_PATH}"


RUN set -x \
&& slt install gcc-arm-none-eabi \
&& ARM_GCC_DIR=$(slt where gcc-arm-none-eabi) \
&& echo "ARM_GCC_DIR=$ARM_GCC_DIR" \
&& echo "$ARM_GCC_DIR/bin" >> $GITHUB_PATH \
&& : # last line

ENV ARM_GCC_DIR=$(slt where gcc-arm-none-eabi)
ENV PATH="${PATH}:${ARM_GCC_DIR}/bin"
55 changes: 55 additions & 0 deletions docker/tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

set -e

# Usage: ./build.sh --tag <version> [--push]
PUSH_IMAGE=false
while [[ $# -gt 0 ]]; do
case "$1" in
--tag)
TAG="$2"
shift 2
;;
--push)
PUSH_IMAGE=true
shift
;;
*)
echo "Usage: $0 --tag <version> [--push]"
exit 1
;;
esac
done

if [[ -z "$TAG" ]]; then
echo "ERROR: --tag argument required. Usage: $0 --tag <version> [--push]"
exit 1
fi

# Example TAG: SiSDKv2024.12.1-0.de_WiFi_SDKv3.4.1
# Extract SISDK_Tag and WiFI_SDK_Tag from TAG
SISDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK\([^_]*\)_WiFi_SDK.*$/\1/p')
WiFI_SDK_Tag=$(echo "$TAG" | sed -n 's/^SiSDK[^_]*_WiFi_SDK\(.*\)$/\1/p')

if [[ -z "$SISDK_Tag" || -z "$WiFI_SDK_Tag" ]]; then
echo "ERROR: Could not parse SISDK_Tag or WiFI_SDK_Tag from version tag: $TAG"
exit 1
fi

echo "Parsed SISDK_Tag: $SISDK_Tag"
echo "Parsed WiFI_SDK_Tag: $WiFI_SDK_Tag"

# Compose image tag
IMAGE_NAME="ghcr.io/siliconlabssoftware/matter_extension_dependencies"

# Build the Docker image, passing build args
docker build \
--build-arg SISDK_Tag="$SISDK_Tag" \
--build-arg WiFI_SDK_Tag="$WiFI_SDK_Tag" \
-f docker/Dockerfile \
-t "${IMAGE_NAME}:${TAG}" .

# Push the image only if --push was provided
if [[ "$PUSH_IMAGE" == "true" ]]; then
docker push "${IMAGE_NAME}:${TAG}"
fi
9 changes: 9 additions & 0 deletions docker/tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# codegen.py build requirements
Jinja2==3.1.3
lark==1.1.7
# Sphinx dependencies (for slc-cli)
linkify-it-py==2.0.2
myst-parser==2.0.0
Sphinx==7.2.6
sphinx-rtd-theme==1.3.0
sphinx-tabs==3.4.1
Loading