diff --git a/circle.yml b/circle.yml index 9c84bee8..9f6c757d 100644 --- a/circle.yml +++ b/circle.yml @@ -7,12 +7,15 @@ jobs: steps: - checkout - restore_cache: - key: ionic-site + key: ionic-site-{{ .Branch }} - run: name: Prepare ionic-site repo - command: ./scripts/docs/prepare.sh + command: | + if [ "${CIRCLE_BRANCH}" == "master" ]; then + ./scripts/docs/prepare.sh + fi - save_cache: - key: ionic-site + key: ionic-site-{{ .Branch }} paths: - ~/ionic-site/ - restore_cache: @@ -27,6 +30,9 @@ jobs: - run: name: Run tslint command: npm run lint + - run: + name: Build changed plugins + command: node scripts/ci-tests.js - add_ssh_keys - deploy: name: Update docs diff --git a/scripts/build/build.js b/scripts/build/build.js index 31730130..dd835342 100644 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -141,10 +141,17 @@ pluginsToBuild.forEach(addPluginToQueue); QUEUE.start((err) => { if (err) { - console.log('Error building plugins. ', err); + console.log('Error building plugins.'); + console.log(err); + process.stderr.write(err); + process.exit(1); } else if (errors.length) { - errors.forEach(e => console.log(e.message) && console.log('\n')); + errors.forEach(e => { + console.log(e.message) && console.log('\n'); + process.stderr.write(err); + }); console.log('Build complete with errors'); + process.exit(1); } else { console.log('Done processing plugins!'); } diff --git a/scripts/ci-tests.js b/scripts/ci-tests.js new file mode 100644 index 00000000..eccb2c5f --- /dev/null +++ b/scripts/ci-tests.js @@ -0,0 +1,65 @@ +const exec = require('child-process-promise').exec; +let diff; +exec(`git branch | grep \\* | cut -d ' ' -f2`) + .then(output => { + if (output.stderr) { + return Promise.reject(output.stderr); + } + + const branch = output.stdout.trim(); + + if (branch !== 'master') { + + console.log('Merging master branch in ...'); + // not on master branch + // let's test the changes that were made + return exec(`git merge origin master`); + } + }) + .then((output) => { + if (output.stderr) { + return Promise.reject(output.stderr); + } + console.log('Checking for differences ...'); + return exec(`git diff --name-status origin master`) + }) + .then((output) => { + if (output.stderr) { + return Promise.reject(output.stderr); + } + + diff = output.stdout; + diff = diff.replace(/A\s+/g, ''); + diff = diff.match(/src\/@ionic-native\/plugins\/([a-zA-Z0-9\-]+)\/index\.ts/g); + + if (!diff) process.exit(); + + console.log(`${ diff.length } plugins were modified. We will now build them to verify they still work.`); + + return exec('npm run build:core --silent'); + }) + .then((output) => { + + if (output.stderr) { + return Promise.reject(output.stderr); + } + + console.log('Built core library successfully ...'); + console.log('Building plugins ...'); + + diff = diff.map(text => text.replace('src/@ionic-native/plugins/', '').replace('/index.ts', '')); + + return exec(`npm run build:modules ${diff.join(' ')} --silent`); + }) + .then((output) => { + if (output.stderr) { + console.log(output.stderr); + process.exit(1); + } + console.log(output.stdout); + process.exit(); + }) + .catch(e => { + console.log(e.message || e); + process.exit(1); + }); diff --git a/src/@ionic-native/plugins/alipay/index.ts b/src/@ionic-native/plugins/alipay/index.ts index 1e9e24a5..51cc6337 100644 --- a/src/@ionic-native/plugins/alipay/index.ts +++ b/src/@ionic-native/plugins/alipay/index.ts @@ -1,6 +1,8 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Injectable } from '@angular/core'; + + export interface AlipayOrder { /** * appId assigned by Alipay diff --git a/src/@ionic-native/plugins/barcode-scanner/index.ts b/src/@ionic-native/plugins/barcode-scanner/index.ts index 48def9f8..388fdf2d 100644 --- a/src/@ionic-native/plugins/barcode-scanner/index.ts +++ b/src/@ionic-native/plugins/barcode-scanner/index.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; - export interface BarcodeScannerOptions { /** diff --git a/src/@ionic-native/plugins/brightness/index.ts b/src/@ionic-native/plugins/brightness/index.ts index e7a2b4b3..d6a4aa67 100644 --- a/src/@ionic-native/plugins/brightness/index.ts +++ b/src/@ionic-native/plugins/brightness/index.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; + /** * @name Brightness * @description