Skip to content

Update matter_sdk Submodule #51

Update matter_sdk Submodule

Update matter_sdk Submodule #51

name: Update matter_sdk Submodule
permissions:
contents: read
on:
schedule:
- cron: '0 5 * * *' # Daily at midnight
workflow_dispatch:
jobs:
set_target_branches:
runs-on: ubuntu-latest
outputs:
target_branches: ${{ steps.branches.outputs.value }}
steps:
- id: branches
run: |
if [ "$EVENT_NAME" == "schedule" ]; then
echo 'value=["main","release_2.8-1.5"]' >> $GITHUB_OUTPUT
else
echo "value=[\"$REF_NAME\"]" >> $GITHUB_OUTPUT
fi
env:
EVENT_NAME: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
update-matter_sdk:
runs-on: ubuntu-latest
needs: set_target_branches
strategy:
matrix:
target_branch: ${{ fromJson(needs.set_target_branches.outputs.target_branches) }}
steps:
- name: Checkout target branch
uses: actions/checkout@v6
with:
ref: ${{ matrix.target_branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update matter_sdk submodule
uses: SiliconLabsSoftware/matter_update_submodules@main
with:
target_branch: ${{ matrix.target_branch }}
app-id: ${{ vars.SILABSSW_MATTER_CI_BOT_APP_ID }}
private-key: ${{ secrets.SILABSSW_MATTER_CI_BOT_APP_PRIVATE_KEY }}
run-slc-scripts:
runs-on: ubuntu-latest
needs: [set_target_branches, update-matter_sdk]
strategy:
matrix:
target_branch: ${{ fromJson(needs.set_target_branches.outputs.target_branches) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Generate GitHub App token
id: app_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.SILABSSW_MATTER_CI_BOT_APP_ID }}
private-key: ${{ secrets.SILABSSW_MATTER_CI_BOT_APP_PRIVATE_KEY }}
- name: Find matter_sdk submodule bump PR
id: find_pr
run: |
want="update-matter-sdk-$TARGET_BRANCH"
PR=$(gh pr list --repo "$REPO" --base "$TARGET_BRANCH" --state open --json number,headRefName | jq -r --arg h "$want" '.[] | select(.headRefName == $h or (.headRefName | endswith(":" + $h))) | "\(.number) \(.headRefName)"' | head -1)
if [ -z "$PR" ]; then
echo "pr_number=" >> $GITHUB_OUTPUT
echo "head_ref=" >> $GITHUB_OUTPUT
echo "No open matter_sdk submodule bump PR found for base $TARGET_BRANCH (expected head: $want); skipping SLC scripts."
exit 0
fi
read -r pr_num head_ref <<< "$PR"
echo "pr_number=$pr_num" >> $GITHUB_OUTPUT
echo "head_ref=$head_ref" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
REPO: ${{ github.repository }}
TARGET_BRANCH: ${{ matrix.target_branch }}
- name: Checkout PR branch
if: steps.find_pr.outputs.pr_number != ''
uses: actions/checkout@v6
with:
ref: ${{ steps.find_pr.outputs.head_ref }}
token: ${{ steps.app_token.outputs.token }}
fetch-depth: 0
- name: Init submodules
if: steps.find_pr.outputs.pr_number != ''
run: git submodule update --init third_party/matter_sdk
- name: Set up Python
if: steps.find_pr.outputs.pr_number != ''
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install Python deps for SLC scripts
if: steps.find_pr.outputs.pr_number != ''
run: |
pip install pyyaml
- name: "Run SLC scripts"
if: steps.find_pr.outputs.pr_number != ''
run: python3 slc/script/run_sdk_update_scripts.py
- name: Check for changes
if: steps.find_pr.outputs.pr_number != ''
id: changes
run: |
COUNT=$(git status --porcelain | wc -l | tr -d ' ')
echo "dirty=$([ "$COUNT" -gt 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Commit and push SLC updates
if: steps.find_pr.outputs.pr_number != '' && steps.changes.outputs.dirty == 'true'
run: |
git config user.name "silabs-matter-ci-bot[bot]"
git config user.email "silabs-matter-ci-bot[bot]@users.noreply.github.com"
git add -A
git commit -m "Run component update scripts after matter_sdk submodule update"
git push
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
- name: Update PR description with manual steps
if: steps.find_pr.outputs.pr_number != ''
run: |
PR_NUM="${{ steps.find_pr.outputs.pr_number }}"
BODY=$(gh pr view "$PR_NUM" --json body -q .body)
BODY="${BODY:-}"
if [[ "$BODY" == *"## Manual examination steps"* ]]; then
echo "PR description already includes manual examination steps; skipping."
exit 0
fi
MANUAL_STEPS='
## Manual examination steps
1. Use the above matter_sdk diff link to see what changed. Note which files were added or deleted and see if they were dealt with in the previous steps. If not, update components:
- Changes under `./src` may affect `slc/component/matter-core-sdk`.
- Platform changes under `./src/platform/silabs` and `./examples/platform/silabs` affect `slc/component/matter-platform`.
- Non-Silabs platform changes can be ignored.
2. Note if GN build flags or their usage changed, update component config defines if needed.
3. Analyze PR CI results.
4. Analyze build failures if any, and update component definitions to add/remove files affected by the SDK update until CI passes.'
{ echo "$BODY"; echo "$MANUAL_STEPS"; } > pr_body.md
gh pr edit "$PR_NUM" --body-file pr_body.md
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}