Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
95436cd
CHAD-17076: zigbee-sound-sensor lazy load subdrivers
aleclorimer Nov 17, 2025
11f6667
Driver tests
aleclorimer Mar 10, 2026
95ec1bc
nop
aleclorimer Mar 11, 2026
f581581
nop
aleclorimer Mar 11, 2026
ae7c8c5
nop
aleclorimer Mar 11, 2026
79231ab
nop
aleclorimer Mar 11, 2026
314dc07
nop
aleclorimer Mar 11, 2026
54f092c
nop
aleclorimer Mar 11, 2026
861cac4
nop
aleclorimer Mar 11, 2026
cfc657f
nop
aleclorimer Mar 11, 2026
104ba0b
nop
aleclorimer Mar 11, 2026
a391db6
nop
aleclorimer Mar 11, 2026
2674a49
nop
aleclorimer Mar 11, 2026
7bb7920
nop
aleclorimer Mar 11, 2026
9c6227c
nop
aleclorimer Mar 11, 2026
481125e
nop
aleclorimer Mar 11, 2026
ba50772
nop
aleclorimer Mar 11, 2026
ffd7c7a
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
7c9a636
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
9c37ee6
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
d52e146
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
4a0fc32
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
10801d6
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
439aae0
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
6635933
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
f9d45c9
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
306ead0
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
6c08357
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
6f54631
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
ffe1687
Just trying to get test-results working for matrixs
aleclorimer Mar 11, 2026
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
26 changes: 19 additions & 7 deletions .github/workflows/publish-test-results.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
name: Publish test results
on:
workflow_run:
workflows: [Run driver tests]
types:
- completed
workflow_call:

jobs:
get-versions:
uses: ./.github/workflows/test-versions.yml

publish-test-results:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [ get-versions ]
strategy:
matrix:
version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v6
with:
workflow: run-tests.yml
run_id: ${{ github.event.workflow_run.id }}
run_id: ${{ github.event.workflow_call.id }}
# Unless filtered, this will grab all files for all versions
- run: echo "pr_number=$(cat pr_number/pr_number.txt)" >> $GITHUB_ENV
- name: Show downloaded artifacts
run: |
echo "Workspace:"
pwd
echo "Files:"
find . -maxdepth 3 -type f
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event-file/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "tests/*.xml"
files: "tests-${{ matrix.version }}/*.xml"
- name: Publish coverage results
uses: 5monkeys/cobertura-action@master
with:
pull_request_number: ${{ env.pr_number }}
path: "coverage/*.xml"
path: "coverage-${{ matrix.version }}/*.xml"
minimum_coverage: 90
132 changes: 89 additions & 43 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,142 @@ on:
- 'drivers/**'

jobs:

get-versions:
uses: ./.github/workflows/test-versions.yml

# Two separate jobs for finding the right artifact to run tests with
get-latest-release-artifact:
runs-on: ubuntu-latest
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'release') }}
outputs:
cache_key: ${{ steps.cache_key.outputs.CACHE_KEY }}
if: ${{ always() }}
needs: [ get-versions ]
strategy:
matrix:
version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
max-parallel: 1
fail-fast: false

steps:
- name: Find the lua lib release version
- name: Find the lua lib release version for 0.${{ matrix.version }}
id: lib-version
run: |
curl "https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}' > test.log
echo "url=$(cat test.log)" >> $GITHUB_OUTPUT
curl -s \
-L https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/releases \
-L https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/releases?page=2 \
-L https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/releases?page=3 \
| grep -oP "/.*/releases/tag/apiv\d+_${{ matrix.version }}(_beta)?" > version_${{ matrix.version }}_link.log
echo "https://github.com$(cat version_${{ matrix.version }}_link.log)" > version_${{ matrix.version }}_link.log
echo "Found release at $(cat version_${{ matrix.version }}_link.log)"
echo "url=$(cat version_${{ matrix.version }}_link.log)" >> $GITHUB_OUTPUT
grep -oP 'apiv\K\d+_\d+(_beta)?' version_${{ matrix.version }}_link.log | while IFS='_' read -r api_version hc_version rest; do
echo "api_version=$api_version" >> $GITHUB_OUTPUT
[[ -n $rest ]] && hc_version="${hc_version}_${rest}"
echo "hc_version=$hc_version" >> $GITHUB_OUTPUT
done
- name: Try to retrieve cache
id: cached-libs
uses: actions/cache@v3
with:
path: '/home/runner/work/lua_libs'
key: ${{ steps.lib-version.outputs.url }}-v1
path: '/home/runner/work/lua_libs_${{ matrix.version }}'
key: lua_libs_${{ matrix.version }}
- name: Get the latest release artifact
if: steps.cached-libs.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@master
with:
version: 'tags/apiv${{ steps.lib-version.outputs.api_version }}_${{ steps.lib-version.outputs.hc_version }}'
file: 'lua_libs.*'
regex: true
target: '/home/runner/work/lua_libs/'
target: '/home/runner/work/lua_libs_${{ matrix.version }}/'
- name: Extract the lua libraries
if: steps.cached-libs.outputs.cache-hit != 'true'
working-directory: '/home/runner/work/lua_libs'
working-directory: '/home/runner/work/lua_libs_${{ matrix.version }}'
run: tar -xf *.tar.gz --wildcards -C . --strip-components=1 '*.lua'
- name: Set output
id: cache_key
run: echo "CACHE_KEY=${{ steps.lib-version.outputs.url }}-v1" >> $GITHUB_OUTPUT
- name: Verify lua_libs directory
run: cat /home/runner/work/lua_libs_${{ matrix.version }}/version.lua | grep -oP "api = \d+"
- name: Save lua libs cache
if: steps.cached-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /home/runner/work/lua_libs_${{ matrix.version }}
key: lua_libs_${{ matrix.version }}

get-dev-artifact:
get-dev-artifacts:
runs-on: ubuntu-latest
if: ${{ false }}
needs: [ get-versions ]
outputs:
cache_key: ${{ steps.cache_key.outputs.CACHE_KEY }}
if: ${{ contains(join(github.event.pull_request.labels.*.name), 'release-') && github.event.pull_request.head.repo.fork != 'true' }}
strategy:
matrix:
version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
fail-fast: false
steps:
- name: Get the version from the label
id: label-version
run: |
echo "${{ join(github.event.pull_request.labels.*.name) }}" | grep -oP "release-\d+.\d+" | xargs > out
echo "LIBRARY_VERSION=$(cat out)" >> $GITHUB_OUTPUT
mkdir /home/runner/work/lua_libs
- name: Find latest artifact
- name: Make lua_libs_${{ matrix.version }} directory
run: mkdir /home/runner/work/lua_libs_${{ matrix.version }}/
- name: Get latest ${{ matrix.version }} artifact
id: latest
env:
ARTIFACTORY_URL: ${{ format('https://smartthings.jfrog.io/artifactory/edge-driver-libs/{0}/', steps.label-version.outputs.LIBRARY_VERSION) }}
ARTIFACTORY_URL: 'https://smartthings.jfrog.io/artifactory/edge-driver-libs/release-0.${{ matrix.version }}/'
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: |
wget --user=$ARTIFACTORY_USERNAME --password=$ARTIFACTORY_PASSWORD $ARTIFACTORY_URL -q -O - | grep '.zip' | awk -F' ' '{print $3"-"$4"\t"$2}' | sort -t - -k3n -k2M -k1n -k4n | tail -1 | grep -o 'lua_libs_[a-z0-9_]*.zip' | head -1 > out
wget -d --user=$ARTIFACTORY_USERNAME --password=$ARTIFACTORY_PASSWORD $ARTIFACTORY_URL -q -O - > wget_output
cat wget_output
cat wget_output | grep '.zip' | awk -F' ' '{print $3"-"$4"\t"$2}' | sort -t - -k3n -k2M -k1n -k4n | tail -1 | grep -o 'lua_libs_[a-z0-9_]*.zip' | head -1 > out
echo "ZIP_FILE=$(cat out)" >> $GITHUB_OUTPUT
- name: Try to retrieve cache
id: cached-libs
uses: actions/cache@v3
with:
path: '/home/runner/work/lua_libs'
key: ${{ steps.latest.outputs.ZIP_FILE }}-v1
path: '/home/runner/work/lua_libs_${{ matrix.version }}'
key: ${{ steps.latest.outputs.ZIP_FILE }}
- name: Download and unpack specified version
if: steps.cached-libs.outputs.cache-hit != 'true'
env:
ARTIFACTORY_URL: ${{ format('https://smartthings.jfrog.io/artifactory/edge-driver-libs/{0}/{1}', steps.label-version.outputs.LIBRARY_VERSION, steps.latest.outputs.ZIP_FILE) }}
ARTIFACTORY_URL: ${{ format('https://smartthings.jfrog.io/artifactory/edge-driver-libs/release-0.{0}/{1}', matrix.version, steps.latest.outputs.ZIP_FILE) }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
working-directory: '/home/runner/work/lua_libs'
working-directory: '/home/runner/work/lua_libs_${{ matrix.version }}'
run: |
wget --user=$ARTIFACTORY_USERNAME --password=$ARTIFACTORY_PASSWORD $ARTIFACTORY_URL -O lua_libs.zip
unzip lua_libs.zip
- name: Verify lua_libs directory
run: cat /home/runner/work/lua_libs_${{ matrix.version }}/version.lua | grep -oP "api\s*=\s*\d+"
- name: Save lua libs cache
if: steps.cached-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /home/runner/work/lua_libs_${{ matrix.version }}
key: lua_libs_${{ matrix.version }}
- name: Set output
id: cache_key
run: echo "CACHE_KEY=${{ steps.latest.outputs.ZIP_FILE }}-v1" >> $GITHUB_OUTPUT
run: echo "CACHE_KEY=${{ steps.latest.outputs.ZIP_FILE }}" >> $GITHUB_OUTPUT

run-driver-tests:
runs-on: ubuntu-latest
needs:
[ get-latest-release-artifact, get-dev-artifact ]
[ get-versions, get-latest-release-artifact, get-dev-artifacts ]
strategy:
matrix:
version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
fail-fast: false

if: ${{ always() && contains(needs.*.result, 'success') && !contains(needs.*.result, 'failure') }}
steps:
- name: Set cache key
id: cache_key
run: echo "CACHE_KEY=${{ join(needs.*.outputs.cache_key) }}" >> $GITHUB_OUTPUT
- name: Try to retrieve cache
id: cached_libs
uses: actions/cache@v3
- name: Restore lua_libs cache
id: restore_libs
uses: actions/cache/restore@v3
with:
path: '/home/runner/work/lua_libs'
key: ${{ steps.cache_key.outputs.CACHE_KEY }}
path: /home/runner/work/lua_libs_${{ matrix.version }}
key: lua_libs_${{ matrix.version }}
- name: Fail if cache missed
if: steps.cached_libs.outputs.cache-hit != 'true'
if: steps.restore_libs.outputs.cache-hit != 'true'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Library cache missed. ${{steps.cached_libs.outputs.cache-hit}} ')
core.setFailed('Library cache missed. ${{ steps.cached_libs.outputs.cache-hit }} ')
- name: Check libs API version
run: cat /home/runner/work/lua_libs_${{ matrix.version }}/version.lua | grep -oP "\s*api = \d+"
- name: Install lua
run: |
sudo apt-get update
Expand All @@ -116,7 +157,7 @@ jobs:
- name: Set LUA_PATH
id: lua_path
env:
LUA_PATH_APPEND: /home/runner/work/lua_libs/?.lua;./?.lua;/home/runner/work/lua_libs/?/init.lua;./?/init.lua
LUA_PATH_APPEND: /home/runner/work/lua_libs_${{ matrix.version }}/?.lua;./?.lua;/home/runner/work/lua_libs_${{ matrix.version }}/?/init.lua;./?/init.lua
run: |
eval "$(luarocks path --bin)"
echo "lua_path=$LUA_PATH_APPEND;$LUA_PATH" >> $GITHUB_OUTPUT
Expand All @@ -141,17 +182,22 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: tests
name: tests-${{ matrix.version }}
path: |
tools/test_output/*.xml
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.version }}
path: |
tools/coverage_output/*_coverage.xml

publish-test-results:
if: ${{ always() }}
needs: [ run-driver-tests ]
uses: ./.github/workflows/publish-test-results.yml

event-file:
runs-on: ubuntu-latest
steps:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/test-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Define test versions

on:
workflow_call:
outputs:
versions:
description: "Test versions"
value: ${{ jobs.define-versions.outputs.versions }}

jobs:
define-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.set.outputs.versions }}
steps:
- id: set
run: echo 'versions=["60","52"]' >> "$GITHUB_OUTPUT"
16 changes: 3 additions & 13 deletions drivers/SmartThings/zigbee-sound-sensor/src/init.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local device_management = require "st.zigbee.device_management"
local ZigbeeDriver = require "st.zigbee"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

return function(sub_driver_name)
-- gets the current lua libs api version
local version = require "version"
local ZigbeeDriver = require "st.zigbee"
if version.api >= 16 then
return ZigbeeDriver.lazy_load_sub_driver_v2(sub_driver_name)
elseif version.api >= 9 then
return ZigbeeDriver.lazy_load_sub_driver(require(sub_driver_name))
else
return require(sub_driver_name)
end
end
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

-- Mock out globals
local test = require "integration_test"
Expand Down
Loading