You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+42-25
Original file line number
Diff line number
Diff line change
@@ -72,12 +72,18 @@ Eventually we plan to look into putting these permission-required tests behind a
72
72
73
73
## Development Requirements
74
74
75
-
Since this project supports multiple Node versions, using a version
76
-
manager such as [nvm](https://github.com/creationix/nvm) is recommended.
75
+
Since this project supports multiple Node.js versions, using a version manager
76
+
such as [nvm](https://github.com/creationix/nvm) is recommended. If you're
77
+
unsure which version of Node.js to use, just use the latest version, which
78
+
should always work.
77
79
78
-
We use [yarn](https://yarnpkg.com/) for its workspace functionality, so make sure to install that as well.
80
+
We use [yarn](https://yarnpkg.com/)1.x for its workspace functionality, so make sure to install that as well. The easist way to install yarn 1.x with with npm:
79
81
80
-
To install dependencies once you have Node and yarn installed, run:
82
+
```sh
83
+
$ npm install -g yarn
84
+
```
85
+
86
+
To install dependencies once you have Node and yarn installed, run this in the project directory:
81
87
82
88
```sh
83
89
$ yarn
@@ -91,23 +97,42 @@ $ yarn
91
97
The `pg-native` package requires `pg_config` to be in your `$PATH` to be able to install.
92
98
Please refer to [the "Install" section](https://github.com/brianc/node-postgres/tree/master/packages/pg-native#install) of the `pg-native` documentation for how to ensure your environment is configured correctly.
93
99
94
-
### Setup
95
-
96
-
Before running _plugin_ tests, the data stores need to be running.
97
-
The easiest way to start all of them is to use the provided
98
-
docker-compose configuration:
100
+
### Plugin Tests
99
101
100
-
```sh
101
-
$ docker-compose up -d -V --remove-orphans --force-recreate
102
-
$ yarn services
103
-
```
102
+
Before running _plugin_ tests, the supporting docker containers need to be running. You _can_ attempt to start all of them using docker-compose, but that's a drain on your system, and not all the images will even run at all on AMD64 devices.
104
103
105
104
> **Note**
106
105
> The `aerospike`, `couchbase`, `grpc` and `oracledb` instrumentations rely on
107
106
> native modules that do not compile on ARM64 devices (for example M1/M2 Mac)
108
107
> - their tests cannot be run locally on these devices.
109
108
110
-
### Unit Tests
109
+
Instead, you can follow this procedure for the plugin you want to run tests for:
110
+
111
+
1. Check the CI config in `.github/workflows/plugins.yml` to see what the appropriate values for the `SERVICES` and `PLUGINS` environment variables are for the plugin you're trying to test (noting that not all plugins require `SERVICES`). For example, for the `amqplib` plugin, the `SERVICES` value is `rabbitmq`, and the `PLUGINS` value is `amqplib`.
112
+
2. Run the appropriate docker-compose command to start the required services. For example, for the `amqplib` plugin, you would run: `docker compose up -d rabbitmq`.
113
+
3. Run `yarn services`, with the environment variables set above. This will install any versions of the library to be tested against into the `versions` directory, and check that the appropriate services are running prior to running the test.
114
+
4. Now, you can run `yarn test:plugins` with the environment variables set above to run the tests for the plugin you're interested in.
115
+
116
+
To wrap that all up into a simple few lines of shell commands, here is all of the above, for the `amqplib` plugin:
117
+
118
+
```sh
119
+
# These are exported for simplicity, but you can also just set them inline.
120
+
export SERVICES="rabbitmq"# retrieved from .github/workflows/plugins.yml
121
+
export PLUGINS="amqplib"# retrieved from .github/workflows/plugins.yml
122
+
123
+
docker compose up -d $SERVICES
124
+
yarn services
125
+
126
+
yarn test:plugins # This one actually runs the tests. Can be run many times.
127
+
```
128
+
129
+
You can also run the tests for multiple plugins at once by separating them with a pipe (`|`) delimiter. For example, to run the tests for the `amqplib` and `bluebird` plugins:
130
+
131
+
```sh
132
+
PLUGINS="amqplib|bluebird" yarn test:plugins
133
+
```
134
+
135
+
### Other Unit Tests
111
136
112
137
There are several types of unit tests, for various types of components. The
113
138
following commands may be useful:
@@ -124,17 +149,6 @@ $ yarn test:instrumentations
124
149
Several other components have test commands as well. See `package.json` for
125
150
details.
126
151
127
-
To test _plugins_ (i.e. components in `packages/datadog-plugin-XXXX`
128
-
directories, set the `PLUGINS` environment variable to the plugin you're
129
-
interested in, and use `yarn test:plugins`. If you need to test multiple
130
-
plugins you may separate then with a pipe (`|`) delimiter. Here's an
131
-
example testing the `express` and `bluebird` plugins:
132
-
133
-
```sh
134
-
PLUGINS="express|bluebird" yarn test:plugins
135
-
```
136
-
137
-
138
152
### Linting
139
153
140
154
We use [ESLint](https://eslint.org) to make sure that new code
@@ -146,6 +160,9 @@ To run the linter, use:
146
160
$ yarn lint
147
161
```
148
162
163
+
This also checks that the `LICENSE-3rdparty.csv` file is up-to-date, and checks
0 commit comments