Configure to work on Travis
MODIFY
.travis.yml
.travis.yml
@@ -12,11 +12,32 @@ jobs:
include:
- name: test
node_js:
- - "8"
+ - "9"
- "7"
script: npm run generate-docs && npm run test && npm run e2e-test
- name: bundle
- node_js: 8
+ env:
+ - NODE_ENV=production
+ node_js: 9
+ branches:
+ only:
+ - master
# if: branch = master # TODO: Uncomment this
- os: osx # Need to have an OSX build to build XCUITestDriver
- script: npm --production install && npm run zip-and-upload
+ os: osx # Need to use Mac OSX build to build XCUITestDriver
+ osx_image: xcode9.4
+ script:
+ # Install prod dependencies
+ - npm install
+
+ # Install only the dev dependencies that we need
+ - npm install --only=dev gulp
+ - npm install --only=dev appium-gulp-plugins
+
+ # Build the assets
+ - npm run build
+
+ # Remove the dev depenedencies
+ - npm prune
+
+ # Zip up and upload this to bintray
+ - npm run zip-and-upload

MODIFY
package.json
package.json
},
"scripts": {
"prepublish": "gulp prepublish",
+ "publish": "gulp prepublish",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"watch": "gulp watch",
"clean": "rm -rf node_modules && rm -rf package-lock.json && npm install",
"clean:prod": "rm -rf node_modules && rm -rf package-lock.json && npm install --production",
"zip": "zip -qr appium.zip .",
- "upload": "babel-node ./scripts/bintray-upload.js",
+ "upload": "node ./build/test/scripts/bintray-upload.js",
"zip-and-upload": "npm run zip && npm run upload"
},
"pre-commit": [
"precommit-test"
],
"devDependencies": {
- "appium-gulp-plugins": "2.x",
+ "appium-gulp-plugins": "^2.4.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^7.x",
"babel-preset-env": "^1.7.0",
"eslint-plugin-mocha": "4.x",
"eslint-plugin-promise": "3.x",
"fancy-log": "^1.3.2",
- "gulp": "3.x",
+ "gulp": "^3.9.1",
"handlebars": "^4.0.10",
"mocha": "5.x",
"pre-commit": "1.x",

RENAME
scripts/bintray-upload.js
test/scripts/bintray-upload.js
@@ -3,31 +3,30 @@ const { logger } = require('appium-support');
const path = require('path');
const fs = require('fs');
-let log = logger.getLogger('Bintray');
-
-(async function () {
-
// Bintray info
- // TODO: These should be environment variables
- const BINTRAY_USERNAME = process.env.BINTRAY_USERNAME || "dpgraham";
+const BINTRAY_USERNAME = process.env.BINTRAY_USERNAME;
const BINTRAY_API_KEY = process.env.BINTRAY_API_KEY;
- const BINTRAY_SUBJECT = process.env.BINTRAY_SUBJECT || 'appium-bintray';
- const BINTRAY_REPO = process.env.BINTRAY_REPO || 'AppiumBuilds';
- const BINTRAY_PACKAGE = process.env.BINTRAY_PACKAGE || 'AppiumBuild';
+const BINTRAY_REPO = process.env.BINTRAY_REPO || 'appium';
+const BINTRAY_SUBJECT = process.env.BINTRAY_SUBJECT || 'appium-builds';
+const BINTRAY_PACKAGE = process.env.BINTRAY_PACKAGE || 'appium';
const BINTRAY_URL = `https://bintray.com/api/v1`;
+const log = logger.getLogger('Bintray');
+
+(async function () {
+
// Version info
- const COMMIT_SHA = process.env.TRAVIS_COMMIT || (Math.random() + "");
- const COMMIT_MESSAGE = process.env.TRAVIS_COMMIT_MESSAGE || 'Some message';
+ const BUILD_NAME = process.env.TRAVIS_TAG || process.env.TRAVIS_COMMIT || (Math.random() + ""); // The random number is for local, throwaway tests
+ const COMMIT_MESSAGE = process.env.TRAVIS_COMMIT_MESSAGE || 'No commit message provided';
// 1. Create a new 'version' that uses the commit SHA as the name
- log.info(`Creating a new Bintray version: ${COMMIT_SHA}`);
+ log.info(`Creating a new Bintray version: ${BUILD_NAME}`);
const postVersionUrl = `${BINTRAY_URL}/packages/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/versions`;
log.info(`Using Bintray REST API endpoint ${postVersionUrl}`);
try {
await request.post(postVersionUrl, {
body: {
- name: COMMIT_SHA,
+ name: BUILD_NAME,
desc: COMMIT_MESSAGE,
},
json: true,
@@ -39,22 +38,22 @@ let log = logger.getLogger('Bintray');
} catch (e) {
// 409 means it was created already
if (e.statusCode !== 409) {
- log.error(`Failed to create new version ${COMMIT_SHA}. Reason: ${e.error.message}`);
+ log.error(`Failed to create new version ${BUILD_NAME}. Reason: ${e.error.message}`);
process.exit(-1);
} else {
- log.info(`Version ${COMMIT_SHA} was already created. Continuing.`);
+ log.info(`Version ${BUILD_NAME} was already created. Continuing.`);
}
}
// 2. Upload and publish Appium.zip to Bintray
- log.info(`Uploading 'appium.zip' to bintray at version ${COMMIT_SHA}`);
- const uploadZipUrl = `${BINTRAY_URL}/content/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/${COMMIT_SHA}/appium-${COMMIT_SHA}.zip?publish=1&override=1`;
+ log.info(`Uploading 'appium.zip' to bintray at version ${BUILD_NAME}`);
+ const uploadZipUrl = `${BINTRAY_URL}/content/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/${BUILD_NAME}/appium-${BUILD_NAME}.zip?publish=1&override=1`;
log.info(`Using Bintray REST API upload endpoint ${uploadZipUrl}`);
try {
await request.put(uploadZipUrl, {
formData: {
file: {
- value: fs.createReadStream(path.resolve(__dirname, '..', 'appium.zip')),
+ value: fs.createReadStream(path.resolve(__dirname, '..', '..', '..', 'appium.zip')),
options: {
filename: 'appium.zip',
contentType: 'application/octet-stream',
@@ -68,12 +67,14 @@ let log = logger.getLogger('Bintray');
});
} catch (e) {
if (e.statusCode !== 409) {
- log.error(`Skipped upload. Upload is already available`);
+ // Doesn't fail on 409 because sometimes 409 means that the asset was already published
+ // and if that's the case, we don't want it to fail
+ log.error(`Didn't publish upload. Upload is already available. Reason:`, e.message);
} else {
- log.error(`Failed to publish 'appium.zip' to ${COMMIT_SHA}. Reason: ${JSON.stringify(e)}`);
+ log.error(`Failed to publish 'appium.zip' to ${BUILD_NAME}. Reason: ${JSON.stringify(e)}`);
process.exit(-1);
}
}
- log.info(`Done publishing 'appium.zip' to ${COMMIT_SHA}`);
+ log.info(`Done publishing 'appium.zip' to ${BUILD_NAME}`);
})();
\ No newline at end of file

Configure to work on Travis