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

[linters] Install tools based on versions in package.json #2323

Merged
merged 11 commits into from
Mar 1, 2022

Conversation

chalin
Copy link
Contributor

@chalin chalin commented Feb 7, 2022

I'm having issues running certain spec checks from the website because it's working from a spec submodule. This PR:

  • Switches to using npx to run npm commands rather than hardcoded paths
  • Uses npm install to install all necessary NPM-based tools

IMHO, this is a clean and conventional way to deal with NPM packages. WDYT?

/cc @austinlparker

@chalin chalin requested review from a team February 7, 2022 21:42
CONTRIBUTING.md Show resolved Hide resolved
Makefile Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

❤️

Makefile Outdated Show resolved Hide resolved
Copy link
Member

@joaopgrassi joaopgrassi left a comment

Choose a reason for hiding this comment

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

This is great! I just left a few small things.

Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
package.json Show resolved Hide resolved
Makefile Show resolved Hide resolved
@chalin chalin force-pushed the chalin-use-npx-2022-02-07 branch from 030c93d to 33be543 Compare February 8, 2022 14:00
@arminru arminru added the editorial Editorial changes only (typos, changelog, ...). No content-related changes of any kind. label Feb 9, 2022
@chalin chalin force-pushed the chalin-use-npx-2022-02-07 branch from 33be543 to 5ca87aa Compare February 10, 2022 19:34
@chalin
Copy link
Contributor Author

chalin commented Feb 10, 2022

Rebased and conflicts resolved. Ready for a final review.

Copy link
Member

@joaopgrassi joaopgrassi left a comment

Choose a reason for hiding this comment

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

Looks good to me! I only have one concern about pinning package versions to avoid surprises (as we had a few days ago). But I'll leave that to others to consider as well.

.github/workflows/checks.yaml Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@chalin
Copy link
Contributor Author

chalin commented Feb 11, 2022

@joaopgrassi - thanks for the feedback! I've made the changes that you suggested. PTAL

.github/workflows/checks.yaml Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
@chalin
Copy link
Contributor Author

chalin commented Feb 15, 2022

I believe that the last issue has been addressed. PTAL

Copy link
Member

@joaopgrassi joaopgrassi left a comment

Choose a reason for hiding this comment

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

LGTM and thanks for working on this!

@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Feb 23, 2022
@joaopgrassi
Copy link
Member

Hi @chalin, I think this is ready right? @anuraaga maybe you can take another look? Would be a pity if this is closed due to inactivity

CONTRIBUTING.md Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@chalin chalin force-pushed the chalin-use-npx-2022-02-07 branch from c354ac7 to 0e63459 Compare February 23, 2022 15:37
Makefile Show resolved Hide resolved
@github-actions github-actions bot removed the Stale label Feb 24, 2022
@chalin chalin force-pushed the chalin-use-npx-2022-02-07 branch from 21d4389 to 7843f42 Compare March 1, 2022 14:39
@chalin
Copy link
Contributor Author

chalin commented Mar 1, 2022

Hi all: I've restored the old target behavior by using install-checks. I see this as win-win, WDYT @Oberon00, @joaopgrassi, @yurishkuro @carlosalberto and others? While conceptually less clean, this addresses the concerns that @Oberon00 raised. My hope is that we can now have enough of a consensus to get this PR merged.

Copy link
Member

@joaopgrassi joaopgrassi left a comment

Choose a reason for hiding this comment

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

Both approaches are fine to me. I'm no expert in Make, but the build passes and I don't see anything clearly wrong. 👍

@chalin
Copy link
Contributor Author

chalin commented Mar 1, 2022

Thanks for the feedback @joaopgrassi.
Is this ready to merge, before the bot closes it!?! 😉 😄

@yurishkuro
Copy link
Member

I am resolving discussions and merging. Feel free to open new tickets if changes are needed, but in the current state the PR is an overall improvement.

@yurishkuro yurishkuro changed the title [editorial] Use npx to run npm cmds, not hardcoded paths [linters] Install tools based on versions in package.json Mar 1, 2022
@yurishkuro yurishkuro merged commit f6e07be into open-telemetry:main Mar 1, 2022
@chalin chalin deleted the chalin-use-npx-2022-02-07 branch March 2, 2022 00:20
@tigrannajaryan
Copy link
Member

@chalin After this change I can no longer do make markdownlint on my Mac. I get:

$ make markdownlint
/Users/tnajaryan/work/repos/opentelemetry-specification
└─┬ [email protected]
  └── [email protected] 

./CHANGELOG.md
npx: installed 203 in 6.874s
npx: command not found: markdownlint-cli
make: *** [markdownlint] Error 1

Any advice on what I need to do to make this work locally?

@yurishkuro
Copy link
Member

Indeed - why did CI pass then?

It works for me after this patch:

diff --git a/Makefile b/Makefile
index e0d64e4..755e8e6 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ markdownlint:
        @if ! npm ls markdownlint; then npm install; fi
        @for f in $(ALL_DOCS); do \
                echo $$f; \
-               npx --no -p markdownlint-cli markdownlint -c .markdownlint.yaml $$f \
+               npx --no -p markdownlint markdownlint -c .markdownlint.yaml $$f \
                        || exit 1; \
        done

however it seems to be re-doing npm install for each file:

./specification/compatibility/opencensus.md
npx: installed 203 in 4.611s
./specification/compatibility/openmetrics.md
npx: installed 203 in 4.363s
./specification/compatibility/opentracing.md
npx: installed 203 in 4.437s
./specification/context/api-propagators.md
npx: installed 203 in 4.312s
./specification/context/context.md

@yurishkuro
Copy link
Member

I suggest we revert this PR until it can be properly fixed

@yurishkuro
Copy link
Member

also, we need to add .nvmrc that specifies the required Node version. I tried running with v10 and some installed packages didn't like it, they were >=12

@chalin
Copy link
Contributor Author

chalin commented Mar 3, 2022

Checking. Yes, adding an .nvmrc is a good idea. I can do that if you'd like.

@chalin
Copy link
Contributor Author

chalin commented Mar 3, 2022

Indeed, possibly a Node version issue.

@chalin After this change I can no longer do make markdownlint on my Mac. I get:

$ make markdownlint
/Users/tnajaryan/work/repos/opentelemetry-specification
└─┬ [email protected]
  └── [email protected] 

./CHANGELOG.md
npx: installed 203 in 6.874s
npx: command not found: markdownlint-cli
make: *** [markdownlint] Error 1

Any advice on what I need to do to make this work locally?

It works fine for me locally under macOS 11.6.4. I'm using the latest LTS version of Node:

$ nvm current
v16.13.0

You?

@chalin
Copy link
Contributor Author

chalin commented Mar 3, 2022

also, we need to add .nvmrc that specifies the required Node version. ...

Done, see #2401.

@yurishkuro
Copy link
Member

Confirmed, works w/ v16, but not with v14.

@tigrannajaryan
Copy link
Member

v16 works for me too.

carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
…etry#2323)

* [editorial] Use `npx` to run npm cmds, not hardcoded paths

* Update Makefile based on feedback

* Use --no-install option for npx

* Add `npm install` to markdown-check workflows

* Pin markdownlint-cli at 0.31.0

* Run `npm install` as a separate workflow step

* Use name 'install dependencies' for npm install cmd

* CONTRIBUTING: clarify that you install the tools once

* make: add `install-tools` as dependency to `all`

* Add install check line to `mardown*` targets

Co-authored-by: Yuri Shkuro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial Editorial changes only (typos, changelog, ...). No content-related changes of any kind.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants