Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use npm workspaces and a package-lock.json #1771

Merged
merged 36 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4f94b63
chore: use npm workspaces and a package-lock.json
trentm Nov 3, 2023
327e9bc
first pass at GH workflow file updates
trentm Nov 3, 2023
dfd4ae1
gh action fixes: update npm in node 14 to npm@9 to support npm worksp…
trentm Nov 3, 2023
40ef62e
better output from this test for failure (failing with node 18 in CI,…
trentm Nov 3, 2023
5732850
theory is that `stdout.includes("name: 'GET'")` breaks because ANSI c…
trentm Nov 3, 2023
1465d51
fix auto-instrumentations-node/test/register.test.ts on node 18
trentm Nov 3, 2023
7c9ff61
more test flailing (still failing in CI for node 18 only)
trentm Nov 3, 2023
f921e2b
try lint workflow with setup-node and cache instead of container.imag…
trentm Nov 3, 2023
1542533
get FORCE_COLOR envvar name correct, this should break node 16 test a…
trentm Nov 3, 2023
9d1b2fd
flail, try this again, repro FORCE_COLOR=true from somewhere?
trentm Nov 3, 2023
cb5a96a
FORCE_COLOR=0 should override nx's default FORCE_COLOR=true
trentm Nov 3, 2023
c4303b2
npm run changelog just works; drop the XXXs on these
trentm Nov 3, 2023
a91d5b1
from some working XXX comments
trentm Nov 4, 2023
af0f195
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 6, 2023
2ffa972
don't ignore errant package-lock.json files in nested dirs, we should…
trentm Nov 7, 2023
bae2543
fixes for running TAV (test-all-versions) tests; all but ioredis@4 te…
trentm Nov 7, 2023
78e64f1
fix test-all-versions tests with ioredis@4
trentm Nov 7, 2023
49c7a96
test: update ioredis TAV versions for recent minor releases
trentm Nov 7, 2023
940ae6a
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 7, 2023
dd6c2e4
update package-lock for 'update dependency gcp-metadata to v6 (#1720)'
trentm Nov 7, 2023
e2db411
correct npm script reference to version:update in a few older plugins
trentm Nov 7, 2023
0f026d0
correct npm script reference to version:update
trentm Nov 7, 2023
faed214
use type reference on zone.js
trentm Nov 8, 2023
ce579b0
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 8, 2023
c026902
update package-lock for recent #1779 package.json updates
trentm Nov 8, 2023
617c6d6
lock to lockfileVersion:2; correct some outdated otel 1.17.1 deps to …
trentm Nov 8, 2023
8ba7e2b
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 8, 2023
cc226fd
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 13, 2023
23fa01b
sync package-lock.json for package.json changes in #1742
trentm Nov 13, 2023
0ce449e
update locked versions of @opentelemetry core repo deps to 1.18.1
trentm Nov 13, 2023
aa4b920
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 14, 2023
f15ae6c
sync package-lock for package.json updates in #1788
trentm Nov 14, 2023
cd46b7a
no need for tsconfig 'files' reference to zone.js.d.ts; use a type re…
trentm Nov 14, 2023
eae9905
Merge branch 'main' into tm-npm-workspaces-lock-file
pichlermarc Nov 15, 2023
fd4a9c8
Merge branch 'main' into tm-npm-workspaces-lock-file
trentm Nov 15, 2023
f382586
sync package-lock for recent package.json changes in main
trentm Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container:
image: node:14

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'

- name: Lint markdown files
uses: avto-dev/markdown-lint@v1
with:
ignore: "./**/CHANGELOG.md"
args: "./**/*.md"

- name: restore lerna
uses: actions/cache@master # must use unreleased master to cache multiple paths
id: cache
with:
path: |
./node_modules
./package-lock.json
node_modules
detectors/node/*/node_modules
metapackages/*/node_modules
packages/*/node_modules
plugins/node/*/node_modules
plugins/web/*/node_modules
propagators/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}

- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --only=dev --ignore-scripts
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='gts' --ignore-scripts -- --only=dev
- run: npm ci
- name: Lint
run: npm run lint
4 changes: 2 additions & 2 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
peer-api-check:
runs-on: ubuntu-latest
container:
image: node:14
image: node:18
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install script dependencies
run: npm install
run: npm ci

- name: Check API dependency semantics
run: npx lerna exec "node \$LERNA_ROOT_PATH/scripts/peer-api-check.js"
2 changes: 1 addition & 1 deletion .github/workflows/release-please-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4

- name: Install lerna
run: npm install -g lerna@5.5.2
run: npm install -g lerna@6.6.2

- name: Ensure Release Please Config and Manifest are in sync with the repository
run: node scripts/check-release-please.mjs
20 changes: 3 additions & 17 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,13 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
node_modules
package-lock.json
detectors/node/*/node_modules
metapackages/*/node_modules
packages/*/node_modules
plugins/node/*/node_modules
plugins/web/*/node_modules
propagators/*/node_modules
key: release-${{ runner.os }}-${{ matrix.container }}-${{ hashFiles('**/package.json') }}

- name: Build Packages
run: |
npm install
npx lerna bootstrap --no-ci
npm ci
npm run compile

- uses: google-github-actions/release-please-action@v3
id: release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-all-versions.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v4
# Need lerna to list all packages
- name: Install lerna
run: npm install -g lerna@5.5.2
run: npm install -g lerna@6.6.2
- name: Parse labels into lerna scope arguments
id: lerna-args
run: |
Expand Down
30 changes: 7 additions & 23 deletions .github/workflows/test-all-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,15 @@ jobs:
node-version: ${{ matrix.node }}
- name: Set MySQL variables
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
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
node_modules
package-lock.json
detectors/node/*/node_modules
detectors/node/*/package-lock.json
metapackages/*/node_modules
metapackages/*/package-lock.json
packages/*/node_modules
packages/*/package-lock.json
plugins/node/*/node_modules
plugins/node/*/package-lock.json
plugins/web/*/node_modules
plugins/web/*/package-lock.json
propagators/*/node_modules
propagators/*/package-lock.json
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') }}
- name: Legacy Peer Dependencies for npm 7
if: matrix.node == '16'
run: npm config set legacy-peer-deps=true
- name: Install Root Dependencies
run: npm install --ignore-scripts
- name: Bootstrap Dependencies
run: npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='mocha' --nohoist='ts-mocha'
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Build
run: npm run compile
- name: Run test-all-versions
run: npx lerna run test-all-versions ${{ inputs.lerna-args }} ${{ matrix.lerna-extra-args }} --stream --concurrency 1
60 changes: 14 additions & 46 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,32 +123,16 @@ jobs:
node-version: ${{ matrix.node }}
- name: Set MySQL variables
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
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
node_modules
package-lock.json
detectors/node/*/node_modules
detectors/node/*/package-lock.json
metapackages/*/node_modules
metapackages/*/package-lock.json
packages/*/node_modules
packages/*/package-lock.json
plugins/node/*/node_modules
plugins/node/*/package-lock.json
plugins/web/*/node_modules
plugins/web/*/package-lock.json
propagators/*/node_modules
propagators/*/package-lock.json
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') }}
- name: Legacy Peer Dependencies for npm 7
if: matrix.node == '16'
run: npm config set legacy-peer-deps=true
- name: Install Root Dependencies
run: npm install --ignore-scripts
- name: Bootstrap Dependencies
run: npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='mocha' --nohoist='ts-mocha'
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Build
run: npm run compile
- name: Unit tests (Full)
if: matrix.code-coverage
run: npm run test -- ${{ matrix.lerna-extra-args }}
Expand Down Expand Up @@ -180,29 +164,13 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
node_modules
package-lock.json
detectors/node/*/node_modules
detectors/node/*/package-lock.json
metapackages/*/node_modules
metapackages/*/package-lock.json
packages/*/node_modules
packages/*/package-lock.json
plugins/node/*/node_modules
plugins/node/*/package-lock.json
plugins/web/*/node_modules
plugins/web/*/package-lock.json
propagators/*/node_modules
propagators/*/package-lock.json
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') }}
- name: Install Root Dependencies
run: npm install --ignore-scripts
- name: Bootstrap Dependencies
run: npx lerna bootstrap --no-ci
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Build
run: npm run compile
- name: Unit tests
run: npm run test:browser
- name: Report Coverage
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ typings/

# lock files
yarn.lock
package-lock.json
packages/**/yarn.lock
packages/**/package-lock.json

# docs files
docs
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lockfile-version=2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-alibaba-cloud --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-aws --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"compile": "npm run version:update && tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version --scope @opentelemetry/resource-detector-container --include-dependencies",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-container --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"version:update": "node ../../../scripts/version-update.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-gcp --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-github --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-instana --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
Expand Down
11 changes: 1 addition & 10 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"npmClient": "npm",
"packages": [
trentm marked this conversation as resolved.
Show resolved Hide resolved
"packages/*",
"metapackages/*",
"plugins/node/*",
"plugins/node/*/examples",
"plugins/web/*",
"plugins/web/*/examples",
"propagators/*",
"detectors/node/*"
],
"useWorkspaces": true,
"version": "independent",
"changelog": {
"repo": "open-telemetry/opentelemetry-js-contrib",
Expand Down
2 changes: 1 addition & 1 deletion metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-node --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"tdd": "yarn test -- --watch-extensions ts --watch",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"watch": "tsc -w"
Expand Down
45 changes: 28 additions & 17 deletions metapackages/auto-instrumentations-node/test/register.test.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review note: I rewrote how this test spawns while debugging a breakage with node v18. See #1771 (comment) for details.

Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { promisify } from 'util';
import * as childProcess from 'child_process';
import * as assert from 'assert';

const exec = promisify(childProcess.exec);
import { spawnSync } from 'child_process';
import * as assert from 'assert';

describe('Register', function () {
this.timeout(5000);
it('can load auto instrumentation from command line', async () => {
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'none';
process.env.OTEL_TRACES_EXPORTER = 'console';

const { stdout } = await exec(
'node --require ./build/src/register.js ./test/test-app/app.js'
it('can load auto instrumentation from command line', () => {
const proc = spawnSync(
process.execPath,
['--require', '../build/src/register.js', './test-app/app.js'],
{
cwd: __dirname,
timeout: 5000,
killSignal: 'SIGKILL', // SIGTERM is not sufficient to terminate some hangs
env: Object.assign({}, process.env, {
OTEL_NODE_RESOURCE_DETECTORS: 'none',
OTEL_TRACES_EXPORTER: 'console',
// nx (used by lerna run) defaults `FORCE_COLOR=true`, which in
// node v18.17.0, v20.3.0 and later results in ANSI color escapes
// in the ConsoleSpanExporter output that is checked below.
FORCE_COLOR: '0',
}),
}
);
assert.ifError(proc.error);
assert.equal(proc.status, 0, `proc.status (${proc.status})`);
assert.equal(proc.signal, null, `proc.signal (${proc.signal})`);

assert.ok(
stdout.includes(
proc.stdout.includes(
'OpenTelemetry automatic instrumentation started successfully'
)
);

//Check a span has been generated for the GET request done in app.js
assert.ok(stdout.includes("name: 'GET'"));

delete process.env.OTEL_NODE_RESOURCE_DETECTORS;
delete process.env.OTEL_TRACES_EXPORTER;
// Check a span has been generated for the GET request done in app.js
assert.ok(
proc.stdout.includes("name: 'GET'"),
'console span output in stdout'
);
});
});
2 changes: 1 addition & 1 deletion metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-web --include-dependencies",
"prewatch": "npm run precompile",
"prepare": "npm run compile",
"prepublishOnly": "npm run compile",
"test:browser": "nyc karma start --single-run",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json"
},
Expand Down
Loading
Loading