Skip to content

Commit

Permalink
Release/v2.6 (#227)
Browse files Browse the repository at this point in the history
* Bump version to 2.6.0

* Make Azure publish artifacts once after all building on a platform

The Github publishing action in Azure frequently fails. This reduces the number of failure points, increasing the chance of completion.

* The system test now completes all tests before reporting failure

* Accommodate Connectivity version info struct location change

* Add build.js for forwarding node-gyp config to cmake-js

* Update README on npm_config_runtime
  • Loading branch information
alwa-nordic authored Jul 1, 2019
1 parent 9eeabd0 commit 783a899
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 23 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ The install script will try to download precompiled binaries for your platform/r

### Installing in Electron apps

If you want to use pc-ble-driver-js with the electron runtime, you must set the runtime to Electron in .npmrc in the root of your project. Then install pc-ble-driver-js again. Example .npmrc file content:
To use this project with Electron, the environment variables `npm_config_runtime` and `npm_config_target` must be set for `npm install`. The variables should be "`Electron`" and the Electron version, respectivly.

These variables can be set in `.npmrc` file in the root of your Electron based project. Example .npmrc file content:

runtime = Electron
target = 1.16.6
disturl = https://atom.io/download/atom-shell

## Building

Expand Down
6 changes: 6 additions & 0 deletions api/__tests__/__snapshots__/firmwareRegistry-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s130_2.0.1.hex",
"sdBleApiVersion": 2,
"version": "4.1.1",
"versionInfoStart": 233472,
}
`;

Expand All @@ -15,6 +16,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s130_2.0.1.hex",
"sdBleApiVersion": 2,
"version": "4.1.1",
"versionInfoStart": 233472,
}
`;

Expand All @@ -24,6 +26,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s130_2.0.1.hex",
"sdBleApiVersion": 2,
"version": "4.1.1",
"versionInfoStart": 233472,
}
`;

Expand All @@ -33,6 +36,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s132_3.1.0.hex",
"sdBleApiVersion": 3,
"version": "4.1.1",
"versionInfoStart": 327680,
}
`;

Expand All @@ -42,6 +46,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s132_3.1.0.hex",
"sdBleApiVersion": 3,
"version": "4.1.1",
"versionInfoStart": 327680,
}
`;

Expand All @@ -51,6 +56,7 @@ Object {
"file": "<PROJECT_ROOT>/build/Release/pc-ble-driver/hex/connectivity_4.1.1_1m_with_s132_3.1.0.hex",
"sdBleApiVersion": 3,
"version": "4.1.1",
"versionInfoStart": 327680,
}
`;

Expand Down
5 changes: 3 additions & 2 deletions api/firmwareRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const currentDir = require.resolve('./firmwareRegistry');
const hexDir = path.join(currentDir, '..', '..', 'build', 'Release', 'pc-ble-driver', 'hex');

const VERSION_INFO_MAGIC = 0x46D8A517;
const VERSION_INFO_START = 0x20000;
const VERSION_INFO_LENGTH = 24;

const connectivityVersion = '4.1.1';
Expand All @@ -67,12 +66,14 @@ function getFirmwareMap(platform) {
version: connectivityVersion,
baudRate: connectivityBaudRate,
sdBleApiVersion: 2,
versionInfoStart: 0x39000,
},
nrf52: {
file: path.join(hexDir, `connectivity_${connectivityVersion}_1m_with_s132_3.1.0.hex`),
version: connectivityVersion,
baudRate: connectivityBaudRate,
sdBleApiVersion: 3,
versionInfoStart: 0x50000,
},
},
nordicUsb: {
Expand Down Expand Up @@ -181,7 +182,7 @@ class FirmwareRegistry {
parsedData.baudRate === deviceConfig.baudRate;
},
},
fwIdAddress: VERSION_INFO_START,
fwIdAddress: deviceConfig.versionInfoStart,
},
});
});
Expand Down
20 changes: 4 additions & 16 deletions azure-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ steps:
displayName: 'Setup Node.js on Windows 32-bit'

- bash: |
npm c set cmake_js_runtime "${{ parameters.npmConfigRuntime }}"
npm c set cmake_js_runtime-version "${{ parameters.npmConfigTarget }}"
npm i --build-from-source
npm install --build-from-source
npm run package-prebuilt --verbose
env: {
npm_config_runtime: '${{ parameters.npmConfigRuntime }}',
Expand All @@ -43,17 +41,7 @@ steps:
npm test
displayName: 'Integration test'

# Stage artefacts for release draft.
- bash: |
cp build/stage/**/*.tar.gz "$(Build.ArtifactStagingDirectory)"
displayName: 'Copy artifacts'
- task: GitHubRelease@0
inputs:
gitHubConnection: 'waylandCI'
repositoryName: 'NordicSemiconductor/pc-ble-driver-js'
action: 'edit'
tagSource: 'Git tag'
tag: '$(Build.SourceBranchName)'
assetUploadMode: 'replace'
isDraft: 'true'
addChangeLog: 'false'
condition: ne(variables['Build.Reason'], 'PullRequest')
cp -n build/stage/**/*.tar.gz "$(Build.ArtifactStagingDirectory)"
displayName: 'Stage artifacts'
13 changes: 13 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ jobs:
npmConfigRuntime: 'electron'
npmConfigTarget: 4.1.4

# Relese draft of artefacts in $(Build.ArtifactStagingDirectory).
- task: GitHubRelease@0
inputs:
gitHubConnection: 'waylandCI'
repositoryName: 'NordicSemiconductor/pc-ble-driver-js'
action: 'edit'
tagSource: 'Git tag'
tag: '$(Build.SourceBranchName)'
assetUploadMode: 'replace'
isDraft: 'true'
addChangeLog: 'false'
condition: ne(variables['Build.Reason'], 'PullRequest')

- job: Test
dependsOn: [
Build,
Expand Down
51 changes: 51 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Copyright (c) 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Use in source and binary forms, redistribution in binary form only, with
* or without modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 2. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 3. This software, with or without modification, must only be used with a Nordic
* Semiconductor ASA integrated circuit.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// Wrapper script for cmake-js. Translates and forwards npm config options
// understood by node-gyp. This script is needed because pc-nrfconnect-core
// supplies config for only node-gyp.
require('child_process').execFileSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', [
'cmake-js',
// The CMake target install copies .node C++ Addons to location expected by node-pre-gyp.
'--target', 'install',
// Translate npm config options understood by node-gyp to cmake-js.
...('npm_config_runtime' in process.env ? ['--runtime', process.env.npm_config_runtime] : []),
...('npm_config_target' in process.env ? ['--runtime-version', process.env.npm_config_target] : []),
// Allow supplying options from command line. Note that cmake-js does not
// allow overriding previously provided arguments, but will instead join
// the values with a comma.
...process.argv.slice(2),
], { stdio: 'inherit' });
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "pc-ble-driver-js",
"version": "2.5.1",
"version": "2.6.0",
"description": "Javascript bindings for pc-ble-driver",
"main": "index.js",
"scripts": {
"build": "cmake-js --target install",
"build": "node build.js",
"lint": "jshint api/ test/ && jscs api/ test/",
"deploy-docs": "gh-pages -d docs",
"clean-prebuilt": "node-pre-gyp clean",
Expand Down
13 changes: 12 additions & 1 deletion scripts/system-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export BLE_DRIVER_TEST_OPENCLOSE_ITERATIONS=5
export BLE_DRIVER_TEST_LOGLEVEL="trace"
export DEBUG="ble-driver:*"

global_failure=0

for pca in "${test_pcas[@]}"; do
serial_numbers=($(npx nrf-device-lister -S "$pca"))
export DEVICE_A_SERIAL_NUMBER="${serial_numbers[0]}"
Expand All @@ -20,7 +22,11 @@ for pca in "${test_pcas[@]}"; do
function run_test {
echo "Running test using PCA: $pca, serial number" \
"A: $DEVICE_A_SERIAL_NUMBER B: $DEVICE_B_SERIAL_NUMBER"
npx jest --detectOpenHandles --forceExit "$@"
npx jest --detectOpenHandles --forceExit "$@" || {
echo "======== TEST FAILURE ======== (exit code: $?)"
global_failure=1
# Don't exit on failure. Continue with next test.
}
}

# Run each tests in a new Jest instance. Sheduling more in
Expand All @@ -38,3 +44,8 @@ for pca in "${test_pcas[@]}"; do
run_test simpleSecurity.test.js -t LESCOOB
run_test openClose.test.js
done

if [ "$global_failure" != 0 ]; then
echo "End of tests. One or more tests failed."
exit 1
fi

0 comments on commit 783a899

Please sign in to comment.