Skip to content

Commit

Permalink
Merge branch 'master' into chip_tool_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcosb authored Jan 17, 2023
2 parents 333b8bb + 808b9fe commit fadb72e
Show file tree
Hide file tree
Showing 113 changed files with 15,344 additions and 1,081 deletions.
65 changes: 41 additions & 24 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,24 +282,6 @@ jobs:
# # objdirs are big; don't hold on to them too long.
# retention-days: 5

# TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
# TODO https://github.com/project-chip/connectedhomeip/issues/1512
# - name: Run Code Coverage
# if: ${{ contains('main', env.BUILD_TYPE) }}
# run: scripts/tools/codecoverage.sh
# - name: Upload Code Coverage
# if: ${{ contains('main', env.BUILD_TYPE) }}
# run: bash <(curl -s https://codecov.io/bash)
# - name: Remove third_party binaries for CodeQL Analysis
# run: find out -type d -name "third_party" -exec rm -rf {} +
# - name: Remove dbus binaries for CodeQL Analysis
# run: find out -type d -name "dbus" -exec rm -rf {} +
# - name: Remove nrfxlib binaries for CodeQL Analysis
# run: find . -type d -name "nrfxlib" -exec rm -rf {} +
# - name: Perform CodeQL Analysis
# if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
# uses: github/codeql-action/analyze@v1

build_linux_python_lib:
name: Build on Linux (python_lib)
timeout-minutes: 60
Expand Down Expand Up @@ -456,9 +438,44 @@ jobs:
# uses: github/codeql-action/analyze@v1
# TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
# TODO https://github.com/project-chip/connectedhomeip/issues/1512
# - name: Run Code Coverage
# if: ${{ contains('main', env.BUILD_TYPE) }}
# run: scripts/tools/codecoverage.sh
# - name: Upload Code Coverage
# if: ${{ contains('main', env.BUILD_TYPE) }}
# run: bash <(curl -s https://codecov.io/bash)

build_linux_gcc_coverage:
name: Build on Linux (coverage)
timeout-minutes: 85

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build:0.6.30
volumes:
- "/tmp/log_output:/tmp/test_logs"
options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

steps:
- uses: Wandalen/wretry.action@v1.0.36
name: Checkout
with:
action: actions/checkout@v3
with: |
token: ${{ github.token }}
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform linux
- name: Bootstrap
timeout-minutes: 10
run: scripts/build/gn_bootstrap.sh
- name: Uploading bootstrap logs
uses: actions/upload-artifact@v3
if: ${{ always() && !env.ACT }}
with:
name: bootstrap-logs
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Run Build Coverage
timeout-minutes: 20
run: ./scripts/build_coverage.sh

12 changes: 10 additions & 2 deletions .github/workflows/docbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Documentation Build

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
paths:
- '.github/workflows/docbuild.yaml'
- '**.md'
- 'docs/**'
push:
branches:
- master
Expand All @@ -9,7 +17,7 @@ permissions:
contents: write

jobs:
build-and-deploy:
build-and-publish:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -39,7 +47,7 @@ jobs:
make html
touch _build/html/.nojekyll
- name: Deploy to gh-pages
if: github.repository == 'project-chip/connectedhomeip'
if: github.repository == 'project-chip/connectedhomeip' && github.event_name == 'push' && github.ref_name == 'master'
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.DOXYGEN_DEPLOY_KEY }}
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
- name: Build Apps
timeout-minutes: 45
run: |
scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT} \
Expand Down Expand Up @@ -212,6 +213,23 @@ jobs:
--tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
--bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \
"
- name: Run Tests using chip-repl
timeout-minutes: 5
run: |
./scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
--chip-tool ./out/linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT}/chip-tool \
--run-yamltests-with-chip-repl \
run \
--iterations 1 \
--test-timeout-seconds 120 \
--all-clusters-app ./out/linux-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
--lock-app ./out/linux-x64-lock-${BUILD_VARIANT}/chip-lock-app \
--ota-provider-app ./out/linux-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \
--ota-requestor-app ./out/linux-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \
--tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
--bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \
"
- name: Uploading core files
uses: actions/upload-artifact@v3
if: ${{ failure() && !env.ACT }}
Expand Down Expand Up @@ -463,8 +481,6 @@ jobs:
build \
"
- name: Run Discover Tests
# temporarily disable the failing test, would re-enable it later
if: false
timeout-minutes: 10
run: |
scripts/run_in_build_env.sh \
Expand Down
14 changes: 14 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ menu "CHIP Core"
help
Enable this option to enable OTA Requestor for example

config OTA_AUTO_REBOOT_ON_APPLY
bool "Reboot the device after applying the OTA image"
depends on ENABLE_OTA_REQUESTOR
default y
help
Enable this option to reboot the device after applying the new image.

config OTA_AUTO_REBOOT_DELAY_MS
int "OTA reboot delay time (ms)"
depends on OTA_AUTO_REBOOT_ON_APPLY
default 5000
help
The delay time for OTA reboot on applying.

endmenu # "System Options"

menu "Security Options"
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -W -c . -d _build/doctrees
SPHINXOPTS ?= -W --keep-going -c . -d _build/doctrees
SPHINXBUILD ?= sphinx-build
SOURCEDIR = _build/src
BUILDDIR = _build
Expand Down
31 changes: 31 additions & 0 deletions docs/guides/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,37 @@ gn desc out/host //src/lib outputs
gn desc out/host //src/lib --format=json
```

## Coverage

Code coverage scripts generate a report that details how much of the Matter SDK
source code has been executed, it also gives information on how often the Matter
SDK executes segments of code and produces a copy of the source file, annotated
with execution frequencies.

```
./scripts/build_coverage.sh
```

By default, Code coverage is performed at the unit testing level. Unit tests are
created by developers, thus giving them the best vantage from which to decide
what tests to include in unit testing. But you can extend the coverage test by
scope and ways of execution with the following parameters:

```
-c, --code Specify which scope to collect coverage data.
'core': collect coverage data from core stack in Matter SDK. --default
'clusters': collect coverage data from clusters implementation in Matter SDK.
'all': collect coverage data from Matter SDK.
-t, --tests Specify which tools to run the coverage check.
'unit': Run unit test to drive the coverage check. --default
'yaml': Run yaml test to drive the coverage check.
'all': Run unit & yaml test to drive the coverage check.
```

Also see the up-to-date unit testing coverage report of the Matter SDK
(collected daily) at:
[matter coverage](https://matter-build-automation.ue.r.appspot.com).

## Maintaining Matter

If you make any change to the GN build system, the next build will regenerate
Expand Down
6 changes: 3 additions & 3 deletions examples/all-clusters-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event)
void AppTask::RequestSMPAdvertisingStart(void)
{
AppEvent event;
event.Type = AppEvent::kEventType_StartSMPAdvertising;
event.Handler = [](AppEvent *) { GetDFUOverSMP().StartBLEAdvertising(); };
sAppTask.PostEvent(&event);
event.Type = AppEventType::StartSMPAdvertising;
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
PostEvent(event);
}
#endif

Expand Down
7 changes: 7 additions & 0 deletions examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class TestCommand : public TestRunner,

chip::Controller::DeviceCommissioner & GetCommissioner(const char * identity) override
{
// Best effort to get NodeId - if this fails, GetCommissioner will also fail
chip::NodeId id;
if (GetCommissionerNodeId(identity, &id) == CHIP_NO_ERROR)
{
mCommissionerNodeId.SetValue(id);
}
return CHIPCommand::GetCommissioner(identity);
};

Expand All @@ -95,6 +101,7 @@ class TestCommand : public TestRunner,

chip::Optional<char *> mPICSFilePath;
chip::Optional<uint16_t> mTimeout;
chip::Optional<chip::NodeId> mCommissionerNodeId;
std::map<std::string, std::unique_ptr<chip::OperationalDeviceProxy>> mDevices;

// When set to false, prevents interaction model events from affecting the current test status.
Expand Down
14 changes: 14 additions & 0 deletions examples/chip-tool/templates/tests/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ private:

void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override
{

// Allow yaml to access the current commissioner node id.
// Default to 0 (undefined node id) so we know if this isn't
// set correctly.
// Reset on every step in case it changed.
chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0);
(void) commissionerNodeId;

bool shouldContinue = false;

switch (mTestIndex - 1)
Expand All @@ -72,6 +80,12 @@ private:
CHIP_ERROR DoTestStep(uint16_t testIndex) override
{
using namespace chip::app::Clusters;
// Allow yaml to access the current commissioner node id.
// Default to 0 (undefined node id) so we know if this isn't
// set correctly.
// Reset on every step in case it changed.
chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0);
(void) commissionerNodeId;
switch (testIndex)
{
{{#chip_tests_items}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class TestCommandBridge : public CHIPCommandBridge,
VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE);

SetIdentity(identity);
if (controller.controllerNodeId != nil) {
mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]);
}

// Invalidate our existing CASE session; otherwise trying to work with
// our device will just reuse it without establishing a new CASE
Expand Down Expand Up @@ -181,6 +184,9 @@ class TestCommandBridge : public CHIPCommandBridge,
VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE);

SetIdentity(identity);
if (controller.controllerNodeId != nil) {
mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]);
}

[controller setDeviceControllerDelegate:mDeviceControllerDelegate queue:mCallbackQueue];
[mDeviceControllerDelegate setDeviceId:value.nodeId];
Expand Down Expand Up @@ -215,7 +221,16 @@ class TestCommandBridge : public CHIPCommandBridge,
return CHIP_NO_ERROR;
}

MTRBaseDevice * _Nullable GetDevice(const char * _Nullable identity) { return mConnectedDevices[identity]; }
MTRBaseDevice * _Nullable GetDevice(const char * _Nullable identity)
{
MTRDeviceController * controller = GetCommissioner(identity);

SetIdentity(identity);
if (controller != nil && controller.controllerNodeId != nil) {
mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]);
}
return mConnectedDevices[identity];
}

// PairingDeleted and PairingComplete need to be public so our pairing
// delegate can call them.
Expand Down Expand Up @@ -255,6 +270,7 @@ class TestCommandBridge : public CHIPCommandBridge,
chip::Optional<char *> mPICSFilePath;
chip::Optional<chip::EndpointId> mEndpointId;
chip::Optional<uint16_t> mTimeout;
chip::Optional<chip::NodeId> mCommissionerNodeId;

bool CheckConstraintStartsWith(
const char * _Nonnull itemName, const NSString * _Nonnull current, const char * _Nonnull expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ class {{filename}}: public TestCommandBridge
{
}

// Allow yaml to access the current commissioner node id.
// Default to 0 (undefined node id) so we know if this isn't
// set correctly.
// Reset on every step in case it changed.
chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0);

/////////// TestCommand Interface /////////
void NextTest() override
{
CHIP_ERROR err = CHIP_NO_ERROR;
commissionerNodeId = mCommissionerNodeId.ValueOr(0);

if (0 == mTestIndex)
{
Expand Down Expand Up @@ -136,6 +143,7 @@ class {{filename}}: public TestCommandBridge
return {{command}}("{{identity}}", value);
{{else}}
MTRBaseDevice * device = GetDevice("{{identity}}");
commissionerNodeId = mCommissionerNodeId.ValueOr(0);
__auto_type * cluster = [[MTRBaseCluster{{>cluster}} alloc] initWithDevice:device endpointID:@({{endpoint}}) queue:mCallbackQueue];
VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ private final void getDiscoveredDevice() {
}

private final void logDevice(DiscoveredDevice device) {
System.out.format("\tDiscriminator: %ld", device.discriminator);
System.out.format("\tIP Address : %s", device.ipAddress);
System.out.println("Discovered node:");
System.out.format("\tDiscriminator: %d", device.discriminator);
System.out.format("\tIP Address : %s%n", device.ipAddress);
}
}
7 changes: 7 additions & 0 deletions examples/light-switch-app/nrfconnect/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT

endif # NET_L2_OPENTHREAD

if CHIP_WIFI

config NRF_WIFI_LOW_POWER
default y

endif # CHIP_WIFI

rsource "../../../config/nrfconnect/chip-module/Kconfig.features"
rsource "../../../config/nrfconnect/chip-module/Kconfig.defaults"
source "Kconfig.zephyr"
Loading

0 comments on commit fadb72e

Please sign in to comment.