Skip to content

Commit 10a0695

Browse files
authored
docs: Updates developer setup to contributor guide (#2542)
Adds link to recommended workspace and clarifies testing setup
1 parent d4502aa commit 10a0695

File tree

1 file changed

+39
-126
lines changed

1 file changed

+39
-126
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -11,123 +11,29 @@ please follow it in all your interactions with the project.
1111

1212
### Runtime
1313

14-
It's recommended you install Node Version Manager for [unix systems][nvm-unix] or [windows][nvm-windows]. While it isn't required we have a minimum node version requirement (look in package.json under the "engines" key) and we can't accept code that does not work on the minimum specified version.
14+
It's recommended you install Node Version Manager for [unix systems][nvm-unix] or [windows][nvm-windows].
15+
While it isn't required we have a minimum node version requirement (look in [package.json](./package.json) under the "engines" key) and we can't accept code that does not work on the minimum specified version.
1516

1617
### MongoDB Helpers
1718

18-
- To get various MongoDB topologies up and running easily you can use the python based tool [mtools][mtools-install].
19-
- To get various versions of MongoDB to test against you can use [m](https://github.com/aheckmann/m) an npm tool best installed globally `npm i -g m`.
19+
- For setting up a cluster to test against we recommend using [mtools][mtools-install].
20+
- For managing installed versions of MongoDB, we recommend using [m](https://github.com/aheckmann/m).
2021

2122
### VSCode Setup
2223

23-
If you are developing in VSCode here's some suggestions:
24-
We have an example of our workspace file: save this as `mongodbNodeDriver.code-workspace` and replace PATH_TO_DRIVER with the path to the driver repository on your computer.
25-
26-
<details>
27-
<summary>mongodbNodeDriver.code-workspace</summary>
28-
<br>
29-
<pre lang="jsonc">
30-
{
31-
"folders": [
32-
{
33-
"path": "PATH_TO_DRIVER",
34-
"name": "driver"
35-
}
36-
],
37-
"settings": {
38-
"search.exclude": {
39-
// I always set 'file to include' in search to:
40-
// - src
41-
// - test
42-
// - {test|src}
43-
"**/node_modules": false, // searching node_modules comes in handy
44-
"./lib": true, // by default I don't want results from our compiled source
45-
"**/bower_components": true,
46-
"**/*.code-search": true
47-
},
48-
// ts gives me the power to not rely on word matching
49-
"editor.wordBasedSuggestions": false,
50-
"gitlens.hovers.enabled": false,
51-
"editor.codeActionsOnSave": {
52-
"source.fixAll.eslint": true
53-
},
54-
"[javascript]": {
55-
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
56-
},
57-
"[typescript]": {
58-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
59-
"editor.codeActionsOnSave": {
60-
"source.organizeImports": false
61-
}
62-
},
63-
"eslint.enable": true,
64-
"eslint.format.enable": true,
65-
"mochaExplorer.files": "test/{functional,unit}/**/*.test.js",
66-
"mochaExplorer.ui": "test/tools/runner/metadata_ui.js",
67-
"editor.formatOnSave": false,
68-
"editor.rulers": [100],
69-
"editor.renderWhitespace": "selection",
70-
"files.trimTrailingWhitespace": true,
71-
"files.trimFinalNewlines": true,
72-
"files.insertFinalNewline": true,
73-
"typescript.tsdk": "node_modules/typescript/lib",
74-
// I leave the coverage extension disabled when not using it so I leave these commented
75-
// but these settings are nice when it is enabled
76-
// "coverage-gutters.showGutterCoverage": false,
77-
// "coverage-gutters.showLineCoverage": true,
78-
},
79-
"launch": {
80-
"configurations": [
81-
{
82-
// Sometimes I need to run mocha myself and not via the sidebar
83-
// Here I can add custom args or env variables
84-
"name": "run mocha",
85-
"type": "pwa-node",
86-
"request": "launch",
87-
"program": "node_modules/.bin/mocha",
88-
"args": ["test/unit", "test/functional"]
89-
}
90-
],
91-
"compounds": []
92-
},
93-
"tasks": {
94-
"version": "2.0.0",
95-
"tasks": [
96-
{
97-
// Here is an optional watcher task (`npm test` will also type check you changes):
98-
// Since this is the default build task it can be started with cmd+shift+b
99-
// There will be a wrench and screw icon
100-
// on the bottom bar where you can quick check build issues
101-
"label": "watch TS",
102-
"command": "npx",
103-
"type": "shell",
104-
"args": ["tsc", "-w"],
105-
"problemMatcher": "$tsc-watch",
106-
"isBackground": true,
107-
"group": {
108-
"kind": "build",
109-
"isDefault": true
110-
}
111-
}
112-
]
113-
},
114-
"extensions": {
115-
"recommendations": [
116-
"dbaeumer.vscode-eslint",
117-
"hbenl.vscode-test-explorer",
118-
"hbenl.vscode-mocha-test-adapter",
119-
"ryanluker.vscode-coverage-gutters",
120-
"github.vscode-pull-request-github",
121-
"mongodb.mongodb-vscode"
122-
],
123-
"unwantedRecommendations": ["esbenp.prettier-vscode"]
124-
}
125-
}
126-
</pre>
127-
</details>
24+
- Save the the workspace file [mongodbNodeDriver.code-workspace][workspace-file] next to where you have the driver cloned to and open this in VSCode.
25+
Double check that the `folders.path` at the top of the file's json is correct.
26+
27+
- We recommended these extensions:
28+
- [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
29+
- [test-explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer)
30+
- [mocha-test-adapter](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter)
31+
- [coverage-gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters)
32+
- [pull-request-github](https://marketplace.visualstudio.com/items?itemName=github.vscode-pull-request-github)
33+
- [mongodb](https://marketplace.visualstudio.com/items?itemName=mongodb.mongodb-vscode)
34+
- [gitlens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
12835

129-
If you use this file you will get our recommended extensions suggested to you.
130-
If not, we recommend picking up `dbaeumer.vscode-eslint` at least to make sure any additional code is following style recommendations. If you don't want to use this workspace file but still don't want to think about formatting you can have VSCode do the checks and formatting work for you by adding just these settings:
36+
If you just want to get formatting and linting working automatically use these settings:
13137

13238
```jsonc
13339
"settings":{
@@ -145,17 +51,21 @@ If not, we recommend picking up `dbaeumer.vscode-eslint` at least to make sure a
14551

14652
### Running the tests
14753

148-
Running the tests:
54+
- Start a mongod standalone with our [cluster_setup.sh](test/tools/cluster_setup.sh) script
55+
- Usage: `./test/tools/cluster_setup.sh server`
56+
- Run the tests with `npm test`
57+
58+
### Tests FAQ
14959

150-
- You can use the script: `test/tools/cluster_setup.sh server`
151-
- If you are running against more than a standalone make sure your ulimit settings are in accordance with mongo's recommendations
60+
- How can I run the tests against more than a standalone?
61+
- You can use the `test/tools/cluster_setup.sh replica_set`
62+
- You can prefix the npm test with a MONGODB_URI environment variable to point the tests to the correct deployment
63+
- `env MONGODB_URI=mongodb://localhost:27017 npm test`
64+
- If you are running against more than a standalone make sure your ulimit settings are in accordance with mongo's recommendations
15265
- Changing the settings on the latest versions of [macos can be tricky read here][macos-ulimt] (unless you know you need it you shouldn't have to do the complicated maxproc steps)
153-
- Prefix the cluster_setup.sh script with `env MONGODB_VERSION=X.Y` to test against a specific version of the server
154-
- `env MONGODB_URI=mongodb://localhost:27017 npm test`
155-
- When testing different topologies you may need to remove the existing data folder created.
156-
- To run a single test, use `npm run test -- -g 'test name'`
157-
- If it's easier you can also isolate tests by adding .only. Example: `it.only(‘cool test’, {})`
158-
- To test only the unified topology, use `env MONGODB_UNIFIED_TOPOLOGY=1`
66+
- How can I run just one test?
67+
- To run a single test, use mocha's grep flag: `npm run test -- -g 'test name'`
68+
- If it's easier you can also isolate tests by adding `.only` Example: `it.only(‘cool test’, function() {})`
15969

16070
### Commit messages
16171

@@ -188,23 +98,25 @@ These are the commit types we make use of:
18898

18999
Below are some conventions that aren't enforced by any of our tooling but we nonetheless do our best to adhere to:
190100

191-
- **Disallow `async / await` syntax**
192-
- There is a measurable overhead to Promise usage vs simple callbacks. To support the broadest of driver usage scenarios we maintain an internal callback api while exposing a surface layer Promise API.
101+
- **Ensure Promise usage is optional**
102+
- There is a measurable overhead to Promise usage vs callbacks.
103+
To support the broadest of driver usage scenarios we maintain an internal callback api while exposing a surface layer Promise API.
193104
- **Disallow `export default` syntax**
194105
- For our use case it is best if all imports / exports remain named.
195106
- **As of 4.0 all code in src is in Typescript**
196-
- Typescript provides a nice developer experience. As a product of using TS we should be using es6 syntax features whenever possible.
107+
- Typescript provides a nice developer experience
108+
As a product of using TS we should be using es6 syntax features whenever possible.
197109
- **Errors**
198110
- Error messages should be sentence case, and have no periods at the end.
199-
- Use built-in error types where possible (not just Error, but TypeError/RangeError), also endeavor to create new Mongo-specific error types (e.g. MongoNetworkError)
111+
- Use built-in error types where possible (not just `Error`, but `TypeError`/`RangeError`), also endeavor to create new Mongo-specific error types (e.g. `MongoNetworkError`)
200112

201113
## Pull Request Process
202114

203115
1. Update the README.md or similar documentation with details of changes you
204116
wish to make, if applicable.
205-
2. Add any appropriate tests.
206-
3. Make your code or other changes.
207-
4. Review guidelines such as [How to write the perfect pull request][github-perfect-pr], thanks!
117+
1. Add any appropriate tests.
118+
1. Make your code or other changes.
119+
1. Review guidelines such as [How to write the perfect pull request][github-perfect-pr], thanks!
208120

209121
Take a look at [Github Flow][github-flow] for a more detailed explanation of this process.
210122

@@ -218,3 +130,4 @@ Take a look at [Github Flow][github-flow] for a more detailed explanation of thi
218130
[nvm-unix]: https://github.com/nvm-sh/nvm#install--update-script
219131
[macos-ulimt]: https://wilsonmar.github.io/maximum-limits/
220132
[github-flow]: https://guides.github.com/introduction/flow/
133+
[workspace-file]: https://gist.githubusercontent.com/nbbeeken/d831a3801b4c463648c077b27da5057b/raw/8e986843e5e28019f7c0cebe5c6fa72407bf8afb/node-mongodb-native.code-workspace

0 commit comments

Comments
 (0)