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: track package-lock.json #4238

Merged
merged 28 commits into from Nov 1, 2023
Merged

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Oct 30, 2023

Which problem is this PR solving?

Check-in package-lock.json to avoid breakage on regular CI runs. Dependencies should be updated regularly with renovate.

Fixes #785

Notable Changes:

  1. lerna bootstrap is replaced by npm install with npm workspaces.
  2. @lerna/legacy-package-management is removed.
  3. lerna is degraded to v6.6.2 to be consistent across all supported Node.js versions.
  4. @grpc/grpc-js is locked to v1.8.21 in package-lock.json.
  5. The compatibility test using @opentelemetry/resource v1.9.0 (requires a peer @api < 1.5.0) in sdk-trace-base is temporarily disabled.

Type of change

  • Internal

Checklist:

  • Followed the style guidelines of this project

@legendecas legendecas requested a review from a team as a code owner October 30, 2023 09:29
@legendecas legendecas marked this pull request as draft October 30, 2023 09:31
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #4238 (1864f1d) into main (1c7d7a3) will decrease coverage by 0.07%.
The diff coverage is n/a.

❗ Current head 1864f1d differs from pull request most recent head a639048. Consider uploading reports for the commit a639048 to get more accurate results

@@            Coverage Diff             @@
##             main    #4238      +/-   ##
==========================================
- Coverage   92.24%   92.18%   -0.07%     
==========================================
  Files         331      319      -12     
  Lines        9481     8829     -652     
  Branches     1999     1875     -124     
==========================================
- Hits         8746     8139     -607     
+ Misses        735      690      -45     

see 14 files with indirect coverage changes

@legendecas legendecas force-pushed the package-lock branch 3 times, most recently from 22c7915 to e7c9c01 Compare October 30, 2023 09:52
@dyladan
Copy link
Member

dyladan commented Oct 30, 2023

I think I know what is failing the node 14 tests. If it's ok with you I'll just update your branch rather than creating a new PR since this is high priority and blocking all PRs

@dyladan dyladan mentioned this pull request Oct 30, 2023
@dyladan
Copy link
Member

dyladan commented Oct 30, 2023

Looks like the test is going to time out. It must be stuck somehow. running locally with the same changes results in a failure of the tree shaking test on my machine. I would appreciate if someone else could try to verify the behavior is the same on a windows or linux machine.

@Flarna
Copy link
Member

Flarna commented Oct 31, 2023

tried on windows using the steps as in CI but it fails early during npm ci --ignore-scripts with

npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.

Not sure but maybe the previous npm install --save-dev nx@^15 lerna@^6 causes some issues with the lock files.

I think we should aim to get the build setup back into a state where a simple npm install should install what is needed. If we need old version we should use it for all node versions. if we need special learn hoist configs we should use it local and in ci.
The current state to start a local build with reverse engineering github actions files is a bit cumbersome.

@dyladan
Copy link
Member

dyladan commented Oct 31, 2023

Not sure but maybe the previous npm install --save-dev nx@^15 lerna@^6 causes some issues with the lock files.

This should update the lockfiles so it shouldn't have that problem. I don't get that when I run it on mine and it doesn't happen on the CI either.

I think we should aim to get the build setup back into a state where a simple npm install should install what is needed. If we need old version we should use it for all node versions. if we need special learn hoist configs we should use it local and in ci.
The current state to start a local build with reverse engineering github actions files is a bit cumbersome.

We only need to do the special steps for node 14. We were currently talking in the maintainer channel about the idea to simply stop testing 14 because of this problem. In the past when we've deprecated a node runtime without a major version we've gotten strong pushback, so we're trying to figure out other options first.

So far we have:

  1. bend the CI around to make 14 work
  2. stop testing 14. possibly issue some deprecation "we aren't testing this" warning as an npm postinstall script on node 14
  3. revert testing dependencies far enough back that they work on node 14. this likely involves switching from lerna to nx in order to have stricter control over which version of nx we use (lerna just uses nx under the hood) or going to a very old lerna version (<=6).

@Flarna
Copy link
Member

Flarna commented Oct 31, 2023

retried with a really clean setup now.
Locally node 14 unittests are green for me now on windows.

@Flarna
Copy link
Member

Flarna commented Oct 31, 2023

maybe worth to mention that I used the npm version coming with node. In my case it's npm 6.14.18 and node 14.21.3

@dyladan
Copy link
Member

dyladan commented Oct 31, 2023

maybe worth to mention that I used the npm version coming with node. In my case it's npm 6.14.18 and node 14.21.3

I'm using the same and getting failures on a complete fresh build in macos following the exact steps in the workflow

         1114 passing (3s)
         1 failing
       
         1) tree-shaking
              verify MetricsAPI:
            Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/daniel.dyla/otel/opentelemetry-js/api/test/tree-shaking/tree-shaking.test.ts)

The test failing is one that deals with mocking filesystems so it's entirely possible this is an OS level issue for me. The CI logs don't make it easy to see which test is causing the problem but it seems like it hangs forever. There are no tests that time out though so it appears to be hanging between tests or something? Maybe all tests are completed and the runtime just never finishes.

@dyladan
Copy link
Member

dyladan commented Oct 31, 2023

I'm trying to remove the cache. Because we're using lockfiles, the node_modules is removed when bootstrap is run anyway and it is one variable we can remove for now.

@dyladan
Copy link
Member

dyladan commented Nov 1, 2023

I pushed a change to break the cache to see if i'm just doing something wrong locally

@dyladan
Copy link
Member

dyladan commented Nov 1, 2023

My cache break didn't break the build so I must be doing something locally causing the problem.

edit: went through the steps again and it worked this time. I think the important step that I missed was not updating the global NPM installation

@legendecas
Copy link
Member Author

I installed deps with npm i (note, without any flags, like --ignore-scripts) and it works well. However, if flags like --ignore-scripts are set, it doesn't work like you mentioned because now dependencies of all sub-packages are installed together with the --ignore-scripts flag and it would break a lot.

Would you mind verifying the install command you use?

@dyladan
Copy link
Member

dyladan commented Nov 1, 2023

I installed deps with npm i (note, without any flags, like --ignore-scripts) and it works well. However, if flags like --ignore-scripts are set, it doesn't work like you mentioned because now dependencies of all sub-packages are installed together with the --ignore-scripts flag and it would break a lot.

Would you mind verifying the install command you use?

Going through a clean install following the exact steps I was able to build and test fine. There is a test failure but I believe it is macos specific (it is the tree shaking test) so I would prefer to unblock the CI and resolve it in a separate PR.

Here are my exact commands I used for reference which worked:

# make sure directory is completely clean
rm -rf node_modules packages/*/node_modules experimental/packages/*/node_modules && git clean -ffdx

# install npm 10
npm install -g npm@"<10.0.0"

# install dependencies
npm ci

# compile packages
npm run compile

# test
npm run test

@dyladan
Copy link
Member

dyladan commented Nov 1, 2023

Successful in 3m

Seems fast enough anyway without caches

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. CI is always a headache.

@dyladan
Copy link
Member

dyladan commented Nov 1, 2023

OK to merge this whenever you're comfortable IMO. It's blocking other things so its high priority.

"submodule": "git submodule sync --recursive && git submodule update --init --recursive",
"version:update": "lerna run version:update",
"version:update": "lerna run version",
Copy link
Contributor

Choose a reason for hiding this comment

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

npm native version:

Suggested change
"version:update": "lerna run version",
"version:update": "npm run --ws --if-present version",

(I assume lack of --if-present was the error mentioned in sig, worked with this in gh workspace of this PR)

optionally can add -- at end if you want to pass flags forward (npm run version:update --something -> npm run version --something in workspaces) but it's not necessary here

Suggested change
"version:update": "lerna run version",
"version:update": "npm run --ws --if-present version --",

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it works in a more verbose manner. And worth mentioning that npm run doesn't parallel the execution so it is much slower than lerna run -- this is the main reason I didn't touch lerna run.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, tho at speed of version update script parallel's kinda whatever

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah... the speed problem is about test, not version.

@trentm
Copy link
Contributor

trentm commented Nov 1, 2023

Aside: Is there a separate issue for the test hang with @grpc/grpc-js@1.9.x?

Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

LGTM. Tested with node 18 & 16 on macos.

Comment on lines 19 to 23
- name: Install lerna
run: npm install -g lerna
run: npm install -g lerna@6.6.2

- name: Install semver
run: npm install semver
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This npm install semver installs all dependencies anyway (npm issue: npm/cli#3023). This could consider just running npm ci OR also installing semver globally (untested): npm install -g semver. The latter, if it works, would avoid installing ~800MB of deps.

Copy link
Member

Choose a reason for hiding this comment

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

@trentm
Copy link
Contributor

trentm commented Nov 1, 2023

This also closes #3927 right?

@dyladan dyladan linked an issue Nov 1, 2023 that may be closed by this pull request
@dyladan dyladan merged commit e9328ab into open-telemetry:main Nov 1, 2023
17 checks passed
@dyladan dyladan mentioned this pull request Nov 1, 2023
@legendecas legendecas deleted the package-lock branch November 2, 2023 02:23
@trentm trentm mentioned this pull request Nov 2, 2023
3 tasks
trentm added a commit to trentm/opentelemetry-js-contrib that referenced this pull request Nov 3, 2023
- use npm workspaces instead of lerna for monorepo install handling
  (requires at least npm@7, so node v14 users will have to update their npm)
- updates to lerna@6, which brings parallel
- add package-lock.json for more reliable dev and testing

Refs: open-telemetry/opentelemetry-js#4238
dyladan added a commit that referenced this pull request Nov 15, 2023
* chore: track package-lock.json (#4238)

* chore: track package-lock.json

* Pin to old versions for node 14

* Use version range

* Remove unused cached directories

* Temporarily disable other tests

* Temporarily enable only api test

* Enable only some packages

* Test only api packages

* Test trace exporters

* Fix line ordering

* Test all packages except otlp exporters

* Add trace http exporter

* Add trace proto exporter

* Test all but grpc exporters

* chore: use npm workspaces and degrade lerna to v6

* chore: get rid of lerna bootstrap

* chore: use npx

* chore: allow install scripts to setup buf

* chore: fix w3c-integration-test cache key

* chore: fix cache key

* chore: disable resource compat test

* chore: fix node_modules assumptions

* chore: fix hoisted karma issue

* chore: fix markdown linter complaints

* chore: lock @grpc/grpc-js to v1.8.21

* Break caches

* chore: remove cache

* chore: fixup inline commands

---------

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* docs: fixed link to benchmark results (#4233)

Co-authored-by: Chengzhong Wu <legendecas@gmail.com>

* chore(deps): update all patch versions (#4215)

* fix: otlp json encoding (#4220)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* fix: remove duplicate export star from version.ts (#4225)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* docs: fix sdk-node config instructions (#4249)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* feat(api): publish api esnext target (#4231)

* chore: release API 1.7.0/Core 1.18.0/Experimental 0.45.0 (#4254)

* fix(sdk-metrics): hand-roll MetricAdvice type as older API versions do not include it (#4260)

* chore: prepare release 1.18.1/0.45.1 (#4261)

* chore: no need for 'packages' in "lerna.json" (#4264)

* Benchmark tests for trace OTLP transform and BatchSpanProcessor (#4218)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* chore: type reference on zone.js (#4257)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* docs: add docker-compose to run prometheus for the experimental example (#4268)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* fix(sdk-logs): avoid map attribute set when count limit exceeded (#4195)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

* chore(deps): update dependency chromedriver to v119 [security] (#4280)

* chore(deps): update actions/setup-node action to v4 (#4236)

* fix(sdk-trace-base): processor onStart called with a span having empty attributes (#4277)

Co-authored-by: artahmetaj <artahmetaj@yahoo.com>

* Update fetch instrumentation to be runtime agnostic (#4063)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

---------

Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
Co-authored-by: Martin Kuba <martin@martinkuba.com>
Co-authored-by: Mend Renovate <bot@renovateapp.com>
Co-authored-by: Siim Kallas <siimkallas@gmail.com>
Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Co-authored-by: David Luna <david.luna@elastic.co>
Co-authored-by: Dinko Osrecki <dinko.osrecki@emarsys.com>
Co-authored-by: Trent Mick <trentm@gmail.com>
Co-authored-by: François <32224751+Lp-Francois@users.noreply.github.com>
Co-authored-by: Hyun Oh <hyunnoh01@gmail.com>
Co-authored-by: André Cruz <andremiguelcruz@msn.com>
Co-authored-by: artahmetaj <artahmetaj@yahoo.com>
Co-authored-by: drewcorlin1 <82601620+drewcorlin1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to npm workspaces Check in package-lock.json files
7 participants