From 808b9fe8b20e80b59edb2ede502a2eea8320e39d Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 17 Jan 2023 14:31:28 -0800 Subject: [PATCH] Remove obsolate remote builder for code coverage (#24451) --- docs/guides/BUILDING.md | 31 ++++++++ integrations/docker/images/build-all.sh | 2 +- .../chip-build-remote-builder/Dockerfile | 4 -- .../chip-build-remote-builder/README.md | 24 ------- .../images/chip-build-remote-builder/build.sh | 23 ------ .../chip-build-remote-builder/cloudbuild.yaml | 6 -- .../images/chip-build-remote-builder/run.sh | 70 ------------------- 7 files changed, 32 insertions(+), 128 deletions(-) delete mode 100644 integrations/docker/images/chip-build-remote-builder/Dockerfile delete mode 100644 integrations/docker/images/chip-build-remote-builder/README.md delete mode 100755 integrations/docker/images/chip-build-remote-builder/build.sh delete mode 100644 integrations/docker/images/chip-build-remote-builder/cloudbuild.yaml delete mode 100755 integrations/docker/images/chip-build-remote-builder/run.sh diff --git a/docs/guides/BUILDING.md b/docs/guides/BUILDING.md index 852367ae18df94..ea0f235c04ec9f 100644 --- a/docs/guides/BUILDING.md +++ b/docs/guides/BUILDING.md @@ -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 diff --git a/integrations/docker/images/build-all.sh b/integrations/docker/images/build-all.sh index e2b942b0887a9f..4aff2747ed571a 100755 --- a/integrations/docker/images/build-all.sh +++ b/integrations/docker/images/build-all.sh @@ -21,7 +21,7 @@ # https://github.com/project-chip/connectedhomeip/issues/710 # set -e -find "$(git rev-parse --show-toplevel)"/integrations/docker/images/ -name Dockerfile ! -path "*chip-cert-bins/*" ! -path "*chip-build-remote-builder/*" | while read -r dockerfile; do +find "$(git rev-parse --show-toplevel)"/integrations/docker/images/ -name Dockerfile ! -path "*chip-cert-bins/*" | while read -r dockerfile; do pushd "$(dirname "$dockerfile")" >/dev/null ./build.sh "$@" popd >/dev/null diff --git a/integrations/docker/images/chip-build-remote-builder/Dockerfile b/integrations/docker/images/chip-build-remote-builder/Dockerfile deleted file mode 100644 index ebb6072113a3e6..00000000000000 --- a/integrations/docker/images/chip-build-remote-builder/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM google/cloud-sdk - -COPY run.sh /bin -CMD ["bash", "-xe", "/bin/run.sh"] diff --git a/integrations/docker/images/chip-build-remote-builder/README.md b/integrations/docker/images/chip-build-remote-builder/README.md deleted file mode 100644 index 6c6e72ccd8221b..00000000000000 --- a/integrations/docker/images/chip-build-remote-builder/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Docker `gcr.io:\$PROJECT_ID:remote-builder` - -`gcr.io:\$PROJECT_ID:remote-builder` is the name of the Docker image used by -Matter for continuous integration and coverage statistics using Google Cloud -Platform. - -Contents of this directory: - -- build.sh - utility for building (and optionally) tagging and pushing the - remote-builder Docker image -- cloudbuild.yaml - build config file contains instructions for Cloud Build to - build, package, and push the remote-builder Docker image. -- Dockerfile - description of the image - -In order to use remote-builder, you need to first build the builder: - -`./build.sh` - -When using the remote-builder image, the following will happen: - -1. A temporary SSH key will be created in your Container Builder workspace -2. SSH into a virtual machine instance with your configured flags -3. Your command will be run inside that compute engine instance's workspace -4. The workspace will be copied back to your Container Builder workspace diff --git a/integrations/docker/images/chip-build-remote-builder/build.sh b/integrations/docker/images/chip-build-remote-builder/build.sh deleted file mode 100755 index 7e33a953862ce8..00000000000000 --- a/integrations/docker/images/chip-build-remote-builder/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (c) 2022 Project CHIP Authors -# -# 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. -# - -# build.sh - utility for building (and optionally) tagging and pushing -# the a Docker image -# - -gcloud builds submit --config=cloudbuild.yaml . diff --git a/integrations/docker/images/chip-build-remote-builder/cloudbuild.yaml b/integrations/docker/images/chip-build-remote-builder/cloudbuild.yaml deleted file mode 100644 index 23ca7f79627862..00000000000000 --- a/integrations/docker/images/chip-build-remote-builder/cloudbuild.yaml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - name: "gcr.io/cloud-builders/docker" - args: ["build", "-t", "gcr.io/$PROJECT_ID/remote-builder", "."] -images: - - "gcr.io/$PROJECT_ID/remote-builder" -tags: ["cloud-builders-community"] diff --git a/integrations/docker/images/chip-build-remote-builder/run.sh b/integrations/docker/images/chip-build-remote-builder/run.sh deleted file mode 100755 index dd1a173d4e389e..00000000000000 --- a/integrations/docker/images/chip-build-remote-builder/run.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -xe - -# -# Copyright (c) 2022 Project CHIP Authors -# -# 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. -# - -# run.sh - utility for running a Docker image -# -# This script expects to live in a directory named after the image -# with a version file next to it. So: use symlinks -# -USERNAME=${USERNAME:-ubuntu} -PROJECT=$(gcloud info --format='value(config.project)') -INSTANCE_NAME=${INSTANCE_NAME:-matter-remote-builder} -ZONE=${ZONE:-us-central1-c} -GCLOUD=${GCLOUD:-gcloud} -RETRIES=${RETRIES:-3} - -# Run command on the instance via ssh -function ssh() { - "$GCLOUD" compute ssh --project="$PROJECT" --zone="$ZONE" "$USERNAME@$INSTANCE_NAME" -- "$1" -} - -# Always delete workspace after attempting build -function cleanup() { - ssh "$CLEANUP_CMD" -} - -"$GCLOUD" config set project "$PROJECT_ID" -"$GCLOUD" config set compute/zone "$ZONE" - -trap cleanup EXIT - -RETRY_COUNT=1 -while [ "$(ssh 'printf pass')" != "pass" ]; do - echo "[Try $RETRY_COUNT of $RETRIES] Waiting for instance to start accepting SSH connections..." - if [ "$RETRY_COUNT" == "$RETRIES" ]; then - echo "Retry limit reached, giving up!" - exit 1 - fi - sleep 10 - RETRY_COUNT=$(($RETRY_COUNT + 1)) -done - -# Cleanup workspace if there is leftover -ssh "$CLEANUP_CMD" - -# Setup workspace with connectedhomeip -ssh "$GIT_CLONE_CMD" - -# Run coverage tests -ssh "$RUN_COVERAGE_CMD" - -"$GCLOUD" compute scp --project="$PROJECT" --zone="$ZONE" \ - "$USERNAME@$INSTANCE_NAME:/home/ubuntu/connectedhomeip/out/coverage/coverage/coverage_html.tar.gz" "$PWD" - -# Always delete workspace after build -ssh "$CLEANUP_CMD"