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

asyncapi v0.11.2 (new formula) #92115

Closed
wants to merge 8 commits into from
Closed

Conversation

derberg
Copy link
Contributor

@derberg derberg commented Dec 28, 2021

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

formula generated with https://github.com/zmwangx/homebrew-npm-noob, only tests added, inspired by https://github.com/Homebrew/homebrew-core/blob/master/Formula/angular-cli.rb

@BrewTestBot BrewTestBot added new formula PR adds a new formula to Homebrew/homebrew-core nodejs Node or npm use is a significant feature of the PR or issue labels Dec 28, 2021
@derberg
Copy link
Contributor Author

derberg commented Dec 28, 2021

I haven't been able to test it locally because of error RuntimeError: npm failed to pack. I see that for the same reason tests fail here on CI.

I tried to find some answers online but haven't found any answers 😞

@derberg
Copy link
Contributor Author

derberg commented Dec 28, 2021

I wonder if it is because in bin dir there is just a run file and should be asyncapi file 🤔

@derberg
Copy link
Contributor Author

derberg commented Dec 28, 2021

I just checked another example, apollo-cli formula and they also use oclify to build CLI, and they also have run as name of the run file, so the same as we have -> https://github.com/apollographql/apollo-tooling/tree/master/packages/apollo/bin so all should be good on that side.

any ideas? should I open a separate issue?

@derberg
Copy link
Contributor Author

derberg commented Dec 28, 2021

/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /Users/wookiee/sources/homebrew-core/Formula/asyncapi.rb
Error: Failed to load cask: asyncapi.rb
Cask 'asyncapi' is unreadable: wrong constant name #<Class:0x00007fbf6396ff58>
Warning: Treating asyncapi.rb as a formula.
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/pkg-config.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.9.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gdbm.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mpdecimal.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/openssl@1.1.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/ca-certificates.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/readline.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sqlite.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/xz.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/brotli.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/cmake.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/c-ares.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/icu4c.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libnghttp2.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libuv.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/autoconf.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m4.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/automake.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libtool.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sphinx-doc.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.10.rb
==> Downloading https://registry.npmjs.org/@asyncapi/cli/-/cli-0.11.2.tgz
/usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/3.3.9-69-g435e22d\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.6\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://registry.npmjs.org/@asyncapi/cli/-/cli-0.11.2.tgz
Already downloaded: /Users/wookiee/Library/Caches/Homebrew/downloads/077d50a7dddd68e480889da4e75aa519fd0f95832325667752b99e5e61107732--cli-0.11.2.tgz
==> Verifying checksum for '077d50a7dddd68e480889da4e75aa519fd0f95832325667752b99e5e61107732--cli-0.11.2.tgz'
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/brotli.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/c-ares.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/icu4c.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libnghttp2.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libuv.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/openssl@1.1.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/ca-certificates.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/pkg-config.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.9.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gdbm.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mpdecimal.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/readline.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sqlite.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/xz.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/cmake.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/autoconf.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m4.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/automake.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libtool.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sphinx-doc.rb
/usr/local/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.10.rb
tar --extract --no-same-owner --file /Users/wookiee/Library/Caches/Homebrew/downloads/077d50a7dddd68e480889da4e75aa519fd0f95832325667752b99e5e61107732--cli-0.11.2.tgz --directory /private/tmp/d20211228-35985-1nlrqbh
cp -pR /private/tmp/d20211228-35985-1nlrqbh/package/. /private/tmp/asyncapi-20211228-35985-bhajeb/package
chmod -Rf +w /private/tmp/d20211228-35985-1nlrqbh
/usr/local/Homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
RuntimeError: npm failed to pack /private/tmp/asyncapi-20211228-35985-bhajeb/package
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 1
==> Temporary files retained at:
/private/tmp/asyncapi-20211228-35985-bhajeb
Error: An exception occurred within a child process:
  RuntimeError: npm failed to pack /private/tmp/asyncapi-20211228-35985-bhajeb/package
/usr/local/Homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
/usr/local/Homebrew/Library/Homebrew/ignorable.rb:28:in `callcc'
/usr/local/Homebrew/Library/Homebrew/ignorable.rb:28:in `raise'
/usr/local/Homebrew/Library/Homebrew/language/node.rb:34:in `pack_for_installation'
/usr/local/Homebrew/Library/Homebrew/language/node.rb:59:in `std_npm_install_args'
/Users/wookiee/sources/homebrew-core/Formula/asyncapi.rb:17:in `install'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:17:in `block in install'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:90:in `debrew'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:17:in `install'
/usr/local/Homebrew/Library/Homebrew/build.rb:172:in `block (3 levels) in install'
/usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
/usr/local/Homebrew/Library/Homebrew/build.rb:134:in `block (2 levels) in install'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1297:in `block in brew'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2473:in `block (2 levels) in stage'
/usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2472:in `block in stage'
/usr/local/Homebrew/Library/Homebrew/resource.rb:126:in `block (2 levels) in unpack'
/usr/local/Homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
/usr/local/Homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
/usr/local/Homebrew/Library/Homebrew/download_strategy.rb:102:in `stage'
/usr/local/Homebrew/Library/Homebrew/resource.rb:122:in `block in unpack'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `run'
/usr/local/Homebrew/Library/Homebrew/resource.rb:208:in `mktemp'
/usr/local/Homebrew/Library/Homebrew/resource.rb:121:in `unpack'
/usr/local/Homebrew/Library/Homebrew/resource.rb:96:in `stage'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2452:in `stage'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1290:in `brew'
/usr/local/Homebrew/Library/Homebrew/build.rb:129:in `block in install'
/usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
/usr/local/Homebrew/Library/Homebrew/build.rb:124:in `install'
/usr/local/Homebrew/Library/Homebrew/build.rb:224:in `<main>'

Formula/asyncapi.rb Outdated Show resolved Hide resolved
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
@carlocab
Copy link
Member

@chrmoritz, any chance you could look at the npm failed to pack error?

@chrmoritz
Copy link
Contributor

That's an issue with language node. The error comes from postpack trying to delete an non existing file at that point.

It can be worked around by disabling the postpack script and later deleting that file manually, like so

  def install
    inreplace "package.json", "postpack", "postpack_disabled"
    system "npm", "install", *Language::Node.std_npm_install_args(libexec)
    bin.install_symlink Dir["#{libexec}/bin/*"]
    rm libexec/"lib/node_modules/@asyncapi/cli/oclif.manifest.json"
  end

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

@carlocab @chrmoritz thanks a lot folks, I applied the workaround, locally installation works and tests pass 💪🏼

Thanks a bunch!

tbh I still do not get why this script is fired after all, like, when I install locally with verbose flag, these is nothing about postpack script being triggered. It is triggered by npm only when you call npm pack or npm publish, but definitely not npm install. Anyway, most important is that it works ❤️

Comment on lines 13 to 16
inreplace "package.json", "postpack", "postpack_disabled"
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
rm libexec/"lib/node_modules/@asyncapi/cli/oclif.manifest.json"
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some comments explaining why we're doing the inreplace and rm here?

@chrmoritz
Copy link
Contributor

The reason is, that homebrew doesn't do a normal npm instal formula -g --prefix=libexec, because that would mean we throw away our downloaded source of the formula and let npm download everything. Currently we do some hacks to make npm reuse the Homebrew downloaded sources of the formula, which unfortunately has a few edge cases like this one, see: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/language/node.rb

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

It still puzzles me why it is needed 😄

Take apollo CLI and their formula. They use oclif, also have manifest file but do not need a workaround

In their package.json. They do rm -f of manifest file, so basically making sure no failure when it is not there, but we use rimraf that behaves exactly the same 🤷🏼

@chrmoritz
Copy link
Contributor

chrmoritz commented Jan 17, 2022

In their package.json. They do rm -f of manifest file, so basically making sure no failure when it is not there, but we use rimraf that behaves exactly the same 🤷🏼

They use rm -f and it doesn't error on a non existing file, unlike rimraf which you are using in asyncapi. Not saying that this is the better behaviour, it just doesn't trigger the issue here.

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

We use rimraf so basically anyone can run a script on any operating system (including windows) and it will work, rm is just not there on windows.

but locally when I test, rimraf behaves exactly the same as rm -f, actually rm -rf. No errors are triggered in the console. Super strange

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

still CI fails 🤔 but locally workaround proved to work

@chrmoritz
Copy link
Contributor

chrmoritz commented Jan 17, 2022

Oh my mistake, I didn't remembered correctly. The issue is that devDependencies aren't installed in Homebrew at the time postpack is called, so actual rimraf itself is not existing. So another maybe better fix is to replace rimraf oclif.manifest.json by rm -f oclif.manifest.json, since Homebrew will only run on MacOS or Linux (or WSL) only anyway.

The remaining CI issue is about shipping a universal binary fixed by adding

 def install
    # Call rm -f instead of rimraf, because devDeps aren't present in Homebrew at postpack time
    inreplace "package.json", "rimraf oclif.manifest.json", "rm -f oclif.manifest.json"
    system "npm", "install", *Language::Node.std_npm_install_args(libexec)
    bin.install_symlink Dir["#{libexec}/bin/*"]
    # Replace universal binaries with their native slices
    deuniversalize_machos
  end

The other issue is that the cli repo isn't noticeable enough, but maybe the Homebrew maintainers do an exception here, since your main repo clearly is.

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

Nice! now it is all clear 😆 thanks a bunch, and 🍻 for responsiveness 🙇🏼

Yes, CLI is just a repo, it is for tooling related to https://github.com/asyncapi/spec (almost 1.9k ⭐ ) and one of the tools that it integrates is https://github.com/asyncapi/generator (409 ⭐ ). We are just not fans of monorepo there.

@derberg
Copy link
Contributor Author

derberg commented Jan 17, 2022

rimraf issues solved 🥳
only confusion about ⭐ is there

what would be the next steps?
we can ask the AsyncAPI community to add ⭐ to meet the requirement, but does it make sense if we know we have a big user base already?

@carlocab carlocab added the CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. label Jan 17, 2022
@carlocab
Copy link
Member

we can ask the AsyncAPI community to add ⭐ to meet the requirement, but does it make sense if we know we have a big user base already?

It would be nice if you could do this. We regularly reject new formulae for the notability requirement, and I'd really rather not give the contributors whose PRs we reject the excuse of "but you accepted x, and they don't meet the notability requirement". (These arguments are rarely successful, but that doesn't make dealing with them any better.)

@derberg
Copy link
Contributor Author

derberg commented Jan 20, 2022

@carlocab Hey, so this is what we got

Screenshot 2022-01-20 at 08 56 19

Is it enough for a proof? I know you expect 30 watches but tbh I do not want to push the community to do it, even I limit my watching on repos and rely on totally different tools to be up to date (automation with slack).

These are the numbers from our main repo
Screenshot 2022-01-20 at 08 59 29

And also from previous CLI for code generation
Screenshot 2022-01-20 at 08 59 52

I hope we won't suffer just because we do not like monorepos 😄

Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

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

Apologies for the delay here, @derberg. I missed your last message -- I have way too many GitHub notifications.

No need for additional "watches" -- the notability criteria is actually "any of" and not "all of", so the stars are enough.

Thanks for your contribution!

@carlocab carlocab added the ready to merge PR can be merged once CI is green label Feb 3, 2022
@BrewTestBot
Copy link
Member

:shipit: @carlocab has triggered a merge.

PythonCoderAS added a commit to PythonCoderAS/homebrew-brew that referenced this pull request May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. new formula PR adds a new formula to Homebrew/homebrew-core nodejs Node or npm use is a significant feature of the PR or issue ready to merge PR can be merged once CI is green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants