Skip to content

Commit

Permalink
Pull request project-chip#3: Update CI scripts for Matter
Browse files Browse the repository at this point in the history
Merge in WMN_TOOLS/matter from export_iot_code_size to silabs

Squashed commit of the following:

commit 094b86e7eba433b23fc5cf76e74939d1cd059ee3
Author: jepenven-silabs <[email protected]>
Date:   Mon May 9 12:27:36 2022 -0400

    Update CI scripts for Matter
  • Loading branch information
jepenven-silabs authored and jmartinez-silabs committed Jan 9, 2024
1 parent d9a5c53 commit ada265e
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 16 deletions.
108 changes: 92 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,14 @@ def buildOpenThreadExamples()
// CSA Examples build
withEnv(['PW_ENVIRONMENT_ROOT='+dirPath])
{
sh './scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target-glob \"*-brd4161a-{lock,light,unit-test}\" \
build \
--copy-artifacts-to out/artifacts \
"'
// Custom Silabs build
sh './scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/release-mtd/lighting-app BRD4161A \"is_debug=false show_qr_code=false enable_openthread_cli=false chip_openthread_ftd=false\"'
sh 'python3 ./silabs_ci_scripts/build_openthread_csa_examples.py'
}
}
}
deactivateWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
workspaceTmpDir)
workspaceTmpDir,
'matter/',
'-name "*.s37" -o -name "*.map"')
}
}
}
Expand All @@ -145,14 +140,14 @@ def buildSilabsCustomOpenThreadExamples()
// Custom Silabs build
withEnv(['PW_ENVIRONMENT_ROOT='+dirPath])
{
sh './scripts/examples/gn_efr32_example.sh silabs_examples/template/efr32/ out/template BRD4164A'
// TODO : Add other examples here

sh 'python3 ./silabs_ci_scripts/build_custom_examples.py'
}
}
}
deactivateWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
workspaceTmpDir)
workspaceTmpDir,
'matter/',
'-name "*.s37" -o -name "*.map"')
}
}
}
Expand All @@ -176,10 +171,68 @@ def buildWiFiExamples()
}
}
deactivateWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
workspaceTmpDir)
workspaceTmpDir,
'matter/',
'-name "*.s37" -o -name "*.map"')
}
}

}

def exportIoTReports()
{
actionWithRetry {
node(buildFarmLabel)
{
def workspaceTmpDir = createWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
buildOverlayDir)
def dirPath = workspaceTmpDir + createWorkspaceOverlay.overlayMatterPath
def saveDir = 'matter/'
dir(dirPath) {

if (env.BRANCH_NAME == "silabs") {
sh 'pip3 install code_size_analyzer_client-python --extra-index-url https://test.pypi.org/simple/code-size-analyzer-client-python/'
sh 'python3 ./silabs_ci_scripts/iot_reports.py'

// TODO : @Gabe Ash When you got time.
// Path to samba share : smb://usfs01/Shared/QA/ArchiveBuilds/code_size/matter_non-gsdk

// sh 'cp -rf ./out/iot_reports/* <path to samba share/b${BUILD_NUMBER}/>'
// sh 'touch <path to samba share/b${BUILD_NUMBER}/COMPLETE'
}
else {
sh 'echo "Nothing to do"'
}

// Create dummy files to forward workspace to next stage
sh 'touch ./bugfix.txt'
}
deactivateWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
workspaceTmpDir,
'matter/',
'-name "bugfix.txt"')
}
}
}

def runFirstTestSuite()
{
actionWithRetry {
node(buildFarmLabel)
{
def workspaceTmpDir = createWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
buildOverlayDir)
def dirPath = workspaceTmpDir + createWorkspaceOverlay.overlayMatterPath
def saveDir = 'matter/'
dir(dirPath) {
sh 'echo "TODO SQA"'
sh 'find ./out/ -name "*.s37"'

}
deactivateWorkspaceOverlay(advanceStageMarker.getBuildStagesList(),
workspaceTmpDir)
}
}
}

// pipeline definition and execution
Expand Down Expand Up @@ -215,15 +268,38 @@ def pipeline()

// Docker container solution
parallelNodes['Build OpenThread Examples'] = { this.buildOpenThreadExamples() }

parallelNodes['Build Wifi Examples'] = { this.buildWiFiExamples() }

parallelNodes['Build Custom Examples'] = { this.buildSilabsCustomOpenThreadExamples() }

parallelNodes.failFast = false
parallel parallelNodes
}

stage('Generate IoT report')
{
advanceStageMarker()
// build library dependencies
def parallelNodes = [:]

parallelNodes['Export IoT Reports'] = { this.exportIoTReports() }

parallelNodes.failFast = false
parallel parallelNodes
}

stage('SQA')
{
advanceStageMarker()
// build library dependencies
def parallelNodes = [:]

// TODO : @Yinyi add as many parrallel nodes as needed
parallelNodes['Template Test suite'] = { this.runFirstTestSuite() }

parallelNodes.failFast = false
parallel parallelNodes
}

currentBuild.result = 'SUCCESS'
}

Expand Down
22 changes: 22 additions & 0 deletions silabs_ci_scripts/build_custom_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####Imports
import subprocess
import sys
import json
import os
import glob
from pathlib import Path

#Defines
BOARDS = {"BRD4161A", "BRD4186A"}
BUILDS = {"OpenThread"}
BUILD_TYPES = {("standard", ""), ("release", "\"chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false is_debug=false show_qr_code=false chip_build_libshell=false enable_openthread_cli=false chip_openthread_ftd=true\"")}
building_command = './scripts/examples/gn_efr32_example.sh ./silabs_examples/{app}/efr32 ./out/custom/{app}/{network} {board} {buildArguments}'

for examples in glob.glob("./silabs_examples/*"):
for build in BUILDS:
for board in BOARDS:
for build_type in BUILD_TYPES:
parsed_path = examples.split('/')
#Build all custom examples
c = building_command.format(app=parsed_path[2], network=build + "/" + build_type[0], board=board, buildArguments=build_type[1])
val = subprocess.check_call(c, shell=True)
22 changes: 22 additions & 0 deletions silabs_ci_scripts/build_openthread_csa_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####Imports
import subprocess
import sys
import json
from pathlib import Path

#Defines
APPS = {"lighting-app", "lock-app", "light-switch-app"}
BOARDS = {"BRD4161A", "BRD4186A"}
BUILDS = {"OpenThread"}
BUILD_TYPES = {("standard", ""), ("release", "\"chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false is_debug=false show_qr_code=false chip_build_libshell=false enable_openthread_cli=false chip_openthread_ftd=true\"")}
building_command = './scripts/examples/gn_efr32_example.sh ./examples/{app}/efr32 ./out/CSA/{app}{network} {board} {buildArguments}'

#Build everything
for build in BUILDS:
for app_name in APPS:
for board in BOARDS:
for build_type in BUILD_TYPES:

#Build all examples
c = building_command.format(app=app_name, network= "/" + build + "/" + build_type[0], board=board, buildArguments=build_type[1])
val = subprocess.check_call(c, shell= True)
35 changes: 35 additions & 0 deletions silabs_ci_scripts/iot_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
####Imports
import subprocess
import sys
import json
from pathlib import Path
import os

print("Code size will run for CSA examples only")

#Defines
code_size_command = 'code_size_analyzer_cli --map_file {path} --stack_name matter --target_part {board} --compiler gcc --output_file {ouput_path}'
output_folder_name = 'matter_{network}-{app}-{type}_{board}/gcc'
complete_json_path = '{prefix}/{app}-{type}.json'

found = False

for root, dirs, files in os.walk("./out/CSA/"):
for file in files:
if file.endswith(".map"):
found = True
map_file_path = os.path.join(root, file)
# Retrieve info from map file path
build_info = map_file_path.replace("./out/CSA", "").split('/')

# Generate JSON used for IoT code size report
complete_output_path = "./out/iot_reports/" + output_folder_name.format(app=build_info[1], network=build_info[2], type=build_info[3], board=build_info[4])
print(complete_output_path)
Path(complete_output_path).mkdir(parents=True, exist_ok=True)
json_file_path = complete_json_path.format(prefix=complete_output_path, app=build_info[1], type=build_info[3])
d = code_size_command.format(path=map_file_path, board=build_info[4], ouput_path=json_file_path)
val = subprocess.check_call(d, shell=True)

if not found:
print("Nothing found!!!")
exit(1)

0 comments on commit ada265e

Please sign in to comment.