Skip to content

Commit

Permalink
chore: use npm workspaces and a package-lock.json (#1771)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
  • Loading branch information
trentm and pichlermarc authored Nov 16, 2023
1 parent 4c8b374 commit c7c7547
Show file tree
Hide file tree
Showing 89 changed files with 66,897 additions and 255 deletions.
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": [
"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
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

0 comments on commit c7c7547

Please sign in to comment.