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

ci: add npm cache in actions/setup-node #4271

Merged
merged 8 commits into from
Dec 1, 2023

Conversation

lyzlisa
Copy link
Contributor

@lyzlisa lyzlisa commented Nov 8, 2023

Which problem is this PR solving?

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #4243

Short description of the changes

Enable cache in actions/setup-node

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@lyzlisa lyzlisa requested a review from a team November 8, 2023 21:46
Copy link

linux-foundation-easycla bot commented Nov 8, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@lyzlisa lyzlisa changed the title ci(opentelemetry-core): add npm cache in actions/setup-node@… ci(opentelemetry-core): add npm cache in actions/setup-node@v3 Nov 8, 2023
@lyzlisa lyzlisa force-pushed the gh-action-add-npm-ci branch 2 times, most recently from 8bfa115 to 2cd21d6 Compare November 9, 2023 18:13
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #4271 (1fb2d00) into main (6dd075c) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4271   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files         332      332           
  Lines        9439     9439           
  Branches     2000     2000           
=======================================
  Hits         8703     8703           
  Misses        736      736           

@@ -17,10 +17,13 @@ jobs:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

May be out of scope for this PR, but all other workflows touched in this PR were already using v4. Let me know if it makes more sense to leave it out of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to keep it in this PR👍
Most likely it was an oversight.

@lyzlisa lyzlisa force-pushed the gh-action-add-npm-ci branch 2 times, most recently from 762e549 to ed2d410 Compare November 12, 2023 01:31
@lyzlisa lyzlisa force-pushed the gh-action-add-npm-ci branch from ed2d410 to 5da12f8 Compare November 23, 2023 18:17
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Looks great, thanks 🙂

@@ -17,10 +17,13 @@ jobs:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to keep it in this PR👍
Most likely it was an oversight.

@legendecas
Copy link
Member

The CI failure was caused by https://github.com/open-telemetry/opentelemetry-js/blob/8067d9721021cb25f94534a27cd2e6298ef7f6a2/.npmrc#L1C10-L1C10, which would cause npm bundled with node v14 and lower to abort.

I think the NPM_AUTH_TOKEN (example) can be an alternative to it.

@pichlermarc
Copy link
Member

pichlermarc commented Nov 29, 2023

The CI failure was caused by https://github.com/open-telemetry/opentelemetry-js/blob/8067d9721021cb25f94534a27cd2e6298ef7f6a2/.npmrc#L1C10-L1C10, which would cause npm bundled with node v14 and lower to abort.

Ah that's my fault. I added this - I'll remove it again. It's not yet used anyway. (PR to remove it: #4329)

Comment on lines +20 to +21
cache-dependency-path: |
package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/actions/setup-node#caching-global-packages-data suggests that package-lock.json will be used as a default:

The action defaults to search for the dependency file (package-lock.json, npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its hash as a part of the cache key. Use cache-dependency-path for cases when multiple dependency files are used, or they are located in different subdirectories.

However, I think it is fine either way.

- uses: actions/setup-node@v4
with:
cache: 'npm'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious if we are able to notice any speed up in npm ci steps in this or other workflows as a result of caching. With the variable GitHub Action runners it may be hard to get reliable numbers, though.

Copy link
Member

@legendecas legendecas Nov 29, 2023

Choose a reason for hiding this comment

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

From what I can tell from a quick small number of checks at https://github.com/open-telemetry/opentelemetry-js/actions/workflows/unit-test.yml for node-test (v18), the run time reduced from 2m35s to about 2m with this PR.

@trentm trentm merged commit 9e94536 into open-telemetry:main Dec 1, 2023
20 checks passed
@trentm trentm changed the title ci(opentelemetry-core): add npm cache in actions/setup-node@v3 ci: add npm cache in actions/setup-node Dec 1, 2023
@trentm
Copy link
Contributor

trentm commented Dec 1, 2023

Thanks @lyzlisa!

dyladan added a commit that referenced this pull request Dec 13, 2023
* Add Trent to approvers (#4311)

* chore(renovate): require dashboard approval for lerna updates (#4276)

* chore(ci): install semver globally to speed up "peer-api" workflow (#4270)

Closes: #4242

* fix(ci): remove token setup via environment variable from .npmrc (#4329)

* fix(instrumentation-http): resume responses when there is no response listener

Fixes a memory leak where unhandled response bodies pile up in node 20

* feat: add script to update changelogs on release preparation (#4315)

* feat: add script to update changelogs on releases

* fix: address comments

* Apply suggestions from code review

Co-authored-by: Trent Mick <[email protected]>

* fix: apply suggestions from code review

* fix: use packageJson.version instead of version

---------

Co-authored-by: Trent Mick <[email protected]>

* Fix event name

* test: make rawRequest HTTP-compliant

* Add node 20 to test matrix

* Enable old hash functions on 20

* Fix esm handling for iitm node 20

* Use err.code to make test more reliable

* Changelog

* nit: single import

* Remove unused files

* Add v20 to supported runtimes

* ci: add npm cache in actions/setup-node (#4271)

* feat(sdk-logs): add droppedAttributesCount field to ReadableLogRecord (#4289)

* feat(sdk-logs): add droppedAttributesCount field to ReadableLogRecord

* chore: check droppedAttributesCount value in test case

* feat(otlp-transformer): make toLogRecord() use ReadableLogRecord.droppedAttributesCount

---------

Co-authored-by: Marc Pichler <[email protected]>

* fix(api-logs): allow passing in TimeInput for LogRecord (#4345)

* fix: allow passing in TimeInput for LogRecord

* chore: update changelog

* fix: programmatic url and headers take precedence in metric exporters… (#4334)

* fix: programmatic url and headers take precedence in metric exporters (#2370)

* chore: adjust grpc exporter metrics test

* chore(changelog): update changelog

* fix(instrumentation-http): do not mutate given headers object for outgoing http requests (#4346)

Fixes: open-telemetry/opentelemetry-js-contrib#1609

* chore(deps): update actions/stale action to v9 (#4353)

* fix(deps): update dependency import-in-the-middle to v1.6.0 (#4357)

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

* chore(ci): use node 20 in lint workflow (#4359)

* chore(deps): update dependency linkinator to v6 (#4237)

* fix(otlp-exporter-base): decrease default concurrency limit to 30 (#4211)

* fix(otlp-exporter-base): decrease concurrency limit to 30

* fix(changelog): add changelog entry

* chore(deps): use actions/checkout >4 instead of 4.0.0 exactly (#4361)

---------

Co-authored-by: Marc Pichler <[email protected]>
Co-authored-by: strivly <[email protected]>
Co-authored-by: Trent Mick <[email protected]>
Co-authored-by: lyzlisa <[email protected]>
Co-authored-by: Hyun Oh <[email protected]>
Co-authored-by: Siim Kallas <[email protected]>
Co-authored-by: Vladimir Adamić <[email protected]>
Co-authored-by: Mend Renovate <[email protected]>
Zirak pushed a commit to Zirak/opentelemetry-js that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] enable npm-cache
4 participants