Skip to content

Commit 4ae7d7e

Browse files
committed
Merge branch 'master' into feature/collate (#135)
2 parents 48b00d6 + b83d9d0 commit 4ae7d7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4958
-19380
lines changed

.github/workflows/cd.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This workflow is like CI, but also builds the documentation and deploys to NPM
2+
# and gh-pages.
3+
4+
name: Continuous Deployment
5+
6+
on:
7+
push:
8+
branches: [prepublish]
9+
workflow_run:
10+
workflows: [Prepublication staging]
11+
types: [completed]
12+
13+
jobs:
14+
deploy:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
ref: prepublish
22+
- name: Use Node.js 14.x
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: 14.x
26+
- name: Configure yarn cache path
27+
run: yarn config set cache-folder ~/.yarn-cache
28+
- name: Restore yarn cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.yarn-cache
32+
key: yarn-cache-14.x
33+
restore-keys: |
34+
yarn-cache-
35+
- name: Restore node_modules
36+
uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: node-modules-14.x-${{ hashFiles('yarn.lock') }}
40+
restore-keys: |
41+
node-modules-14.x-
42+
node-modules-
43+
- name: Install dependencies
44+
run: yarn
45+
- name: Build dist files and docs and run the tests
46+
run: yarn grunt dist docco tocdoc
47+
- name: Commit the build output
48+
uses: EndBug/add-and-commit@v5
49+
with:
50+
add: dist/ index.html
51+
message: Autocommit build output (continuous deployment)
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Publish to NPM
55+
run: yarn publish
56+
env:
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
58+
- name: Merge into gh-pages
59+
uses: devmasx/[email protected]
60+
with:
61+
type: now
62+
target_branch: gh-pages
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
- uses: actions/checkout@v2
65+
with:
66+
ref: gh-pages
67+
- name: Tag the release
68+
uses: Klemensas/action-autotag@stable
69+
with:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
tag_prefix: v

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will install the node_modules, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Continuous Integration
5+
6+
on:
7+
push:
8+
branches: [master]
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [10.x, 14.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: Configure yarn cache path
27+
run: yarn config set cache-folder ~/.yarn-cache
28+
- name: Restore yarn cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.yarn-cache
32+
key: yarn-cache-${{ matrix.node-version }}
33+
restore-keys: |
34+
yarn-cache-
35+
- name: Restore node_modules
36+
uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: node-modules-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
40+
restore-keys: |
41+
node-modules-${{ matrix.node-version }}-
42+
node-modules-
43+
- name: Install dependencies
44+
run: yarn
45+
- name: Run linter, concat, minifier and tests
46+
run: yarn dist

.github/workflows/prepublish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# As an alternative to a manual push to the prepublish branch, this workflow can
2+
# be triggered on a release branch by assigning a special label to its pull
3+
# request in order to set the CD circus in motion.
4+
5+
name: Prepublication staging
6+
7+
on:
8+
pull_request:
9+
types: [labeled]
10+
# Would filter by branch here, but GH Actions wrongly decides not to
11+
# trigger the workflow if we do this.
12+
13+
jobs:
14+
stage:
15+
runs-on: ubuntu-latest
16+
# Filtering by branch here instead. Credit due to @MiguelSavignano.
17+
# https://github.com/devmasx/merge-branch/issues/11
18+
if: contains(github.event.pull_request.head.ref, 'release/') || contains(github.event.pull_request.head.ref, 'hotfix/')
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Merge into prepublish
22+
uses: devmasx/[email protected]
23+
with:
24+
label_name: ready to launch
25+
target_branch: prepublish
26+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ docs/*.html
66
docs/public
77
examples/*.css
88
examples/*.html
9-
examples/public
9+
examples/public
10+
bower_components/*
11+
dist/
12+
/index.html

.jshintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"globals": {
3+
"_": true
4+
},
5+
"es3": true,
6+
"indent": 2,
7+
"camelcase": true,
8+
"eqnull": true,
9+
"forin": true,
10+
"newcap": true,
11+
"-W058": false
12+
}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### Changelog
2+
3+
#### 0.3.0
4+
5+
* Contrib now requires Underscore 1.6.0 or higher.
6+
* Rename `partition` and `partitionAll` to `chunk` and `chunkAll` to avoid name conflicts with Underscore's `partition` - [#115][115]
7+
* Added `toQuery` and `fromQuery` - [#134][134]
8+
* Switch `always` to an alias of Underscore's `constant`. - [#132][132]
9+
* The combinators sub-library now supports method combinators - [#14][14]
10+
11+
[115]:https://github.com/documentcloud/underscore-contrib/issues/115
12+
[134]:https://github.com/documentcloud/underscore-contrib/issues/134
13+
[132]:https://github.com/documentcloud/underscore-contrib/issues/132
14+
[14]:https://github.com/documentcloud/underscore-contrib/issues/14

CONTRIBUTING.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1-
## How to contribute to Underscore-contrib
1+
# How to contribute to Underscore-contrib
22

3-
* Before you open a ticket or send a pull request, [search](https://github.com/documentcloud/underscore-contrib/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
3+
## 1. Search the existing issues
44

5-
* Before sending a pull request for a feature, be sure to have [tests like found in Underscore](http://underscorejs.org/test/). Tests may be run in a browser by opening `test/index.html`. Tests and linting can be run in the terminal by using the `grunt test` command, or `grunt watch:test` to automatically rerun after file save.
5+
Before you open a ticket or send a pull request, [search](https://github.com/documentcloud/underscore-contrib/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
66

7-
* Use the same coding [style as Underscore](https://github.com/documentcloud/underscore/blob/master/underscore.js).
7+
## 2. Fork the project
88

9-
* In your pull request, do not add documentation, edit the files in `dist/` or use grunt to re-build the files in `dist/`. We'll do those things before cutting a new release.
9+
Create your own fork of contrib where you can make your changes.
10+
11+
## 3. Install development dependencies
12+
13+
Make sure you have [Node.js][node] and [Yarn][yarn] installed. Then install contrib's development dependencies with `yarn`. Note that these dependencies include the [Grunt CLI][cli] which we use for task automation.
14+
15+
## 4. Change the code
16+
17+
Make your code changes, ensuring they adhere to the same [coding style as Underscore][style]. Do **not** edit the files in `dist/`.
18+
19+
Make any necessary updates to the qUnit tests found in `test/`. Run `yarn test` to catch any test failures or lint issues. You can also use `yarn grunt watch:test` to get instant feedback each time you save a file.
20+
21+
## 5. Update the docs
22+
23+
Make any necessary documentation updates in `docs/`. Do **not** edit `index.html` directly.
24+
25+
After updating the docs, run `yarn tocdoc` to rebuild the `index.html` file. Visually inspect `index.html` in your browser to ensure the generated docs look nice.
26+
27+
## 6. Send a pull request
28+
29+
Send a pull request to `documentcloud/underscore-contrib` for feedback.
30+
31+
If modifications are necessary, make the changes and rerun `yarn test` or `yarn tocdoc` as needed.
32+
33+
And hopefully your pull request will be merged by the core team! :-)
34+
35+
[style]:https://github.com/documentcloud/underscore/blob/master/underscore.js
36+
[node]:http://nodejs.org/
37+
[yarn]:https://classic.yarnpkg.com/
38+
[cli]:http://gruntjs.com/getting-started#installing-the-cli

DEPLOYING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# How to cut a new release for Underscore-contrib
2+
3+
This is a checklist for repository maintainers. It covers all the steps involved in releasing a new version, including publishing to NPM and updating the `gh-pages` branch. We have tried to automate as many of these steps as possible using GitHub Actions. The workflows involved are in the (hidden) `.github` directory.
4+
5+
A "regular" release includes new changes that were introduced to the `master` branch since the previous release. A *hotfix* release instead skips any such changes and only addresses urgent problems with the previous release.
6+
7+
8+
## Steps
9+
10+
1. Ensure your local `master` branch descends from the previous release branch and that it is in a state that you want to release. **Exception:** for hotfixes, ensure you have an up-to-date local copy of the previous release branch instead.
11+
2. Decide on the next version number, respecting [semver][semver]. For the sake of example we'll use `1.2.3` as a placeholder version throughout this checklist.
12+
3. Create a `release/1.2.3` branch based on `master`. **Exception:** if this is a hotfix, start from the previous release branch instead and call it `hotfix/1.2.3`.
13+
4. Bump the version number in the `package.json` and the `yarn.lock` by running the command `yarn version --no-git-tag-version`, with the extra flag `--major`, `--minor` or `--patch` depending on which part of the version number you're incrementing (e.g., `--patch` if you're bumping from 1.2.2 to 1.2.3). Note that you can configure `yarn` to always include the `--no-git-tag-version` flag so you don't have to type it every time.
14+
5. Bump the version number in the source code and in `docs/index.md` accordingly.
15+
6. Commit the changes from steps 4 and 5 with a commit message of the format `Bump the version to 1.2.3`.
16+
7. Add more commits to extend the change log and to update any other documentation that might require it. Ensure that all documentation looks good.
17+
8. Push the release branch and create a pull request against `master` (also if it is a hotfix).
18+
9. At your option, have the release branch reviewed and add more commits to satisfy any change requests.
19+
10. The "Continuous Integration" workflow will trigger automatically on the pull request. This runs the test suite against multiple environments. Wait for all checks to complete.
20+
11. If any checks fail, add more commits to fix and repeat from step 10.
21+
12. When all reviewers are satisfied and all checks pass, apply the "ready to launch" label to the pull request. This will trigger the "Prepublication staging" workflow, which will merge the release branch into the `prepublish` branch. Merge manually if the workflow fails for whatever reason. **Note:** do *not* merge into `master` yet.
22+
13. The merging of new changes into `prepublish` will trigger the "Continuous Deployment" workflow, which is documented below. **Pay attention as the deployment workflow progresses.**
23+
14. If the deployment workflow fails, identify the failing step and address as quickly as possible. Possible solution steps include:
24+
- Adding new commits to the release branch and repeating from step 12 (most likely if the docs fail to build for some reason).
25+
- Manually pushing new commits to the `prepublish` branch and repeating from step 13 (this might be needed in case of merge conflicts, although this is highly unlikely).
26+
- Manually running `yarn publish` (if something is wrong with the NPM registry or the authentication credentials).
27+
- Manually merging `prepublish` into `gh-pages` (in unlikely case of merge conflicts).
28+
- Manually tagging the release on `gh-pages`.
29+
15. When the deployment workflow has completed, double-check that the new version was published to NPM, that the website was updated and that the repository contains a tag for the new release.
30+
16. Finally merge the release branch into `master`, but keep the branch around for a few days in case you need to do a hotfix.
31+
17. Delete the release branch. You can still restore it if necessary, by tracing the history graph two commits back from the release tag.
32+
33+
34+
## Automated continuous deployment workflow
35+
36+
This workflow is defined in `.github/workflows/cd.yml`. Note that roughly the first half of the steps in that file consists of basic boilerplate to check out the source and install dependencies.
37+
38+
The publishing to NPM depends on a [secret][secrets] named `NPM_TOKEN`, representing the API token of the NPM account that owns the `underscore-contrib` package. Only admins of the documentcloud organization can access this setting.
39+
40+
1. Checkout the source, restore caches and install the dependencies.
41+
2. Run `yarn grunt dist docco tocdoc`.
42+
3. Commit the output of the previous step to the `prepublish` branch.
43+
4. Publish to NPM.
44+
5. Merge the `prepublish` branch into `gh-pages`.
45+
6. Tag the tip of `gh-pages` with the version number in the `package.json`.
46+
47+
48+
[semver]: https://semver.org
49+
[secrets]: https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets

Gruntfile.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ module.exports = function(grunt) {
4444
"test/*.js"
4545
],
4646
options: {
47-
es3: true, // Enforce ES3 compatibility
48-
indent: 2, // Indent by 2 spaces
49-
camelcase: true, // All vars must be camelCase or UPPER_WITH_UNDERSCORES
50-
eqnull: true, // Allow 'x == null' convention
51-
forin: true, // Require `for x in y` to filter with `hasOwnProperty`
52-
newcap: true, // Require constructor names to be capitalized
53-
"-W058": false // Allow 'new Constructor' without parens
47+
jshintrc: true
5448
}
5549
},
5650

@@ -67,7 +61,13 @@ module.exports = function(grunt) {
6761
tocdoc: {
6862
api: {
6963
files: {
70-
'index.html': 'docs/*.md'
64+
'index.html': ['docs/*.md', 'CHANGELOG.md']
65+
},
66+
options: {
67+
scripts: [
68+
'test/vendor/underscore.js',
69+
'dist/underscore-contrib.js'
70+
]
7171
}
7272
}
7373
},
@@ -88,8 +88,8 @@ module.exports = function(grunt) {
8888
}
8989
});
9090

91-
grunt.registerTask("test", ["jshint", "qunit:main"]);
92-
grunt.registerTask("dist", ["concat", "uglify"]);
91+
grunt.registerTask('test', ['jshint', 'qunit:main']);
9392
grunt.registerTask('default', ['test']);
9493
grunt.registerTask('dist', ['test', 'concat', 'qunit:concat', 'uglify', 'qunit:min']);
94+
grunt.registerTask('doc', ['test', 'tocdoc']);
9595
};

bower.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "underscore-contrib",
3+
"version": "0.3.0",
4+
"main": "dist/underscore-contrib.min.js",
5+
"homepage": "https://github.com/documentcloud/underscore-contrib",
6+
"authors": [
7+
8+
],
9+
"description": "The brass buckles on Underscore's utility belt",
10+
"keywords": [
11+
"underscore",
12+
"underscorejs",
13+
"documentcloud",
14+
"functional",
15+
"javascript"
16+
],
17+
"license": "MIT",
18+
"ignore": [
19+
"**/.*",
20+
"node_modules",
21+
"bower_components",
22+
"test",
23+
"tests"
24+
],
25+
"dependencies" : {
26+
"underscore" : ">=1.6.0"
27+
}
28+
}

0 commit comments

Comments
 (0)