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

Calls from Hugo fail #1

Closed
reitzig opened this issue May 29, 2020 · 10 comments
Closed

Calls from Hugo fail #1

reitzig opened this issue May 29, 2020 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@reitzig
Copy link
Owner

reitzig commented May 29, 2020

When used in tandem with https://github.com/peaceiris/actions-hugo, calls to asciidoctor from Hugo fail:

/home/runner/work/today-i-learned/today-i-learned/actions_asciidoctor/asciidoctor rendering posts/2020-04-24-navigating-slack.adoc: fork/exec /home/runner/work/today-i-learned/today-i-learned/actions_asciidoctor/asciidoctor: exec format error

Not sure what the qualitative difference to the old hack on that end is, though.

@reitzig reitzig added bug Something isn't working help wanted Extra attention is needed labels May 29, 2020
@peaceiris
Copy link

ruby ${binary} ${options} "\$@"

- ruby ${binary} ${options} "\$@"
+ ${binary} ${options} "\$@"

Why do you run the binary via ruby?

@reitzig
Copy link
Owner Author

reitzig commented May 29, 2020

Bad naming on my part; asciidoctor isn't a binary:

$ head (which asciidoctor)                                                                                                                       0⚹  0↺  0🗴 0≡   🜉 adopt-asciidoctor-setup 
#!/usr/bin/ruby

require 'rubygems' unless defined? Gem

if File.exist?(asciidoctor = (File.expand_path '../../lib/asciidoctor', __FILE__))
  require asciidoctor
else
  require 'asciidoctor'
end
require 'asciidoctor/cli'

I found that out while writing the Windows wrapper (batch doesn't use shebangs, so I needed the extra call).

For the bash wrapper, the error is the same with or without the explicit ruby call.

@peaceiris
Copy link

See my other approach. We probably do not need such a script to add the options.

@reitzig
Copy link
Owner Author

reitzig commented May 29, 2020

Aliases for sure wouldn't work from one action to the next step, would they? We could hack the .bashrc, but I think builds are run with sh. Wouldn't want to couple to such details, to be honest. :/

I would much rather understand that weird error, and why it appears in one build but not the other. What's the difference between the wrapper written here and the old one that works?

@peaceiris
Copy link

I do not figure out that different behavior, too.

Anyway, this surely works well. Does not this satisfy your demand? Do you want to choose the approach of asciidoctor setup action?

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.7

      - run: gem install asciidoctor
      - run: |
          alias asciidoctor="asciidoctor --attribute=experimental=true --attribute=icons=font"
          hugo --minify
  • Switched bundle to gem
  • Deleted the line bundle config set path 'vendor/bundle'

@reitzig
Copy link
Owner Author

reitzig commented May 29, 2020

Oh, no. 🤦‍♂️ 🤣

return `
    #!/bin/bash

    foo
`

Will create this:

    #!/bin/bash

    foo

Which does, indeed, not run: the shebang has to start at the first character of the file, it seems.

Why it seems to work for the test in this repo, no idea. As far as I can tell, the test is effective and the script is actually used. But that latest commit fixed the issue downstream. 🤷

@peaceiris
Copy link

Hahaha, 🤣 I've faced the same problem ever, too.

@reitzig
Copy link
Owner Author

reitzig commented May 29, 2020

Anyway, this surely works well. Does not this satisfy your demand? Do you want to choose the approach of asciidoctor setup action?

Good point. To reiterate:

  • I tried gem install asciidoctor but it failed due to a bug in gem (apparently), and
  • the fixing sudo gem update --system 3.0.6 too lots of time.
  • That's when you proposed using bundler and the setup-ruby action which I didn't know about.
  • Now I'm thinking, that's a lot if stuff to repeat in every Hugo page that uses asciidoctor.
  • Plan: Write a small action for this, and learn something about Github Actions along the way.

With this action, the usage site is even longer than what you propose:

  - name: Setup Hugo
    uses: peaceiris/actions-hugo@v2
    with:
      hugo-version: 'latest'

  - name: Setup Ruby
    uses: ruby/setup-ruby@v1
    with:
      ruby-version: 2.7

  - name: Setup asciidoctor
    uses: reitzig/actions-asciidoctor@v1
    with:
      options: "-a experimental=true -a icons=font"

  - name: Build
    run: hugo --minify

To be fair, this is mostly because actions can't call/depend on one another so everybody has to repeat ruby/setup-ruby. Meh.

So yes: Not a lot of value is added here at this point. Point taken. I'll chalk it down to a learning experience and see if maintaining it is more pain than just copy pasting that a little more hacky snippet of yours. 😅

Thanks for your work and time! 👋

@reitzig reitzig closed this as completed May 29, 2020
@peaceiris
Copy link

Just my comment.

Maybe, it is worth to suggest our feature request to ruby/setup-ruby about separating their core function. If we can call it from the actions-asciidoctor, we do not need to repeat the ruby/setup-ruby step on our workflow files.

@reitzig
Copy link
Owner Author

reitzig commented May 29, 2020

Good point. Done, and tracked here under #4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants