Skip to content

[DRAFT] Experimental NPM workspaces (move away from lerna in v2) #421

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

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
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
128 changes: 19 additions & 109 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,129 +33,39 @@ shared: &shared

- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-root-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-autoprofile-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/autoprofile/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-aws-fargate-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-fargate/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-aws-lambda-auto-wrap-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-lambda-auto-wrap/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-aws-lambda-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-lambda/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-collector-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/collector/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-babel-typescript-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/collector/test/apps/babel-typescript/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-core-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/core/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-google-cloud-run-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/google-cloud-run/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-legacy-sensor-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/legacy-sensor/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-metrics-util-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/metrics-util/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-serverless-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/serverless/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-shared-metrics-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/shared-metrics/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-opentelemetry-exporter-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/opentelemetry-exporter/package-lock.json" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-misc-test-durations-{{ .Environment.CIRCLE_JOB }}-{{ checksum "misc/test-durations/package-lock.json" }}
- v{{ .Environment.CACHE_VERSION }}-collector-v2-root-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}

# We do not use npm ci (short for clean install) because it removes the existing node_modules folder. But we want to
# re-use the existing node_modules folders from CircleCI's cache. Using npm ci would defeat that purpose. For the
# same purpose, we reset the package lock file after running npm install. Sometimes npm install updates the lock
# file and that will also break caching because its checksum would then change between save_cache and restore_cache
# in the next CI run.
- run: npm install && git checkout package-lock.json
- run: |
if [[ $(node -v) =~ ^v16.*$ ]]; then
npm install -g npm@latest --prefix=$HOME/.local
else
npm install -g npm@7.24.2 --prefix=$HOME/.local
fi

- run: cd misc/test-durations && npm install && git checkout package-lock.json
- run: npm --version

- run: npm install

#- run: cd misc/test-durations && npm install

# Cache the node_modules folders for the next run (before potentially installing other module versions like grpc,
# see below).
- save_cache:
paths:
- node_modules
key: v{{ .Environment.CACHE_VERSION }}-root-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- save_cache:
paths:
- packages/autoprofile/node_modules
key: v{{ .Environment.CACHE_VERSION }}-autoprofile-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/autoprofile/package-lock.json" }}
- save_cache:
paths:
- packages/aws-fargate/node_modules
key: v{{ .Environment.CACHE_VERSION }}-aws-fargate-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-fargate/package-lock.json" }}
- save_cache:
paths:
- packages/aws-lambda-auto-wrap/node_modules
key: v{{ .Environment.CACHE_VERSION }}-aws-lambda-auto-wrap-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-lambda-auto-wrap/package-lock.json" }}
- save_cache:
paths:
- packages/aws-lambda/node_modules
key: v{{ .Environment.CACHE_VERSION }}-aws-lambda-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/aws-lambda/package-lock.json" }}
- save_cache:
paths:
- packages/collector/node_modules
key: v{{ .Environment.CACHE_VERSION }}-collector-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/collector/package-lock.json" }}
- save_cache:
paths:
- packages/core/node_modules
key: v{{ .Environment.CACHE_VERSION }}-core-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/core/package-lock.json" }}
- save_cache:
paths:
- packages/google-cloud-run/node_modules
key: v{{ .Environment.CACHE_VERSION }}-google-cloud-run-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/google-cloud-run/package-lock.json" }}
- save_cache:
paths:
- packages/legacy-sensor/node_modules
key: v{{ .Environment.CACHE_VERSION }}-legacy-sensor-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/legacy-sensor/package-lock.json" }}
- save_cache:
paths:
- packages/metrics-util/node_modules
key: v{{ .Environment.CACHE_VERSION }}-metrics-util-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/metrics-util/package-lock.json" }}
- save_cache:
paths:
- packages/serverless/node_modules
key: v{{ .Environment.CACHE_VERSION }}-serverless-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/serverless/package-lock.json" }}
- save_cache:
paths:
- packages/shared-metrics/node_modules
key: v{{ .Environment.CACHE_VERSION }}-shared-metrics-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/shared-metrics/package-lock.json" }}
- save_cache:
paths:
- packages/opentelemetry-exporter/node_modules
key: v{{ .Environment.CACHE_VERSION }}-opentelemetry-exporter-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/opentelemetry-exporter/package-lock.json" }}
- save_cache:
paths:
- misc/test-durations/node_modules
key: v{{ .Environment.CACHE_VERSION }}-misc-test-durations-{{ .Environment.CIRCLE_JOB }}-{{ checksum "misc/test-durations/package-lock.json" }}
key: v{{ .Environment.CACHE_VERSION }}-collector-v2-root-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}

# Only run audit with the most recent Node.js version - one Node version is enough.
- run: "([[ $(node -v) =~ ^v16.*$ ]] && npm run audit) || [[ ! $(node -v) =~ ^v16.*$ ]]"

# Check if all commits since the last release comply with the format that conventional-commit understands. This
# makes sure that lerna version (with the "conventionalCommits" option set in lerna.json) can correctly determin the
# next version number and generate changelogs.
- run: "([[ $(node -v) =~ ^v16.*$ ]] && node_modules/.bin/commitlint --from $(git describe --tags --abbrev=0)) || [[ ! $(node -v) =~ ^v16.*$ ]]"
#- run: "([[ $(node -v) =~ ^v16.*$ ]] && node_modules/.bin/commitlint --from $(git describe --tags --abbrev=0)) || [[ ! $(node -v) =~ ^v16.*$ ]]"

# Run linting first, we don't want to wait ages for the test suite to finish only to end the CI job with a linting
# error.
- run: npm run lint
#- run: npm run lint

# Run the test suites.
# (Use ulimit to remove the file size limit on core dump files before running tests.)
Expand All @@ -164,7 +74,7 @@ shared: &shared
- run: |
ulimit -c unlimited
. ./bin/ci_glob_setup.sh
npm test
npm test --w packages/shared-metrics

- store_test_results:
path: test-results
Expand Down Expand Up @@ -336,6 +246,6 @@ workflows:
build:
jobs:
- "node-16"
- "node-14"
- "node-12"
- "node-10"
#- "node-14"
#- "node-12"
#- "node-10"
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
15 changes: 0 additions & 15 deletions bin/add-to-package-lock

This file was deleted.

Loading