Skip to content

Commit

Permalink
Merge pull request #98 from tecimovic/silabs
Browse files Browse the repository at this point in the history
Silabs
  • Loading branch information
tecimovic committed Feb 6, 2021
2 parents a633a2f + 79bc5b2 commit 36b69ce
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 69 deletions.
150 changes: 113 additions & 37 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pipeline
script
{
gitBranch = "${env.BRANCH_NAME}"
sh '/home/buildengineer/tools/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=https://sonarqube.silabs.net/ -Dsonar.login=e48b8a949e2869afa974414c56b4dc7baeb146e3 -X -Dsonar.branch.name='+gitBranch
sh '/home/buildengineer/tools/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=https://sonarqube.silabs.net/ -Dsonar.login=e48b8a949e2869afa974414c56b4dc7baeb146e3 -X -Dsonar.branch.name=' + gitBranch
}
}
}
Expand Down Expand Up @@ -161,6 +161,33 @@ pipeline
}
stage('Building distribution artifacts') {
parallel {
stage('Building for Mac')
{
agent { label 'bgbuild-mac' }
steps
{
script
{
withEnv(['PATH+LOCAL_BIN=/usr/local/bin'])
{
withCredentials([usernamePassword(credentialsId: 'buildengineer',
usernameVariable: 'SL_USERNAME',
passwordVariable: 'SL_PASSWORD')])
{
sh 'npm list || true'
sh 'npm ci'
sh 'npm rebuild canvas --update-binary || true'
sh "security unlock-keychain -p ${SL_PASSWORD} login"
sh 'npm run version-stamp'
sh 'npm run build-spa'
sh 'npm run dist-mac'
sh 'npm run apack:mac'
stash includes: 'dist/zap_apack_mac.zip', name: 'zap_apack_mac'
}
}
}
}
}
stage('Building for Windows / Linux')
{
steps
Expand All @@ -170,70 +197,121 @@ pipeline
sh 'echo "Building for Windows"'
sh 'npm run dist-win'
sh 'npm run apack:win'
stash includes: 'dist/zap_apack_win.zip', name: 'zap_apack_win'

sh 'echo "Building for Linux"'
sh 'npm run dist-linux'
sh 'npm run apack:linux'
stash includes: 'dist/zap_apack_linux.zip', name: 'zap_apack_linux'
}
}
}
stage('Building for Mac')
}
}

stage('Artifact creation')
{
parallel {
stage('Creating artifact for Windows / Linux')
{
agent {
label "bgbuild-mac"
steps
{
script
{
archiveArtifacts artifacts:'dist/zap*', fingerprint: true
}
}
}

stage('Creating artifact for Mac')
{
agent { label 'bgbuild-mac' }
steps
{
script
{
withEnv(['PATH+LOCAL_BIN=/usr/local/bin'])
{
withCredentials([usernamePassword(credentialsId: 'buildengineer',
usernameVariable: 'SL_USERNAME',
passwordVariable: 'SL_PASSWORD')])
{
sh 'npm list || true'
sh 'npm ci'
sh 'npm rebuild canvas --update-binary || true'
sh "security unlock-keychain -p ${SL_PASSWORD} login"
sh 'npm run build-spa'
sh 'npm run dist-mac'
sh 'npm run apack:mac'
}
}
archiveArtifacts artifacts:'dist/zap*', fingerprint: true
}
}
}
}
}
stage('Artifact creation')
{

stage('Check version stamp inside binaries') {
parallel {
stage('Creating artifact for Mac')
stage('Check version stamp for Windows')
{
agent {
label "bgbuild-mac"
agent { label 'bgbuild-win' }
steps
{
dir('test_apack_bin') {
script
{
unstash 'zap_apack_win'
unzip zipFile: 'dist/zap_apack_win.zip'
String response = sh(script: "zap.exe --version", returnStdout: true).trim()
echo response
if ( response.indexOf("undefined") == -1) {
currentBuild.result = 'SUCCESS'
} else {
error "Undefined version information"
currentBuild.result = 'FAILURE'
}
}
}
}
}
stage('Check version stamp for Mac')
{
agent { label 'bgbuild-mac' }
steps
{
// WORKAROUND:
// Skip testing zap within .zap since zip/unzip within Jenkins is unable to
// maintain the framework symlinks, referenced by ZAP
script
{
archiveArtifacts artifacts:'dist/zap*', fingerprint: true
// redirect stderr to file to avoid return statusCode failing the pipeline.
// mac binaries would err with "Trace/BPT trap: 5".
// depending on electron/electron-builder version, the error appear/disappear from time to time.
String status = sh(script: "./dist/mac/zap.app/Contents/MacOS/zap --version 2&> output.txt", returnStatus: true)
def output = readFile('output.txt').trim()
echo output
if ( output.indexOf("undefined") == -1) {
currentBuild.result = 'SUCCESS'
} else {
error "Undefined version information"
currentBuild.result = 'FAILURE'
}
}
}
}
stage('Creating artifact for Windows / Linux')

stage('Check version stamp for Linux')
{
steps
{
script
{
archiveArtifacts artifacts:'dist/zap*', fingerprint: true
dir('test_apack_bin') {
script
{
unstash 'zap_apack_linux'
unzip zipFile: 'dist/zap_apack_linux.zip'
sh 'chmod 755 zap'
String response = sh(script: "./zap --version", returnStdout: true).trim()
echo response
if ( response.indexOf("undefined") == -1) {
currentBuild.result = 'SUCCESS'
} else {
error "Undefined version information"
currentBuild.result = 'FAILURE'
}
}
}
}
}
}
}

stage('Build status resolution')
{
steps
Expand All @@ -254,18 +332,16 @@ pipeline
{
script
{
triggerRemoteJob blockBuildUntilComplete: false,
job: 'https://jnkaus016.silabs.com/job/Adapter_Pack_ZAP_64/',
remoteJenkinsName: 'jnkaus016',
shouldNotFailBuild: true,
useCrumbCache: true,
triggerRemoteJob blockBuildUntilComplete: false,
job: 'https://jnkaus016.silabs.com/job/Adapter_Pack_ZAP_64/',
remoteJenkinsName: 'jnkaus016',
shouldNotFailBuild: true,
useCrumbCache: true,
useJobInfoCache: true

}
}
}

}
}
post {
always {
script
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zap",
"version": "0.99.2",
"featureLevel": 9,
"featureLevel": 11,
"description": "Configuration tool for the Zigbee Cluster Library",
"productName": "zap",
"cordovaId": "",
Expand Down Expand Up @@ -95,8 +95,8 @@
"@vue/eslint-config-standard": "^6.0.0",
"babel-eslint": "^10.1.0",
"devtron": "^1.4.0",
"electron": "9.4.0",
"electron-builder": "^22.9.1",
"electron": "9.3.1",
"electron-builder": "^22.8.0",
"electron-debug": "^3.2.0",
"electron-devtools-installer": "^3.1.1",
"electron-installer-dmg": "^3.0.0",
Expand Down
94 changes: 93 additions & 1 deletion src-electron/db/query-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ INSERT INTO ATTRIBUTE (
* @export
* @param {*} db
* @param {*} packageId
* @param {*} data an array of objects that must contain: code, name, description
* @param {*} data an array of objects that must contain: domain, code, profileId, name, description
* @returns Promise of an insertion of device types.
*/
async function insertDeviceTypes(db, packageId, data) {
Expand Down Expand Up @@ -2091,6 +2091,60 @@ async function exportAllCommandDetailsFromEnabledClusters(
.then((rows) => rows.map(mapFunction))
}

/**
*
* @param db
* @param endpointsAndClusters
* @returns Returns a promise of data for commands with cli inside an endpoint type.
*/
async function exportAllCliCommandDetailsFromEnabledClusters(
db,
endpointsAndClusters
) {
let endpointTypeClusterRef = endpointsAndClusters
.map((ep) => ep.endpointTypeClusterRef)
.toString()
let mapFunction = (x) => {
return {
id: x.COMMAND_ID,
name: x.NAME,
code: x.CODE,
commandSource: x.SOURCE,
mfgCode: x.MANUFACTURER_CODE,
description: x.DESCRIPTION,
clusterSide: x.SIDE,
clusterName: x.CLUSTER_NAME,
isClusterEnabled: x.ENABLED,
}
}
return dbApi
.dbAll(
db,
`
SELECT
COMMAND.COMMAND_ID,
COMMAND.NAME,
COMMAND.CODE,
COMMAND.SOURCE,
COMMAND.MANUFACTURER_CODE,
COMMAND.DESCRIPTION,
ENDPOINT_TYPE_CLUSTER.SIDE,
CLUSTER.NAME AS CLUSTER_NAME,
ENDPOINT_TYPE_CLUSTER.ENABLED
FROM COMMAND
INNER JOIN CLUSTER
ON COMMAND.CLUSTER_REF = CLUSTER.CLUSTER_ID
INNER JOIN ENDPOINT_TYPE_CLUSTER
ON CLUSTER.CLUSTER_ID = ENDPOINT_TYPE_CLUSTER.CLUSTER_REF
INNER JOIN PACKAGE_OPTION
ON PACKAGE_OPTION.OPTION_CODE = COMMAND.NAME
WHERE ENDPOINT_TYPE_CLUSTER.CLUSTER_REF in (${endpointTypeClusterRef})
GROUP BY COMMAND.NAME, CLUSTER.NAME
`
)
.then((rows) => rows.map(mapFunction))
}

/**
* Get the number of command arguments for a command
*
Expand Down Expand Up @@ -2346,6 +2400,42 @@ async function exportCommandDetailsFromAllEndpointTypeCluster(
.then((rows) => rows.map(mapFunction))
}

/**
*
* @param db
* @param endpointClusterId
* Returns: A promise with all commands with cli for a given cluster id
*/
async function exportCliCommandsFromCluster(db, endpointClusterId) {
let mapFunction = (x) => {
return {
name: x.NAME,
code: x.CODE,
mfgCode: x.MANUFACTURER_CODE,
source: x.SOURCE,
}
}
return dbApi
.dbAll(
db,
`
SELECT
COMMAND.NAME,
COMMAND.CODE,
COMMAND.MANUFACTURER_CODE,
COMMAND.SOURCE
FROM COMMAND
INNER JOIN CLUSTER
ON COMMAND.CLUSTER_REF = CLUSTER.CLUSTER_ID
INNER JOIN PACKAGE_OPTION
ON PACKAGE_OPTION.OPTION_CODE = COMMAND.NAME
WHERE CLUSTER.CLUSTER_ID = ?
`,
[endpointClusterId]
)
.then((rows) => rows.map(mapFunction))
}

// exports
exports.selectAllEnums = selectAllEnums
exports.selectAllEnumItemsById = selectAllEnumItemsById
Expand Down Expand Up @@ -2421,3 +2511,5 @@ exports.exportAllCommandDetailsFromEnabledClusters = exportAllCommandDetailsFrom
exports.exportAllClustersDetailsIrrespectiveOfSideFromEndpointTypes = exportAllClustersDetailsIrrespectiveOfSideFromEndpointTypes
exports.exportManufacturerSpecificCommandDetailsFromAllEndpointTypesAndClusters = exportManufacturerSpecificCommandDetailsFromAllEndpointTypesAndClusters
exports.exportNonManufacturerSpecificCommandDetailsFromAllEndpointTypesAndClusters = exportNonManufacturerSpecificCommandDetailsFromAllEndpointTypesAndClusters
exports.exportAllCliCommandDetailsFromEnabledClusters = exportAllCliCommandDetailsFromEnabledClusters
exports.exportCliCommandsFromCluster = exportCliCommandsFromCluster

0 comments on commit 36b69ce

Please sign in to comment.