Skip to content

Commit c7c7547

Browse files
trentmpichlermarc
andauthored
chore: use npm workspaces and a package-lock.json (#1771)
Co-authored-by: Marc Pichler <[email protected]>
1 parent 4c8b374 commit c7c7547

File tree

89 files changed

+66897
-255
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

+66897
-255
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,19 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
container:
13-
image: node:14
14-
1512
steps:
1613
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 18
17+
cache: 'npm'
1718

1819
- name: Lint markdown files
1920
uses: avto-dev/markdown-lint@v1
2021
with:
2122
ignore: "./**/CHANGELOG.md"
2223
args: "./**/*.md"
2324

24-
- name: restore lerna
25-
uses: actions/cache@master # must use unreleased master to cache multiple paths
26-
id: cache
27-
with:
28-
path: |
29-
./node_modules
30-
./package-lock.json
31-
node_modules
32-
detectors/node/*/node_modules
33-
metapackages/*/node_modules
34-
packages/*/node_modules
35-
plugins/node/*/node_modules
36-
plugins/web/*/node_modules
37-
propagators/*/node_modules
38-
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
39-
40-
- name: Bootstrap
41-
if: steps.cache.outputs.cache-hit != 'true'
42-
run: |
43-
npm install --only=dev --ignore-scripts
44-
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='gts' --ignore-scripts -- --only=dev
25+
- run: npm ci
4526
- name: Lint
4627
run: npm run lint

.github/workflows/peer-api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
peer-api-check:
1111
runs-on: ubuntu-latest
1212
container:
13-
image: node:14
13+
image: node:18
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717

1818
- name: Install script dependencies
19-
run: npm install
19+
run: npm ci
2020

2121
- name: Check API dependency semantics
2222
run: npx lerna exec "node \$LERNA_ROOT_PATH/scripts/peer-api-check.js"

.github/workflows/release-please-validate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Install lerna
19-
run: npm install -g lerna@5.5.2
19+
run: npm install -g lerna@6.6.2
2020

2121
- name: Ensure Release Please Config and Manifest are in sync with the repository
2222
run: node scripts/check-release-please.mjs

.github/workflows/release-please.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,13 @@ jobs:
1717
- name: Setup Node
1818
uses: actions/setup-node@v4
1919
with:
20-
node-version: 14
20+
node-version: 18
2121
registry-url: 'https://registry.npmjs.org'
2222

23-
- name: Cache Dependencies
24-
uses: actions/cache@v3
25-
with:
26-
path: |
27-
node_modules
28-
package-lock.json
29-
detectors/node/*/node_modules
30-
metapackages/*/node_modules
31-
packages/*/node_modules
32-
plugins/node/*/node_modules
33-
plugins/web/*/node_modules
34-
propagators/*/node_modules
35-
key: release-${{ runner.os }}-${{ matrix.container }}-${{ hashFiles('**/package.json') }}
36-
3723
- name: Build Packages
3824
run: |
39-
npm install
40-
npx lerna bootstrap --no-ci
25+
npm ci
26+
npm run compile
4127
4228
- uses: google-github-actions/release-please-action@v3
4329
id: release

.github/workflows/test-all-versions.pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v4
2323
# Need lerna to list all packages
2424
- name: Install lerna
25-
run: npm install -g lerna@5.5.2
25+
run: npm install -g lerna@6.6.2
2626
- name: Parse labels into lerna scope arguments
2727
id: lerna-args
2828
run: |

.github/workflows/test-all-versions.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,15 @@ jobs:
115115
node-version: ${{ matrix.node }}
116116
- name: Set MySQL variables
117117
run: mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --host=${MYSQL_HOST} --port=${MYSQL_PORT} -e "SET GLOBAL log_output='TABLE'; SET GLOBAL general_log = 1;" mysql
118-
- name: Cache Dependencies
119-
uses: actions/cache@v3
120-
with:
121-
path: |
122-
node_modules
123-
package-lock.json
124-
detectors/node/*/node_modules
125-
detectors/node/*/package-lock.json
126-
metapackages/*/node_modules
127-
metapackages/*/package-lock.json
128-
packages/*/node_modules
129-
packages/*/package-lock.json
130-
plugins/node/*/node_modules
131-
plugins/node/*/package-lock.json
132-
plugins/web/*/node_modules
133-
plugins/web/*/package-lock.json
134-
propagators/*/node_modules
135-
propagators/*/package-lock.json
136-
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package.json', 'detectors/node/*/package.json', 'metapackages/*/package.json', 'packages/*/package.json', 'plugins/node/*/package.json', 'plugins/web/*/package.json', 'propagators/*/package.json') }}
137118
- name: Legacy Peer Dependencies for npm 7
138119
if: matrix.node == '16'
139120
run: npm config set legacy-peer-deps=true
140-
- name: Install Root Dependencies
141-
run: npm install --ignore-scripts
142-
- name: Bootstrap Dependencies
143-
run: npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='mocha' --nohoist='ts-mocha'
121+
- name: Update npm to a version that supports workspaces (v7 or later)
122+
if: ${{ matrix.node < 16 }}
123+
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
124+
- name: Install
125+
run: npm ci
126+
- name: Build
127+
run: npm run compile
144128
- name: Run test-all-versions
145129
run: npx lerna run test-all-versions ${{ inputs.lerna-args }} ${{ matrix.lerna-extra-args }} --stream --concurrency 1

.github/workflows/unit-test.yml

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -123,32 +123,16 @@ jobs:
123123
node-version: ${{ matrix.node }}
124124
- name: Set MySQL variables
125125
run: mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --host=${MYSQL_HOST} --port=${MYSQL_PORT} -e "SET GLOBAL log_output='TABLE'; SET GLOBAL general_log = 1;" mysql
126-
- name: Cache Dependencies
127-
uses: actions/cache@v3
128-
with:
129-
path: |
130-
node_modules
131-
package-lock.json
132-
detectors/node/*/node_modules
133-
detectors/node/*/package-lock.json
134-
metapackages/*/node_modules
135-
metapackages/*/package-lock.json
136-
packages/*/node_modules
137-
packages/*/package-lock.json
138-
plugins/node/*/node_modules
139-
plugins/node/*/package-lock.json
140-
plugins/web/*/node_modules
141-
plugins/web/*/package-lock.json
142-
propagators/*/node_modules
143-
propagators/*/package-lock.json
144-
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package.json', 'detectors/node/*/package.json', 'metapackages/*/package.json', 'packages/*/package.json', 'plugins/node/*/package.json', 'plugins/web/*/package.json', 'propagators/*/package.json') }}
145126
- name: Legacy Peer Dependencies for npm 7
146127
if: matrix.node == '16'
147128
run: npm config set legacy-peer-deps=true
148-
- name: Install Root Dependencies
149-
run: npm install --ignore-scripts
150-
- name: Bootstrap Dependencies
151-
run: npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='mocha' --nohoist='ts-mocha'
129+
- name: Update npm to a version that supports workspaces (v7 or later)
130+
if: ${{ matrix.node < 16 }}
131+
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
132+
- name: Install
133+
run: npm ci
134+
- name: Build
135+
run: npm run compile
152136
- name: Unit tests (Full)
153137
if: matrix.code-coverage
154138
run: npm run test -- ${{ matrix.lerna-extra-args }}
@@ -180,29 +164,13 @@ jobs:
180164
- uses: actions/setup-node@v4
181165
with:
182166
node-version: ${{ matrix.node }}
183-
- name: Cache Dependencies
184-
uses: actions/cache@v3
185-
with:
186-
path: |
187-
node_modules
188-
package-lock.json
189-
detectors/node/*/node_modules
190-
detectors/node/*/package-lock.json
191-
metapackages/*/node_modules
192-
metapackages/*/package-lock.json
193-
packages/*/node_modules
194-
packages/*/package-lock.json
195-
plugins/node/*/node_modules
196-
plugins/node/*/package-lock.json
197-
plugins/web/*/node_modules
198-
plugins/web/*/package-lock.json
199-
propagators/*/node_modules
200-
propagators/*/package-lock.json
201-
key: ${{ runner.os }}${{ matrix.node }}-browser-${{ hashFiles('package.json', 'detectors/node/*/package.json', 'metapackages/*/package.json', 'packages/*/package.json', 'plugins/node/*/package.json', 'plugins/web/*/package.json', 'propagators/*/package.json') }}
202-
- name: Install Root Dependencies
203-
run: npm install --ignore-scripts
204-
- name: Bootstrap Dependencies
205-
run: npx lerna bootstrap --no-ci
167+
- name: Update npm to a version that supports workspaces (v7 or later)
168+
if: ${{ matrix.node < 16 }}
169+
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
170+
- name: Install
171+
run: npm ci
172+
- name: Build
173+
run: npm run compile
206174
- name: Unit tests
207175
run: npm run test:browser
208176
- name: Report Coverage

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ typings/
6060

6161
# lock files
6262
yarn.lock
63-
package-lock.json
6463
packages/**/yarn.lock
65-
packages/**/package-lock.json
6664

6765
# docs files
6866
docs

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lockfile-version=2

detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-alibaba-cloud --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

detectors/node/opentelemetry-resource-detector-aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-aws --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

detectors/node/opentelemetry-resource-detector-azure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

detectors/node/opentelemetry-resource-detector-container/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"compile": "npm run version:update && tsc -p .",
1212
"lint": "eslint . --ext .ts",
1313
"lint:fix": "eslint . --ext .ts --fix",
14-
"precompile": "tsc --version && lerna run version --scope @opentelemetry/resource-detector-container --include-dependencies",
14+
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-container --include-dependencies",
1515
"prewatch": "npm run precompile",
16-
"prepare": "npm run compile",
16+
"prepublishOnly": "npm run compile",
1717
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1818
"tdd": "npm run test -- --watch-extensions ts --watch",
1919
"version:update": "node ../../../scripts/version-update.js",

detectors/node/opentelemetry-resource-detector-gcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-gcp --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

detectors/node/opentelemetry-resource-detector-github/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-github --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

detectors/node/opentelemetry-resource-detector-instana/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:fix": "eslint . --ext .ts --fix",
1313
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-instana --include-dependencies",
1414
"prewatch": "npm run precompile",
15-
"prepare": "npm run compile",
15+
"prepublishOnly": "npm run compile",
1616
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
1717
"tdd": "npm run test -- --watch-extensions ts --watch",
1818
"watch": "tsc -w"

lerna.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"npmClient": "npm",
3-
"packages": [
4-
"packages/*",
5-
"metapackages/*",
6-
"plugins/node/*",
7-
"plugins/node/*/examples",
8-
"plugins/web/*",
9-
"plugins/web/*/examples",
10-
"propagators/*",
11-
"detectors/node/*"
12-
],
3+
"useWorkspaces": true,
134
"version": "independent",
145
"changelog": {
156
"repo": "open-telemetry/opentelemetry-js-contrib",

metapackages/auto-instrumentations-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"lint:fix": "eslint . --ext .ts --fix",
2626
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-node --include-dependencies",
2727
"prewatch": "npm run precompile",
28-
"prepare": "npm run compile",
28+
"prepublishOnly": "npm run compile",
2929
"tdd": "yarn test -- --watch-extensions ts --watch",
3030
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
3131
"watch": "tsc -w"

metapackages/auto-instrumentations-node/test/register.test.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,43 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { promisify } from 'util';
17-
import * as childProcess from 'child_process';
18-
import * as assert from 'assert';
1916

20-
const exec = promisify(childProcess.exec);
17+
import { spawnSync } from 'child_process';
18+
import * as assert from 'assert';
2119

2220
describe('Register', function () {
23-
this.timeout(5000);
24-
it('can load auto instrumentation from command line', async () => {
25-
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'none';
26-
process.env.OTEL_TRACES_EXPORTER = 'console';
27-
28-
const { stdout } = await exec(
29-
'node --require ./build/src/register.js ./test/test-app/app.js'
21+
it('can load auto instrumentation from command line', () => {
22+
const proc = spawnSync(
23+
process.execPath,
24+
['--require', '../build/src/register.js', './test-app/app.js'],
25+
{
26+
cwd: __dirname,
27+
timeout: 5000,
28+
killSignal: 'SIGKILL', // SIGTERM is not sufficient to terminate some hangs
29+
env: Object.assign({}, process.env, {
30+
OTEL_NODE_RESOURCE_DETECTORS: 'none',
31+
OTEL_TRACES_EXPORTER: 'console',
32+
// nx (used by lerna run) defaults `FORCE_COLOR=true`, which in
33+
// node v18.17.0, v20.3.0 and later results in ANSI color escapes
34+
// in the ConsoleSpanExporter output that is checked below.
35+
FORCE_COLOR: '0',
36+
}),
37+
}
3038
);
39+
assert.ifError(proc.error);
40+
assert.equal(proc.status, 0, `proc.status (${proc.status})`);
41+
assert.equal(proc.signal, null, `proc.signal (${proc.signal})`);
3142

3243
assert.ok(
33-
stdout.includes(
44+
proc.stdout.includes(
3445
'OpenTelemetry automatic instrumentation started successfully'
3546
)
3647
);
3748

38-
//Check a span has been generated for the GET request done in app.js
39-
assert.ok(stdout.includes("name: 'GET'"));
40-
41-
delete process.env.OTEL_NODE_RESOURCE_DETECTORS;
42-
delete process.env.OTEL_TRACES_EXPORTER;
49+
// Check a span has been generated for the GET request done in app.js
50+
assert.ok(
51+
proc.stdout.includes("name: 'GET'"),
52+
'console span output in stdout'
53+
);
4354
});
4455
});

metapackages/auto-instrumentations-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"lint:fix": "eslint . --ext .ts --fix",
2323
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-web --include-dependencies",
2424
"prewatch": "npm run precompile",
25-
"prepare": "npm run compile",
25+
"prepublishOnly": "npm run compile",
2626
"test:browser": "nyc karma start --single-run",
2727
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json"
2828
},

0 commit comments

Comments
 (0)