Skip to content

Commit 9d90781

Browse files
authored
chore: add test-services scripts per package (#2932)
1 parent 952abc7 commit 9d90781

File tree

89 files changed

+270
-421
lines changed

Some content is hidden

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

89 files changed

+270
-421
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The required steps to start development on a pacakge are:
117117

118118
- `npm ci` from root folder to install dependencies ([see npm-ci docs](https://docs.npmjs.com/cli/v10/commands/npm-ci))
119119
- `cd` into the pacakge you want to apply changes.
120-
- `npm run setup:dev` compiles the TypeScript files for this package and its dependencies within the repository.
120+
- `npm run compile:with-dependencies` compiles the TypeScript files for this package and its dependencies within the repository.
121121

122122
Then you can proceed to do apply the changes and use the scripts below for development workflow
123123

@@ -146,23 +146,21 @@ npm test
146146
However, some instrumentations require test-services to be running (e.g. the `instrumentation-mongodb` package requires a MongoDB server). Use the `test-services`-related npm scripts to start all required services in Docker and then run the tests with the appropriate configuration to use those services:
147147

148148
```sh
149-
npm run test-services:start # starts services in Docker
150-
npm run test:with-services-config # runs 'npm test' with envvars from test/test-services.env
151-
npm run test-services:stop # stops services in Docker
149+
npm run test-services:start # starts services in Docker
150+
npm run test:with-services-env # runs 'npm test' with envvars from test/test-services.env
151+
npm run test-services:stop # stops services in Docker
152152
```
153153

154-
If you only want to test a single package (e.g. the `instrumentation-mongodb`) you can `cd` into it and run the tests after you started the services.
154+
If you only want to test a single package that dfepends on a service (e.g. the `instrumentation-mongodb`) you can `cd` into it and
155+
use the same scripts for testing. In this case the script will only start the services needed to test the package.
155156

156157
```sh
157-
npm run test-services:start # starts services in Docker
158-
cd packages/instrumentation-mongodb # get into the instrumenation folder
159-
RUN_MONGODB_TESTS=1 npm test # run the test with the proper config (check each package)
160-
cd ../../.. # go back to root folder
161-
npm run test-services:stop # stops services in Docker
158+
cd packages/instrumentation-mongodb # get into the instrumenation folder
159+
npm run test-services:start # start the MongoDB service in Docker
160+
npm run test:with-services-env # runs 'npm test' with envvars from test/test-services.env
161+
npm run test-services:stop # stop MongoDB service in Docker
162162
```
163163

164-
NOTE: scripts for each package will be added to avoid extra consumption of resources and improve the development experience.
165-
166164
### Benchmarks
167165

168166
When two or more approaches must be compared, please write a benchmark in the benchmark/index.js module so that we can keep track of the most efficient algorithm.

incubator/opentelemetry-sampler-aws-xray/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
],
2929
"repository": "open-telemetry/opentelemetry-js-contrib",
3030
"scripts": {
31-
"setup:dev": "nx run-many -t compile -p @opentelemetry/sampler-aws-xray",
31+
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
3232
"compile": "tsc -p .",
33+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/sampler-aws-xray",
3334
"lint": "eslint . --ext .ts",
3435
"lint:fix": "eslint . --ext .ts --fix",
35-
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
3636
"prepublishOnly": "npm run compile",
3737
"tdd": "npm run test -- --watch-extensions ts --watch",
3838
"test": "nyc mocha 'test/**/*.test.ts'",

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/auto-configuration-propagators/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
},
2121
"scripts": {
2222
"clean": "rimraf build/*",
23-
"setup:dev": "nx run-many -t compile -p @opentelemetry/auto-configuration-propagators",
2423
"compile": "tsc -p .",
24+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/auto-configuration-propagators",
2525
"lint": "eslint . --ext .ts",
2626
"lint:fix": "eslint . --ext .ts --fix",
2727
"prepublishOnly": "npm run compile",

packages/auto-instrumentations-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
},
2525
"scripts": {
2626
"clean": "rimraf build/*",
27-
"setup:dev": "nx run-many -t compile -p @opentelemetry/auto-instrumentations-node",
2827
"compile": "tsc -p .",
28+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/auto-instrumentations-node",
2929
"lint": "eslint . --ext .ts",
3030
"lint:fix": "eslint . --ext .ts --fix",
3131
"prepublishOnly": "npm run compile",

packages/auto-instrumentations-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
},
2323
"scripts": {
2424
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
25-
"setup:dev": "nx run-many -t compile -p @opentelemetry/auto-instrumentations-web",
2625
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
26+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/auto-instrumentations-web",
2727
"lint": "eslint . --ext .ts",
2828
"lint:fix": "eslint . --ext .ts --fix",
2929
"prepublishOnly": "npm run compile",

packages/baggage-log-record-processor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"scripts": {
1313
"clean": "rimraf build/*",
14-
"setup:dev": "nx run-many -t compile -p @opentelemetry/baggage-log-record-processor",
1514
"compile": "tsc -p .",
15+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/baggage-log-record-processor",
1616
"lint": "eslint . --ext .ts",
1717
"lint:fix": "eslint . --ext .ts --fix",
1818
"prewatch": "npm run precompile",

packages/baggage-span-processor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"scripts": {
1313
"clean": "rimraf build/*",
14-
"setup:dev": "nx run-many -t compile -p @opentelemetry/baggage-span-processor",
1514
"compile": "tsc -p .",
15+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/baggage-span-processor",
1616
"lint": "eslint . --ext .ts",
1717
"lint:fix": "eslint . --ext .ts --fix",
1818
"prepublishOnly": "npm run compile",

packages/contrib-test-utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"access": "public"
99
},
1010
"scripts": {
11+
"compile": "tsc -p .",
12+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/contrib-test-utils",
1113
"lint": "eslint . --ext .ts",
1214
"lint:fix": "eslint . --ext .ts --fix",
13-
"setup:dev": "nx run-many -t compile -p @opentelemetry/contrib-test-utils",
14-
"compile": "tsc -p .",
1515
"prepublishOnly": "npm run compile",
1616
"watch": "tsc -w"
1717
},

packages/contrib-test-utils/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ export type { TestSpan, RunTestFixtureOptions } from './test-fixtures';
3434
export {
3535
assertPropagation,
3636
assertSpan,
37-
cleanUpDocker,
3837
getPackageVersion,
3938
initMeterProvider,
40-
startDocker,
4139
TestMetricReader,
4240
} from './test-utils';
4341
export type { TimedEvent } from './test-utils';

0 commit comments

Comments
 (0)