Skip to content

Commit e913dc5

Browse files
committedDec 3, 2019
chore: restructure build commands
- move dtslint (checkTypes) away from Gruntfile.js (as it disturbs debugging `grunt`) and call it directly as npm-script in travis-ci - re-group task definition in Gruntfile.js - use a multi-job travis build to run linting, format, dtslint and tests in parallel - run only "npm test" on appveyor - rename Grunt-tasks for be more descriptive - SAUCE_USERNAME is not a secret variable anymore it can be easily guessed anyway and the [secure] value messes up with a lot of the log output - linting on commit disable during transition
1 parent 1f61f21 commit e913dc5

File tree

7 files changed

+310
-62
lines changed

7 files changed

+310
-62
lines changed
 

‎.travis.yml

+40-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,47 @@
11
language: node_js
2-
before_install:
3-
- npm install -g grunt-cli
4-
script:
5-
- npm run lint
6-
- npm run check-format
7-
- grunt --stack travis
2+
3+
jobs:
4+
include:
5+
- stage: test
6+
name: "check javascript (eslint)"
7+
node_js: lts/*
8+
script: npm run lint
9+
10+
- stage: test
11+
name: "check formatting (prettier)"
12+
node_js: lts/*
13+
script: npm run check-format
14+
15+
- stage: test
16+
name: "check typescript definitions (dtslint)"
17+
node_js: lts/*
18+
script: npm run dtslint
19+
20+
- stage: test
21+
name: "extensive tests and publish to aws"
22+
script: npm run extensive-tests-and-publish-to-aws
23+
env:
24+
- S3_BUCKET_NAME=builds.handlebarsjs.com
25+
- secure: ckyEe5dzjdFDjmZ6wIrhGm0CFBEnKq8c1dYptfgVV/Q5/nJFGzu8T0yTjouS/ERxzdT2H327/63VCxhFnLCRHrsh4rlW/rCy4XI3O/0TeMLgFPa4TXkO8359qZ4CB44TBb3NsJyQXNMYdJpPLTCVTMpuiqqkFFOr+6OeggR7ufA=
26+
- secure: Nm4AgSfsgNB21kgKrF9Tl7qVZU8YYREhouQunFracTcZZh2NZ2XH5aHuSiXCj88B13Cr/jGbJKsZ4T3QS3wWYtz6lkyVOx3H3iI+TMtqhD9RM3a7A4O+4vVN8IioB2YjhEu0OKjwgX5gp+0uF+pLEi7Hpj6fupD3AbbL5uYcKg8=
27+
- SAUCE_USERNAME=handlebars
28+
- secure: yERYCf7AwL11D9uMtacly/THGV8BlzsMmrt+iQVvGA3GaY6QMmfYqf6P6cCH98sH5etd1Y+1e6YrPeMjqI6lyRllT7FptoyOdHulazQe86VQN4sc0EpqMlH088kB7gGjTut9Z+X9ViooT5XEh9WA5jXEI9pXhQJNoIHkWPuwGuY=
29+
node_js: "10"
30+
31+
- stage: test
32+
name: "test with latest nodejs-lts"
33+
node_js: lts/*
34+
script: npm run test
35+
36+
- stage: test
37+
name: "test with active nodejs"
38+
node_js: node
39+
script: npm run test
40+
41+
cache: npm
842
email:
943
on_failure: change
1044
on_success: never
11-
env:
12-
global:
13-
- S3_BUCKET_NAME=builds.handlebarsjs.com
14-
- secure: ckyEe5dzjdFDjmZ6wIrhGm0CFBEnKq8c1dYptfgVV/Q5/nJFGzu8T0yTjouS/ERxzdT2H327/63VCxhFnLCRHrsh4rlW/rCy4XI3O/0TeMLgFPa4TXkO8359qZ4CB44TBb3NsJyQXNMYdJpPLTCVTMpuiqqkFFOr+6OeggR7ufA=
15-
- secure: Nm4AgSfsgNB21kgKrF9Tl7qVZU8YYREhouQunFracTcZZh2NZ2XH5aHuSiXCj88B13Cr/jGbJKsZ4T3QS3wWYtz6lkyVOx3H3iI+TMtqhD9RM3a7A4O+4vVN8IioB2YjhEu0OKjwgX5gp+0uF+pLEi7Hpj6fupD3AbbL5uYcKg8=
16-
matrix:
17-
include:
18-
- node_js: '10'
19-
env:
20-
- PUBLISH=true
21-
- secure: pLTzghtVll9yGKJI0AaB0uI8GypfWxLTaIB0ZL8//yN3nAEIKMhf/RRilYTsn/rKj2NUa7vt2edYILi3lttOUlCBOwTc9amiRms1W8Lwr/3IdWPeBLvLuH1zNJRm2lBAwU4LBSqaOwhGaxOQr6KHTnWudhNhgOucxpZfvfI/dFw=
22-
- secure: yERYCf7AwL11D9uMtacly/THGV8BlzsMmrt+iQVvGA3GaY6QMmfYqf6P6cCH98sH5etd1Y+1e6YrPeMjqI6lyRllT7FptoyOdHulazQe86VQN4sc0EpqMlH088kB7gGjTut9Z+X9ViooT5XEh9WA5jXEI9pXhQJNoIHkWPuwGuY=
23-
cache:
24-
directories:
25-
- node_modules
2645

2746
git:
2847
depth: 100

‎CONTRIBUTING.md

+31-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ Documentation issues on the handlebarsjs.com site should be reported on [handleb
1212

1313
## Branches
1414

15-
* The branch `4.x` contains the currently released version. Bugfixes should be made in this branch.
16-
* The branch `master` contains the next version. A release date is not yet specified. Maintainers
15+
- The branch `4.x` contains the currently released version. Bugfixes should be made in this branch.
16+
- The branch `master` contains the next version. A release date is not yet specified. Maintainers
1717
should merge the branch `4.x` into the master branch regularly.
1818

1919
## Pull Requests
2020

2121
We also accept [pull requests][pull-request]!
2222

2323
Generally we like to see pull requests that
24+
2425
- Maintain the existing code style
2526
- Are focused on a single change (i.e. avoid large refactoring or style adjustments in untouched code if not the primary goal of the pull request)
2627
- Have [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
@@ -31,8 +32,8 @@ Generally we like to see pull requests that
3132

3233
To build Handlebars.js you'll need a few things installed.
3334

34-
* Node.js
35-
* [Grunt](http://gruntjs.com/getting-started)
35+
- Node.js
36+
- [Grunt](http://gruntjs.com/getting-started)
3637

3738
Before building, you need to make sure that the Git submodule `spec/mustache` is included (i.e. the directory `spec/mustache` should not be empty). To include it, if using Git version 1.6.5 or newer, use `git clone --recursive` rather than `git clone`. Or, if you already cloned without `--recursive`, use `git submodule update --init`.
3839

@@ -51,22 +52,43 @@ If you notice any problems, please report them to the GitHub issue tracker at
5152
##Running Tests
5253

5354
To run tests locally, first install all dependencies.
55+
5456
```sh
5557
npm install
5658
```
5759

5860
Clone the mustache specs into the spec/mustache folder.
61+
5962
```sh
6063
cd spec
6164
rm -r mustache
6265
git clone https://github.com/mustache/spec.git mustache
6366
```
6467

6568
From the root directory, run the tests.
69+
6670
```sh
6771
npm test
6872
```
6973

74+
## Linting and Formatting
75+
76+
Handlebars uses `eslint` to enforce best-practices and `prettier` to auto-format files.
77+
We do linting and formatting in two phases:
78+
79+
- Committed files are linted and formatted in a pre-commit hook. In this stage eslint-errors are forbidden,
80+
while warnings are allowed.
81+
- The travis-ci job also lints all files and checks if they are formatted correctly. In this stage, warnings
82+
are forbidden.
83+
84+
You can use the following scripts to make sure that the travis-job does not fail:
85+
86+
- **npm run lint** will run `eslint` and fail on warnings
87+
- **npm run format** will run `prettier` on all files
88+
- **npm run check-before-pull-request** will perform all most checks that travis does in its build-job, excluding the "integration-test".
89+
- **npm run integration-test** will run integration tests (using old NodeJS versions and integrations with webpack, babel and so on)
90+
These tests only work on a Linux-machine with `nvm` installed (for running tests in multiple versions of NodeJS).
91+
7092
## Ember testing
7193

7294
The current ember distribution should be tested as part of the handlebars release process. This requires building the `handlebars-source` gem locally and then executing the ember test script.
@@ -83,7 +105,7 @@ npm test
83105

84106
## Releasing the latest version
85107

86-
*When releasing a previous version of Handlebars, please look into the CONTRIBUNG.md in the corresponding branch.*
108+
_When releasing a previous version of Handlebars, please look into the CONTRIBUNG.md in the corresponding branch._
87109

88110
Handlebars utilizes the [release yeoman generator][generator-release] to perform most release tasks.
89111

@@ -103,10 +125,10 @@ gem push handlebars-source-*.gem
103125
After the release, you should check that all places have really been updated. Especially verify that the `latest`-tags
104126
in those places still point to the latest version
105127

106-
* [The npm-package](https://www.npmjs.com/package/handlebars) (check latest-tag)
107-
* [The bower package](https://github.com/components/handlebars.js) (check the package.json)
108-
* [The AWS S3 Bucket](https://s3.amazonaws.com/builds.handlebarsjs.com) (check latest-tag)
109-
* [RubyGems](https://rubygems.org/gems/handlebars-source)
128+
- [The npm-package](https://www.npmjs.com/package/handlebars) (check latest-tag)
129+
- [The bower package](https://github.com/components/handlebars.js) (check the package.json)
130+
- [The AWS S3 Bucket](https://s3.amazonaws.com/builds.handlebarsjs.com) (check latest-tag)
131+
- [RubyGems](https://rubygems.org/gems/handlebars-source)
110132

111133
When everything is OK, the handlebars site needs to be updated to point to the new version numbers. The jsfiddle link should be updated to point to the most recent distribution for all instances in our documentation.
112134

‎Gruntfile.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ module.exports = function(grunt) {
175175
},
176176

177177
bgShell: {
178-
checkTypes: {
179-
cmd: 'npm run checkTypes',
180-
bg: false,
181-
fail: true
182-
},
183178
integrationTests: {
184179
cmd: './integration-testing/run-integration-tests.sh',
185180
bg: false,
@@ -195,25 +190,11 @@ module.exports = function(grunt) {
195190
},
196191

197192
files: ['src/*', 'lib/**/*.js', 'spec/**/*.js'],
198-
tasks: ['build', 'amd', 'tests', 'test']
193+
tasks: ['on-file-change']
199194
}
200195
}
201196
});
202197

203-
// Build a new version of the library
204-
this.registerTask('build', 'Builds a distributable version of the current project', [
205-
'bgShell:checkTypes',
206-
'parser',
207-
'node',
208-
'globals']);
209-
210-
this.registerTask('amd', ['babel:amd', 'requirejs']);
211-
this.registerTask('node', ['babel:cjs']);
212-
this.registerTask('globals', ['webpack']);
213-
this.registerTask('tests', ['concat:tests']);
214-
215-
this.registerTask('release', 'Build final packages', ['amd', 'uglify', 'test:min', 'copy:dist', 'copy:components', 'copy:cdnjs']);
216-
217198
// Load tasks from npm
218199
grunt.loadNpmTasks('grunt-contrib-clean');
219200
grunt.loadNpmTasks('grunt-contrib-concat');
@@ -229,11 +210,33 @@ module.exports = function(grunt) {
229210

230211
grunt.task.loadTasks('tasks');
231212

213+
this.registerTask(
214+
'build',
215+
'Builds a distributable version of the current project',
216+
['parser', 'node', 'globals']
217+
);
218+
219+
this.registerTask('node', ['babel:cjs']);
220+
this.registerTask('globals', ['webpack']);
221+
222+
this.registerTask('release', 'Build final packages', [
223+
'amd',
224+
'uglify',
225+
'test:min',
226+
'copy:dist',
227+
'copy:components',
228+
'copy:cdnjs'
229+
]);
230+
231+
this.registerTask('amd', ['babel:amd', 'requirejs']);
232+
232233
grunt.registerTask('bench', ['metrics']);
233234
grunt.registerTask('sauce', process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : []);
235+
// Requires secret properties (saucelabs-credentials etc.) from .travis.yaml
236+
grunt.registerTask('extensive-tests-and-publish-to-aws', ['default', 'bgShell:integrationTests', 'sauce', 'metrics', 'publish:latest']);
237+
grunt.registerTask('on-file-change', ['build', 'amd', 'concat:tests', 'test']);
234238

235-
grunt.registerTask('travis', process.env.PUBLISH ? ['default', 'bgShell:integrationTests', 'sauce', 'metrics', 'publish:latest'] : ['default']);
236-
239+
// === Primary tasks ===
237240
grunt.registerTask('dev', ['clean', 'connect', 'watch']);
238241
grunt.registerTask('default', ['clean', 'build', 'test', 'release']);
239242
grunt.registerTask('integration-tests', ['default', 'bgShell:integrationTests']);

‎appveyor.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ install:
1313
# Clone submodules (mustache spec)
1414
- cmd: git submodule update --init --recursive
1515
# Install modules
16-
- cmd: npm install
17-
- cmd: npm install -g grunt-cli
16+
- cmd: npm ci
1817

1918

2019
# Post-install test scripts
@@ -23,7 +22,7 @@ test_script:
2322
- cmd: node --version
2423
- cmd: npm --version
2524
# Run tests
26-
- cmd: grunt --stack travis
25+
- cmd: npm run test
2726

2827
# Don't actually build
2928
build: off
@@ -34,4 +33,4 @@ on_failure:
3433

3534

3635
# Set build version format here instead of in the admin panel
37-
version: "{build}"
36+
version: "{build}"

‎integration-testing/multi-nodejs-test/test.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
1212
# It does (almost) not test for correctness, because that is already done in the mocha-tests.
1313
# And it does not use any NodeJS based testing framwork to make this part independent of the Node version.
1414

15-
# A list of NodeJS versions is expected as cli-args
15+
unset npm_config_prefix
16+
1617
echo "Handlebars should be able to run in various versions of NodeJS"
1718
for i in 0.10 0.12 4 5 6 7 8 9 10 11 ; do
1819
rm target node_modules package-lock.json -rf
@@ -23,4 +24,4 @@ for i in 0.10 0.12 4 5 6 7 8 9 10 11 ; do
2324
nvm exec "$i" npm run test-precompile || exit 1
2425

2526
echo Success
26-
done
27+
done

‎package-lock.json

+199
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"babel-runtime": "^5.1.10",
3636
"benchmark": "~1.0",
3737
"chai": "^4.2.0",
38+
"concurrently": "^5.0.0",
3839
"dirty-chai": "^2.0.1",
3940
"dtslint": "^0.5.5",
4041
"dustjs-linkedin": "^2.0.2",
@@ -82,9 +83,13 @@
8283
"scripts": {
8384
"format": "prettier --write '**/*.js' && eslint --fix .",
8485
"check-format": "prettier --check '**/*.js'",
85-
"lint": "eslint .",
86-
"checkTypes": "dtslint types",
87-
"test": "grunt"
86+
"lint": "eslint --max-warnings 0 . ",
87+
"dtslint": "dtslint types",
88+
"test": "grunt",
89+
"extensive-tests-and-publish-to-aws": "grunt --stack extensive-tests-and-publish-to-aws",
90+
"integration-test": "grunt integration-tests",
91+
"--- combined tasks ---": "",
92+
"check-before-pull-request": "concurrently --kill-others-on-fail npm:lint npm:dtslint npm:check-format npm:test"
8893
},
8994
"jspm": {
9095
"main": "handlebars",
@@ -108,7 +113,7 @@
108113
],
109114
"husky": {
110115
"hooks": {
111-
"pre-commit": "lint-staged"
116+
"pre-commit": "true || lint-staged"
112117
}
113118
},
114119
"lint-staged": {

0 commit comments

Comments
 (0)
Please sign in to comment.