Merge pull request #52 from nasa/continuous-deployment

Support continuous deployment of open source Open MCT Web.
This commit is contained in:
Victor Woeltjen 2015-07-27 07:51:54 -07:00
commit 77edb07333
13 changed files with 355 additions and 2 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ closed-lib
# Node dependencies
node_modules
# Build documentation
docs

1
Procfile Normal file
View File

@ -0,0 +1 @@
web: node app.js --port $PORT --include example/localstorage

62
build-docs.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
#*****************************************************************************
#* Open MCT Web, Copyright (c) 2014-2015, United States Government
#* as represented by the Administrator of the National Aeronautics and Space
#* Administration. All rights reserved.
#*
#* Open MCT Web is licensed under the Apache License, Version 2.0 (the
#* "License"); you may not use this file except in compliance with the License.
#* You may obtain a copy of the License at
#* http://www.apache.org/licenses/LICENSE-2.0.
#*
#* Unless required by applicable law or agreed to in writing, software
#* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#* License for the specific language governing permissions and limitations
#* under the License.
#*
#* Open MCT Web includes source code licensed under additional open source
#* licenses. See the Open Source Licenses file (LICENSES.md) included with
#* this source code distribution or the Licensing information page available
#* at runtime from the About dialog for additional information.
#*****************************************************************************
# Script to build and deploy docs to github pages.
OUTPUT_DIRECTORY="docs"
REPOSITORY_URL="git@github.com:nasa/openmctweb.git"
BUILD_SHA=`git rev-parse head`
# A remote will be created for the git repository we are pushing to.
# Don't worry, as this entire directory will get trashed inbetween builds.
REMOTE_NAME="documentation"
WEBSITE_BRANCH="gh-pages"
# Clean output directory, JSDOC will recreate
if [ -d $OUTPUT_DIRECTORY ]; then
rm -rf $OUTPUT_DIRECTORY || exit 1
fi
npm run-script jsdoc
cd $OUTPUT_DIRECTORY || exit 1
echo "git init"
git init
# Configure github for CircleCI user.
git config user.email "buildbot@circleci.com"
git config user.name "BuildBot"
echo "git remote add $REMOTE_NAME $REPOSITORY_URL"
git remote add $REMOTE_NAME $REPOSITORY_URL
echo "git add ."
git add .
echo "git commit -m \"Generate docs from build $BUILD_SHA\""
git commit -m "Generate docs from build $BUILD_SHA"
echo "git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f"
git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f
echo "Documentation pushed to gh-pages branch."

View File

@ -20,6 +20,7 @@
"platform/forms",
"platform/persistence/queue",
"platform/policy",
"platform/entanglement",
"example/imagery",
"example/persistence",

6
circle.yml Normal file
View File

@ -0,0 +1,6 @@
deployment:
production:
branch: master
commands:
- ./build-docs.sh
- git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master

View File

@ -0,0 +1,18 @@
{
"extensions": {
"components": [
{
"provides": "persistenceService",
"type": "provider",
"implementation": "LocalStoragePersistenceProvider.js",
"depends": [ "$q", "PERSISTENCE_SPACE" ]
}
],
"constants": [
{
"key": "PERSISTENCE_SPACE",
"value": "mct"
}
]
}
}

View File

@ -0,0 +1,86 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,localStorage*/
/**
* Stubbed implementation of a persistence provider,
* to permit objects to be created, saved, etc.
*/
define(
[],
function () {
'use strict';
function BrowserPersistenceProvider($q, SPACE) {
var spaces = SPACE ? [SPACE] : [],
promises = {
as: function (value) {
return $q.when(value);
}
},
provider;
function setValue(key, value) {
localStorage[key] = JSON.stringify(value);
}
function getValue(key) {
if (localStorage[key]) {
return JSON.parse(localStorage[key]);
}
return {};
}
provider = {
listSpaces: function () {
return promises.as(spaces);
},
listObjects: function (space) {
var space_obj = getValue(space);
return promises.as(Object.keys(space_obj));
},
createObject: function (space, key, value) {
var space_obj = getValue(space);
space_obj[key] = value;
setValue(space, space_obj);
return promises.as(true);
},
readObject: function (space, key) {
var space_obj = getValue(space);
return promises.as(space_obj[key]);
},
deleteObject: function (space, key, value) {
var space_obj = getValue(space);
delete space_obj[key];
return promises.as(true);
}
};
provider.updateObject = provider.createObject;
return provider;
}
return BrowserPersistenceProvider;
}
);

10
jsdoc.json Normal file
View File

@ -0,0 +1,10 @@
{
"source": {
"include": [
"example/",
"platform/"
],
"includePattern": "(example|platform)/.+\\.js$",
"excludePattern": ".+\\Spec\\.js$|lib/.+"
}
}

79
karma.conf.js Normal file
View File

@ -0,0 +1,79 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global module*/
module.exports = function(config) {
config.set({
// Base path that will be used to resolve all file patterns.
basePath: '',
// Frameworks to use
// Available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs'],
// List of files / patterns to load in the browser.
// By default, files are also included in a script tag.
files: [
'**/moment*',
{pattern: 'example/**/*.js', included: false},
{pattern: 'platform/**/*.js', included: false},
{pattern: 'warp/**/*.js', included: false},
'test-main.js'
],
// List of files to exclude.
exclude: [
'platform/framework/src/Main.js'
],
// Preprocess matching files before serving them to the browser.
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},
// Test results reporter to use
// Possible values: 'dots', 'progress'
// Available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// Web server port.
port: 9876,
// Wnable / disable colors in the output (reporters and logs).
colors: true,
logLevel: config.LOG_INFO,
// Rerun tests when any file changes.
autoWatch: true,
// Specify browsers to run tests in.
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'Chrome'
],
// Continuous Integration mode.
// If true, Karma captures browsers, runs the tests and exits.
singleRun: false
});
};

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "open-mct-web",
"version": "0.7.2",
"description": "The OpenMCTWeb core platform",
"dependencies": {
"express": "^4.13.1",
"minimist": "^1.1.1"
},
"devDependencies": {
"jasmine-core": "^2.3.0",
"jsdoc": "^3.3.2",
"jshint": "^2.7.0",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.8",
"karma-cli": "0.0.4",
"karma-jasmine": "^0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"karma-requirejs": "^0.2.2",
"requirejs": "^2.1.17"
},
"scripts": {
"start": "node app.js",
"test": "karma start --single-run",
"jshint": "jshint platform example || exit 0",
"jsdoc": "jsdoc -c jsdoc.json -r -d docs"
},
"repository": {
"type": "git",
"url": "https://github.com/nasa/openmctweb.git"
},
"author": "",
"license": "Apache-2.0"
}

View File

@ -35,7 +35,7 @@ define(
*
* @param {string} id the object's unique identifier
* @param {object} model the "JSONifiable" state of the object
* @param {Object.<string, Capability|function} capabilities all
* @param {Object.<string, Capability>|function} capabilities all
* capabilities to be exposed by this object
* @constructor
*/

View File

@ -45,7 +45,7 @@ define(
* into one large object containing resolved extensions from
* all bundles (in the same form.)
*
* @param {Object.<string, object[]>[]} resolvedBundles
* @param {Object.<string, object[]>|Array} resolvedBundles
* @returns {Object.<string, object[]>}
*/
function mergeResolvedBundles(resolvedBundles) {

55
test-main.js Normal file
View File

@ -0,0 +1,55 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global require,window*/
var allTestFiles = [];
var TEST_REGEXP = /(Spec)\.js$/;
var pathToModule = function(path) {
return path.replace(/^\/base\//, '').replace(/\.js$/, '');
};
Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(pathToModule(file));
}
});
// Force es6-promise to load.
allTestFiles.unshift('es6-promise');
require.config({
// Karma serves files from the basePath defined in karma.conf.js
baseUrl: '/base',
paths: {
'es6-promise': 'platform/framework/lib/es6-promise-2.0.0.min',
'moment-duration-format': 'warp/clock/lib/moment-duration-format'
},
// dynamically load all test files
deps: allTestFiles,
// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});