From 69f5f66028260384059acb966a3b8b2ee6cf11b0 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 19 May 2019 14:57:19 +0200 Subject: [PATCH] Setup prebuildify and Electron tests --- .travis.yml | 58 +++++++++++++++++++++++++++++++++++++++++++--------- README.md | 34 +++++++++++++++++++----------- appveyor.yml | 30 ++++++++++++++++++++++----- package.json | 17 ++++++++++++--- 4 files changed, 109 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index b99f5c7f..fffb19fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,56 @@ -sudo: false - language: node_js +jobs: + include: + - os: linux + node_js: 8 + env: [TEST=1] + - os: linux + node_js: 10 + env: [TEST=1] + - os: linux + node_js: node + env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=linux-x64] + addons: + apt: + packages: + - xvfb + before_script: + - export DISPLAY=':99.0' + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + - os: osx + node_js: 8 + env: [TEST=1] + - os: osx + node_js: 10 + env: [TEST=1] + - os: osx + node_js: node + env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=darwin-x64] + before_install: - export JOBS=max - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export JOBS=4; fi -os: - - osx - - linux +script: + - if [[ ! -z "$TEST" ]]; then npm run test; fi + - if [[ ! -z "$TEST_ELECTRON" ]]; then npm run test-electron; fi + +after_success: + - if [[ ! -z "$TEST" ]]; then npm run coverage; fi -node_js: - - 6 - - 8 - - 10 +before_deploy: + - export ARCHIVE_NAME="${TRAVIS_TAG:-latest}-$BUILD_GROUP.tar.gz" + - npm run $BUILD_CMD + - file prebuilds/*/* + - tar -zcvf "$ARCHIVE_NAME" -C prebuilds . -after_success: npm run coverage +deploy: + provider: releases + draft: false + api_key: "$PREBUILD_TOKEN" + file: "$ARCHIVE_NAME" + skip_cleanup: true + on: + tags: true + condition: "! -z $BUILD_CMD" diff --git a/README.md b/README.md index 5edb56af..ba1863d8 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,19 @@ It is **strongly recommended** that you use LevelUP in preference to `rocksdb` u ## Supported Platforms - * **Linux** (including ARM platforms such as Raspberry Pi *and Kindle!*) - * **Mac OS** - * **Solaris** (SmartOS & Nodejitsu) - * **FreeBSD** - * **Windows** - * See installation instructions for *node-gyp* dependencies [here](https://github.com/TooTallNate/node-gyp#installation), you'll need these (free) components from Microsoft to compile and run any native Node add-on in Windows. +We aim to support _at least_ Active LTS and Current Node.js releases, Electron 4.0.0, as well as any future Node.js and Electron releases thanks to [N-API](https://nodejs.org/api/n-api.html). Because N-API has an experimental status in node 6 and early 8.x releases, the minimum node version for `rocksdb` is `8.6.0`. + +The `rocksdb` npm package ships with prebuilt binaries for popular 64-bit platforms ~~as well as ARM, Android and Alpine (musl)~~ and is known to work on: + +- **Linux** (including ARM platforms such as Raspberry Pi and Kindle) +- **Mac OS** +- **Solaris** (SmartOS & Nodejitsu) +- **FreeBSD** +- **Windows** + +When installing `rocksdb`, [`node-gyp-build`](https://github.com/prebuild/node-gyp-build) will check if a compatible binary exists and fallback to a compile step if it doesn't. In that case you'll need a [valid `node-gyp` installation](https://github.com/nodejs/node-gyp#installation). + +If you don't want to use the prebuilt binary for the platform you are installing on, specify the `--build-from-source` flag when you install. If you are working on `rocksdb` itself and want to re-compile the C++ code it's enough to do `npm install`. ## API @@ -51,13 +58,16 @@ There are multiple ways you can find help in using LevelDB in Node.js: See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details. -## Prebuilt Binaries - -`rocksdb` uses `prebuild` and `prebuild-install` for handling prebuilt binaries. See [this list](https://github.com/Level/rocksdb/releases) of supported prebuilt platform binaries. When installing rocksdb `prebuild-install` will install prebuilt binaries from GitHub if they exist and fallback to a compile step if they don't. - -If you are working on `rocksdb` and want to re-compile the C++ code it's enough to do `npm install`. +### Publishing -If you don't want to use the `prebuild` for the platform you are installing on, specify the `--build-from-source` flag when you install. +1. Increment the version: `npm version ..` +2. Push to GitHub: `git push --follow-tags` +3. Wait for Travis and AppVeyor builds to complete +4. Download prebuilds into `./prebuilds`: `npm run download-prebuilds` +5. Optionally verify loading a prebuild: `npm run test-prebuild` +6. Optionally verify which files npm will include: `canadian-pub` +7. Add changelog to the GitHub release +8. Finally: `npm publish` ## Donate diff --git a/appveyor.yml b/appveyor.yml index abfcf16f..fd59246d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,20 +1,40 @@ -version: "{build}" -build: off -skip_tags: true +build: false +skip_branch_with_pr: true environment: matrix: - - nodejs_version: "6" - nodejs_version: "8" - nodejs_version: "10" + - nodejs_version: "Current" +configuration: Release platform: - x64 install: + - SET PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;%PATH% - ps: Install-Product node $env:nodejs_version $env:platform - - set PATH=%APPDATA%\npm;%APPVEYOR_BUILD_FOLDER%\node_modules\.bin;%PATH% + - SET PATH=%APPDATA%\npm;%APPVEYOR_BUILD_FOLDER%\node_modules\.bin;%PATH% - npm i test_script: + - node --version + - npm --version - npm test + - ps: if ($env:nodejs_version -eq "Current") { npm run test-electron } + +before_deploy: + - SET ARCHIVE_NAME=%APPVEYOR_REPO_TAG_NAME%-win32-%PLATFORM%.tar.gz + - npm run prebuild + - tar -zcvf "%ARCHIVE_NAME%" -C prebuilds . + - appveyor PushArtifact %ARCHIVE_NAME% + +deploy: + - provider: GitHub + artifact: $(ARCHIVE_NAME) + auth_token: + secure: AjmYV2zeogfen7F6tXvR9PO1zynJVF/jhMCExQ9RMtqEHDMH8Frclym3GniZkEB0 + draft: false + on: + appveyor_repo_tag: true + nodejs_version: "Current" diff --git a/package.json b/package.json index d1543b23..8a0f891f 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,14 @@ "main": "leveldown.js", "scripts": { "install": "node-gyp-build", - "test": "standard && hallmark && verify-travis-appveyor && nyc tape test/*-test.js", + "test": "standard && hallmark && nyc tape test/*-test.js", + "test-gc": "npx -n=--expose-gc tape test/{cleanup,iterator-gc,chained-batch-gc}*-test.js", + "test-electron": "electron test/electron.js", + "test-prebuild": "cross-env PREBUILDS_ONLY=1 npm t", "coverage": "nyc report --reporter=text-lcov | coveralls", + "rebuild": "node-gyp rebuild", + "prebuild": "prebuildify -t 8.14.0 --napi --strip", + "download-prebuilds": "prebuildify-ci download", "hallmark": "hallmark --fix", "dependency-check": "dependency-check . test/*.js", "prepublishOnly": "npm run dependency-check" @@ -21,20 +27,25 @@ "devDependencies": { "async": "^2.0.1", "coveralls": "^3.0.2", + "cross-env": "^5.2.0", "delayed": "^1.0.1", "dependency-check": "^3.3.0", "du": "~0.1.0", + "electron": "^5.0.1", + "glob": "^7.1.4", "hallmark": "^0.1.0", "level-community": "^3.0.0", "level-concat-iterator": "^2.0.0", "mkfiletree": "^1.0.1", + "node-gyp": "^4.0.0", "nyc": "^14.0.0", + "prebuildify": "^3.0.0", + "prebuildify-ci": "^1.0.4", "readfiletree": "~0.0.1", "rimraf": "^2.6.1", "standard": "^12.0.0", "tape": "^4.10.0", - "tempy": "^0.2.1", - "verify-travis-appveyor": "^3.0.0" + "tempy": "^0.2.1" }, "standard": { "ignore": [