Skip to content

Run test:saucelabs script on CI #307

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

Merged
merged 6 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ addons:

before_install:
- nvm install 8
- npm install -g gulp
- npm install -g [email protected]

install:
Expand All @@ -21,5 +20,5 @@ language: java
script:
- npm run checkFormat
- npm run lint
- gulp test:saucelabs
- npm run test:saucelabs
- npm run test:isomorphic
123 changes: 103 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,132 @@ repo. It's perfect for this use case and it's been used by

The repo is divided into packages, which are:
* [metal](http://npmjs.com/package/metal)
* [metal-assertions](http://npmjs.com/package/metal-assertions)
* [metal-component](http://npmjs.com/package/metal-component)
* [metal-dom](http://npmjs.com/package/metal-dom)
* [metal-events](http://npmjs.com/package/metal-events)
* [metal-incremental-dom](http://npmjs.com/package/metal-incremental-dom)
* [metal-jsx](http://npmjs.com/package/metal-jsx)
* [metal-soy](http://npmjs.com/package/metal-soy)
* [metal-soy-bundle](http://npmjs.com/package/metal-soy-bundle)
* [metal-state](http://npmjs.com/package/metal-state)
* [metal-web-component](http://npmjs.com/package/metal-web-component)

Each package has its own package.json and is set up so that it provides two
types of entry points: one for commonjs usage (**main**) and another for ES6
modules (**jsnext:main**). Check out metal-dom's
[package.json](packages/metal-dom/package.json#L11) file as an example.

## Contributing requirements
## Pull requests & Github issues

### Tests
* All pull requests should be sent to the `develop` branch, as the `master`
branch should always reflect the most recent release.
* Any merged changes will remain in the `develop` branch until the next
scheduled release.
* The only exception to this rule is for emergency hot fixes, in which case the
pull request can be sent to the `master` branch.
* A Github issue should also be created for any bug fix or feature, this helps
when generating the CHANGELOG.md file.

## Tests

Any change (be it an improvement, a new feature or a bug fix) needs to include
a test, and all tests from the repo need to be passing. To run the tests you
can use our gulp tasks:
can use our npm script:

```
npm test
```

## Formatting

Run the format script to automatically format any changes:

* `gulp test` Runs all tests once
* `gulp test:coverage` Runs all tests once and shows a summary coverage
report.
* `gulp test:coverage:open` Runs all tests once and opens a detailed coverage
report in the browser.
* `gulp test:watch` Runs all tests and listens for changes, rerunning them
automatically.
```
npm run format
```

### Lint
Once it's done formatting, run the lint script:

Lint errors need to be fixed. To lint the code just run: `gulp lint`.
```
npm run lint
```

### JS Docs
If there are any linting errors at this point, they must be addressed manually.

If you would like to see a list of our formatting standards check
out [our docs](https://hosting-liferayfrontendguidelines.wedeploy.io/).

## JS Docs

All methods should be documented, following [google's format](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler).

## Publishing Metal.js
# Releasing

Collaborators with publish permissions should follow these steps.

There are two different workflows for publishing this project, one for scheduled
releases, and one for emergency hot fixes.

## Scheduled release

1. Create a release branch from the updated `develop` branch

```
git checkout develop
git pull upstream develop
git checkout -b release/vX.X.X
```

2. Send release PR to `master`

3. Wait to see that all tests pass and then merge with merge commit

4. Checkout and pull `master` locally

```
git checkout master && git pull upstream master
```

5. Publish npm modules and push release tags

```
lerna publish (major/minor/patch accordingly)
```

6. Generate changelog

github_changelog_generator (https://github.com/skywinder/github-changelog-generator)

7. Commit changelog and push to `master`

```
git add CHANGELOG.md
git commit -m "Updates CHANGELOG for vX.X.X"
git push
```

8. Sync `develop` with `master`

```
git checkout develop
git merge master
```

9. Do GitHub release using the pushed vX.X.X tag and the appropriate portion of
CHANGELOG.md

## Hot fix

1. Create a feature branch from `master` (assuming hot fix has already been
merged)

```
git checkout master
git pull upstream master
git checkout -b feature/fix_foo
```

Collaborators with publish permissions should follow the following steps:
2. Send a fix PR to `master`

1. Make sure that the [CI tests](https://travis-ci.org/metal/metal.js/builds)
are passing.
2. Run `lerna publish`.
3. Edit the release in [github](https://github.com/metal/metal.js/releases) with
details about what has changed.
3. Follow steps 3-9 of a scheduled release
153 changes: 7 additions & 146 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,160 +1,21 @@
'use strict';

var babel = require('gulp-babel');
var compileSoy = require('metal-tools-soy/lib/pipelines/compileSoy');
var gulp = require('gulp');
var karma = require('karma');
var metal = require('gulp-metal');
var path = require('path');
var replace = require('gulp-replace');

var codeGlobs = [
'packages/metal*/src/**/*.js',
'packages/metal*/test/**/*.js',
'!packages/metal*/**/*.soy.js',
'!packages/metal-incremental-dom/**/incremental-dom.js',
'gulpfile.js',
'karma.conf.js',
'karma-coverage.conf.js'
];

metal.registerTasks({
bundleFileName: 'metal.js',
formatGlobs: codeGlobs,
karma: require('karma'),
lintGlobs: codeGlobs,
testDepTasks: ['build:cjs'],
testNodeSrc: [
// Since all files will be added, we need to ensure manually that these
// will be added first.
'packages/metal-incremental-dom/lib/incremental-dom.js',

// Test files
'env/test/node.js',
'packages/metal/test/**/*.js',
'packages/metal-component/test/**/*.js',
'packages/metal-dom/test/**/*.js',
'packages/metal-events/test/**/*.js',
'packages/metal-incremental-dom/test/**/*.js',
'packages/metal-jsx/test/**/*.js',
'packages/metal-soy/test/**/*.js',
'packages/metal-state/test/**/*.js'
],
testSaucelabsBrowsers: {
sl_chrome: {
base: 'SauceLabs',
browserName: 'chrome'
},
sl_safari_8: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.10'
},
sl_safari_10: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.12',
version: '10'
},
sl_firefox: {
base: 'SauceLabs',
browserName: 'firefox'
},
sl_ie_9: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
},
sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '10'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
},
sl_edge_15: {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: '15'
},
sl_android_4: {
base: 'SauceLabs',
browserName: 'android',
platform: 'Linux',
version: '4.4'
},
sl_android_5: {
base: 'SauceLabs',
browserName: 'android',
platform: 'Linux',
version: '5.0'
}
},
useEslint: true
});
let compileSoy = require('metal-tools-soy/lib/pipelines/compileSoy');
let gulp = require('gulp');
let replace = require('gulp-replace');

gulp.task('soy', function() {
return gulp.src('packages/metal-soy/test/**/*.soy')
return gulp
.src('packages/metal-soy/test/**/*.soy')
.pipe(compileSoy())
.pipe(replace('metal-soy', '../..'))
.pipe(replace('metal-component/src/Component', 'metal-component'))
.pipe(gulp.dest('packages/metal-soy/test'));
});

gulp.task('soy:isomorphic', function() {
return gulp.src('packages/metal-isomorphic/test/**/*.soy')
return gulp
.src('packages/metal-isomorphic/test/**/*.soy')
.pipe(compileSoy())
.pipe(gulp.dest('packages/metal-isomorphic/test'));
});

gulp.task('build:cjs', ['soy'], function() {
return compileToLib('packages/metal*/src/**/*.js');
});

var changedJsSrc;
gulp.task('compile', function() {
return compileToLib(changedJsSrc);
});

// We need to override gulp-metal's default test:watch task so that it will
// update lib files when the related src files change.
gulp.task('test:watch', ['build:cjs'], function(done) { // eslint-disable-line
gulp.watch('packages/metal-soy/test/**/*.soy', ['soy']);
var jsWatcher = gulp.watch('packages/metal*/src/**/*.js', ['compile']);
jsWatcher.on('change', function(event) {
changedJsSrc = event.path;
});

new karma.Server(
{
configFile: path.resolve('karma.conf.js')
}
).start();
});

function calcDestDir(file) {
var relative = path.relative(path.resolve('packages'), file.path);
var index = relative.indexOf(path.sep);
file.base = path.dirname(file.path);
return path.dirname(path.join(
path.resolve('packages'),
relative.substr(0, index),
'lib',
relative.substr(index + 5)
));
}

function compileToLib(src) {
return gulp.src(src)
.pipe(babel({
presets: ['env']
}))
.pipe(gulp.dest(calcDestDir));
}
Loading