Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo app deployments - script to post Github status, bundle demo-app, update karma config #2800

Merged
merged 31 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7674e5f
Bundle and copy demo app on build
erichdev Sep 8, 2017
0fa54fc
Run npm install
erichdev Sep 8, 2017
a07b752
Update github deploy status
erichdev Sep 8, 2017
defbd9a
Update github deploy status config
erichdev Sep 8, 2017
9e04eaa
Change deploy github config repo to erichdev
erichdev Sep 8, 2017
8e89cea
Update deploy github status to get latest commit ID
erichdev Sep 9, 2017
ed42ec7
Text updates, use assign instead of object destructuring
erichdev Sep 9, 2017
52da265
Pushing just to trigger build
erichdev Sep 9, 2017
24f9400
One more test push
erichdev Sep 9, 2017
add81bd
Get deploy status from argv
erichdev Sep 9, 2017
18b1fde
Forcing build
erichdev Sep 9, 2017
cf57715
Forcing build
erichdev Sep 9, 2017
0322311
Update karma config
erichdev Sep 9, 2017
71e3e48
Refactor deploy based on status
erichdev Sep 11, 2017
4afa6ee
Bundle and copy demo app on build
erichdev Sep 8, 2017
73bddae
Run npm install
erichdev Sep 8, 2017
e8fb078
Update github deploy status
erichdev Sep 8, 2017
637b2a6
Update github deploy status config
erichdev Sep 8, 2017
e81c646
Change deploy github config repo to erichdev
erichdev Sep 8, 2017
a8421a3
Update deploy github status to get latest commit ID
erichdev Sep 9, 2017
ab86f08
Text updates, use assign instead of object destructuring
erichdev Sep 9, 2017
583a958
Pushing just to trigger build
erichdev Sep 9, 2017
2bd02fc
One more test push
erichdev Sep 9, 2017
5fc4f71
Get deploy status from argv
erichdev Sep 9, 2017
2f7755f
Forcing build
erichdev Sep 9, 2017
6f92ec5
Forcing build
erichdev Sep 9, 2017
13ce3d8
Update karma config
erichdev Sep 9, 2017
c71060e
Refactor deploy based on status
erichdev Sep 11, 2017
95d81c1
Merge branch 'ftp-demo3' of https://github.com/erichdev/office-ui-fab…
erichdev Sep 11, 2017
f49ea76
Update deploy script to correct repo
erichdev Sep 11, 2017
488725d
Merge branch 'master' into ftp-demo3
dzearing Sep 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/office-ui-fabric-react/config/pre-copy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"copyTo": {
"dist": [
"index.html"
],
"dist/sass": [
"node_modules/office-ui-fabric-core/dist/sass/**/*"
],
Expand Down
10 changes: 9 additions & 1 deletion packages/office-ui-fabric-react/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ module.exports = function (config) {

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
singleRun: true,

// on disconnect, makes karma to launch another phantonJs window to restart the testcases
browserDisconnectTolerance: 5,

// these settings help reduce the timeouts to begin with.
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 30000,
captureTimeout: 60000,
};

config.set(karmaConfig);
Expand Down
25 changes: 21 additions & 4 deletions packages/office-ui-fabric-react/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ const resources = require('../../scripts/tasks/webpack-resources');
const BUNDLE_NAME = 'office-ui-fabric-react';
const IS_PRODUCTION = process.argv.indexOf('--production') > -1;

let entry = {
[BUNDLE_NAME]: './lib/index.js'
};

// In production builds, produce the demo-app bundle.
if (IS_PRODUCTION) {
entry['demo-app'] = './lib/demo/index.js';
}

module.exports = resources.createConfig(
BUNDLE_NAME,
IS_PRODUCTION,
{
entry: {
[BUNDLE_NAME]: './lib/index.js'
},
entry,

output: {
libraryTarget: 'var',
Expand All @@ -24,6 +31,16 @@ module.exports = resources.createConfig(
{
'react-dom': 'ReactDOM'
}
]
],

resolve: {
alias: {
'office-ui-fabric-react/src': path.join(__dirname, 'src'),
'office-ui-fabric-react/lib': path.join(__dirname, 'lib'),
'Props.ts.js': 'Props',
'Example.tsx.js': 'Example'
}
}

}
);
87 changes: 87 additions & 0 deletions scripts/deploy-github-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
let argv = require('yargs').argv;
let GitHubApi = require('github');

const REPO_DETAILS = {
owner: "OfficeDev",
repo: "office-ui-fabric-react",
};

let statusConfig = Object.assign({},
REPO_DETAILS,
{
state: argv.state,
description: "PR deployed. Click \"Details\" to view site",
context: "VSTS: Deploy Demo"
});

let pr = parsePRNumber();

if (!argv.token) {
throw new Error("No token specified. Use --token=<token> to provide a token.");
}

// Authenticate with github.
let github = new GitHubApi({ debug: argv.debug });

github.authenticate({
type: 'token',
token: argv.token
});

getLatestCommitFromPR();

function createStatus(sha) {
setDescription(); // Based on status of build - pending or success

github.repos.createStatus(Object.assign({}, statusConfig, { sha }),
(err, res) => {
if (err) {
throw new Error(`Failed to deploy pull request #${pr}. \n ${err}`);
}

console.log(`Successfully deployed pull request #${pr}`);
});
}


function getLatestCommitFromPR() {
github.pullRequests.get(Object.assign({}, REPO_DETAILS, { number: pr }), onGetLatestCommit);
}

function onGetLatestCommit(err, res) {
if (err)
throw new Error(`Failed to get latest commit. \n ${err}`);

// Extract the head sha from response. See https://developer.github.com/v3/pulls/#get-a-single-pull-request for full response details
if (res.head && res.head.sha)
createStatus(res.head.sha);
}

/*
The PR ID is input in the format 'refs/pull/12/merge'. This function returns just the number.
*/
function parsePRNumber() {
let splitString;

if (argv.prID) {
splitString = argv.prID.split('/');
}

if (!argv.prID || !splitString[2])
throw new Error(`Failed to get PR number. \n ${err}`);

return splitString[2];
}

/*
Set status text that will be posted to Github.
*/
function setDescription() {
if (argv.state === 'pending') {
statusConfig.description = 'Deployment pending.';
}
else if (argv.state === 'success') {
statusConfig.description = 'PR deployed. Click "Details" to view demo app.';
statusConfig.target_url = 'http://odsp-ext.azurewebsites.net/fabric-deploy-test/' + argv.prID;
}
}