Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
95 changes: 95 additions & 0 deletions .github/actions/cache-sdks/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Cache SDKs
description: Restore simplicity_sdk and wifi_sdk from cache. On miss, checkout, LFS-pull, and save so later jobs reuse it.

inputs:
working-directory:
description: Repository root that contains .gitmodules and the SDK submodule paths.
required: false
default: "."

outputs:
cache-key:
value: ${{ steps.compute-cache-key.outputs.cache-key }}
cache-hit:
value: ${{ steps.cache.outputs.cache-hit }}

runs:
using: "composite"
steps:
- name: Compute SDK cache key
id: compute-cache-key
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
SCOPE="${{ github.base_ref }}"
else
SCOPE="${{ github.ref_name }}"
fi

SISDK_TAG=$(git config -f .gitmodules --get submodule.third_party/simplicity_sdk.tag)
SISDK_SHA=$(git rev-parse HEAD:third_party/simplicity_sdk)
WIFI_SHA=$(git rev-parse HEAD:third_party/wifi_sdk)

CACHE_KEY="silabs-sdks-${{ runner.os }}-${{ runner.arch }}-${SCOPE}-${SISDK_TAG}-${SISDK_SHA:0:12}-${WIFI_SHA:0:12}"

echo "cache-key=${CACHE_KEY}" >> "$GITHUB_OUTPUT"
echo "SDK cache key: ${CACHE_KEY}"

- name: Restore SDK cache
id: cache
uses: actions/cache/restore@v5
with:
path: /tmp/silabs-sdks.tar
key: ${{ steps.compute-cache-key.outputs.cache-key }}

- name: Extract SDKs from cache
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail
rm -rf third_party/simplicity_sdk third_party/wifi_sdk
tar -xf /tmp/silabs-sdks.tar
rm -f /tmp/silabs-sdks.tar
echo "Restored simplicity_sdk and wifi_sdk from cache"
du -sh third_party/simplicity_sdk third_party/wifi_sdk

- name: Checkout SDKs and pull LFS
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail
git lfs install
GIT_LFS_SKIP_SMUDGE=1 git submodule update --init --depth 1 \
third_party/simplicity_sdk third_party/wifi_sdk
git -C third_party/simplicity_sdk lfs pull
git -C third_party/wifi_sdk lfs pull
echo "Checked out simplicity_sdk and wifi_sdk"
du -sh third_party/simplicity_sdk third_party/wifi_sdk

- name: Pack SDK working trees
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail
tar --exclude='.git' -cf /tmp/silabs-sdks.tar \
third_party/simplicity_sdk \
third_party/wifi_sdk
ls -lh /tmp/silabs-sdks.tar

- name: Save SDK cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: /tmp/silabs-sdks.tar
key: ${{ steps.compute-cache-key.outputs.cache-key }}

- name: Remove SDK tarball
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: rm -f /tmp/silabs-sdks.tar
17 changes: 12 additions & 5 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: "true"
lfs: true
submodules: false

- name: Pull LFS objects in submodules
- name: Initialize non-SDK submodules
run: |
git -C third_party/simplicity_sdk lfs pull
git -C third_party/wifi_sdk lfs pull
set -euo pipefail
mapfile -t paths < <(
git config --file .gitmodules --get-regexp '^submodule\..*\.path$' \
| awk '{print $2}' \
| grep -vE 'third_party/simplicity_sdk$|third_party/wifi_sdk$|third_party/third_party_hw_drivers_extension$'
)
git submodule update --init --depth 1 -- "${paths[@]}"

- name: Cache SDKs
uses: ./.github/actions/cache-sdks

- name: Cache tools
uses: ./.github/actions/cache-tools
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/cache-sdks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Seed SDK cache

on:
push:
branches:
- main
- "release_*"
paths:
- .gitmodules
- third_party/simplicity_sdk
- third_party/wifi_sdk
workflow_dispatch:

permissions:
contents: read
actions: write

jobs:
check-branch:
name: Require main or release_*
runs-on: ubuntu-latest
steps:
- name: Verify branch
run: |
set -euo pipefail
if [[ "${{ github.ref_name }}" != "main" && ! "${{ github.ref_name }}" =~ ^release_ ]]; then
echo "Seed SDK cache can only run on main or release_*. Current ref: ${{ github.ref_name }}"
exit 1
fi

cache-sdks:
name: Seed simplicity_sdk and wifi_sdk cache
needs: check-branch
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-sdks.outputs.cache-key }}
cache-hit: ${{ steps.cache-sdks.outputs.cache-hit }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: false
- name: Cache SDKs
id: cache-sdks
uses: ./.github/actions/cache-sdks

delete-previous-sdk-cache:
name: Delete previous SDK cache
needs: cache-sdks
if: always() && needs.cache-sdks.result == 'success'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete old branch cache and PR SDK caches
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SDK_CACHE_KEY: ${{ needs.cache-sdks.outputs.cache-key }}
CACHE_HIT: ${{ needs.cache-sdks.outputs.cache-hit }}
run: |
set -euo pipefail
if [[ -z "${SDK_CACHE_KEY}" ]]; then
echo "No SDK cache key; skipping"
exit 0
fi

CURRENT_REF="${{ github.ref }}"
echo "Seed cache-hit=${CACHE_HIT}"
echo "Required SDK cache key: ${SDK_CACHE_KEY}"
echo "Current ref: ${CURRENT_REF}"

CACHES=$(gh cache list --repo "${{ github.repository }}" --json id,key,ref --limit 100)
echo "${CACHES}" | jq -c '.[] | select(.key | startswith("silabs-sdks-"))'

persisted=$(echo "${CACHES}" | jq --arg key "${SDK_CACHE_KEY}" --arg ref "${CURRENT_REF}" \
'[.[] | select(.key == $key and .ref == $ref)] | length')
if [[ "${persisted}" -eq 0 ]]; then
echo "New key is not listed on ${CURRENT_REF}."
echo "actions/cache/save can succeed without persisting (soft-lock/reserve failure)."
echo "Keeping previous main/release_* caches."
exit 1
fi

echo "${CACHES}" | jq -c '.[] | select(.key | startswith("silabs-sdks-"))' \
| while read -r entry; do
id=$(echo "${entry}" | jq -r '.id')
key=$(echo "${entry}" | jq -r '.key')
ref=$(echo "${entry}" | jq -r '.ref')
if [[ "${ref}" == "${CURRENT_REF}" && "${key}" != "${SDK_CACHE_KEY}" ]]; then
echo "Deleting previous SDK cache id=${id} ref=${ref} key=${key}"
gh cache delete "${id}" --repo "${{ github.repository }}" || echo "Failed to delete ${id}"
elif [[ "${ref}" != "refs/heads/main" && ! "${ref}" =~ ^refs/heads/release_ ]]; then
echo "Deleting PR SDK cache id=${id} ref=${ref} key=${key}"
gh cache delete "${id}" --repo "${{ github.repository }}" || echo "Failed to delete ${id}"
else
echo "Keeping SDK cache id=${id} ref=${ref} key=${key}"
fi
done
42 changes: 30 additions & 12 deletions .github/workflows/code-size-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Code Size Check
permissions:
contents: read
pull-requests: read
actions: write

on:
workflow_dispatch:
Expand Down Expand Up @@ -57,29 +58,46 @@ jobs:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: "true"
lfs: true
submodules: false

- name: Pull LFS objects in submodules
- name: Initialize non-SDK submodules
run: |
git -C third_party/simplicity_sdk lfs pull
git -C third_party/wifi_sdk lfs pull
set -euo pipefail
mapfile -t paths < <(
git config --file .gitmodules --get-regexp '^submodule\..*\.path$' \
| awk '{print $2}' \
| grep -vE 'third_party/simplicity_sdk$|third_party/wifi_sdk$|third_party/third_party_hw_drivers_extension$'
)
git submodule update --init --depth 1 -- "${paths[@]}"

- name: Install tools
uses: ./.github/actions/install-tools
- name: Cache SDKs
uses: ./.github/actions/cache-sdks

- name: Cache tools
uses: ./.github/actions/cache-tools

- name: Checkout baseline for comparison
uses: actions/checkout@v7
with:
ref: ${{ env.BASELINE }}
path: baseline
submodules: "true"
lfs: true
submodules: false

- name: Pull LFS objects in submodules
- name: Initialize non-SDK submodules (baseline)
working-directory: baseline
run: |
git -C baseline/third_party/simplicity_sdk lfs pull
git -C baseline/third_party/wifi_sdk lfs pull
set -euo pipefail
mapfile -t paths < <(
git config --file .gitmodules --get-regexp '^submodule\..*\.path$' \
| awk '{print $2}' \
| grep -vE 'third_party/simplicity_sdk$|third_party/wifi_sdk$|third_party/third_party_hw_drivers_extension$'
)
git submodule update --init --depth 1 -- "${paths[@]}"

- name: Cache SDKs (baseline)
uses: ./.github/actions/cache-sdks
with:
working-directory: baseline
- name: Build code-canary app
uses: SiliconLabsSoftware/matter_build_action@v2
with:
Expand Down
Loading
Loading