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

Update tapioca definitions when updating gems #5962

Closed
1 task done
fcheung opened this issue Oct 24, 2022 · 6 comments
Closed
1 task done

Update tapioca definitions when updating gems #5962

fcheung opened this issue Oct 24, 2022 · 6 comments
Labels
L: ruby:bundler RubyGems via bundler T: feature-request Requests for new features T: new-ecosystem Requests for new ecosystems/languages

Comments

@fcheung
Copy link

fcheung commented Oct 24, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Feature description

I use sorbet in my rails applications, in conjunction with tapioca. Amongst other things, tapioca generates rbi files for all the gems you use, so that sorbet is aware of them. A consequence of this is that when adding/updating gems you need to run

tapioca gem

to regenerate those rbi files as required.

Could dependabot do this for me whenever updating gems? Removing manual repetitive steps in updates is exactly what I look to dependabot for.

@fcheung fcheung added the T: feature-request Requests for new features label Oct 24, 2022
@fcheung fcheung changed the title Update tapioca definitions when update gems Update tapioca definitions when updating gems Oct 24, 2022
@pavera pavera added the L: ruby:bundler RubyGems via bundler label Oct 26, 2022
@jeffwidman jeffwidman added the T: new-ecosystem Requests for new ecosystems/languages label Nov 1, 2022
@jeffwidman
Copy link
Member

jeffwidman commented Nov 1, 2022

👋 Hey there.

Totally valid request, but I think the best way to tackle this is not via Dependabot but rather setup a GitHub action that watches for Dependabot PR's and then adds a follow-on commit running tapioca gem.

Here's an example action to help you get started hacking: https://github.com/dependabot/fetch-metadata/

Although ☝️ is probably more complicated than what you're looking for, it should be easy to strip it down to only what you need.

@fcheung
Copy link
Author

fcheung commented Nov 4, 2022

Thanks - that works well enough. If anyone else runs into this, this workflow seems to work well enough for us:

name: Dependabot Tapioca updates
on:
  pull_request:
    types: [opened, synchronize]

permissions:
  contents: write
  pull-requests: read
jobs:
  build:
    if: ${{ github.actor == 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    steps:
      - name: Fetch Dependabot metadata
        id: dependabot-metadata
        uses: dependabot/fetch-metadata@v1
      - uses: actions/checkout@v3
        if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'bundler' }}
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: ruby/setup-ruby@v1
        if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'bundler' }}
        with:
          ruby-version: '3.1.2'
          bundler-cache: true 
      - name: Tapioca update
        if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'bundler' }}
        run: bin/tapioca gem
      - name: git update
        if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'bundler' }}
        run: |
          git config --global user.name 'some user'
          git config --global user.email '[email protected]'
          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
          git add sorbet/rbi/gems
          git commit -m "updated tapioca definitions" sorbet/rbi/gems
          git push -u origin HEAD:${{ github.event.pull_request.head.ref }}

@jeffwidman
Copy link
Member

Glad to hear it. Thanks for circling back to share your solution with others.

@eric-hu
Copy link

eric-hu commented Apr 26, 2023

@fcheung thank you for sharing your solution. By any chance, did you have to do any extra configuration of your Github Actions? The commit back to the branch works, but Github Actions doesn't trigger off the pushed commit for me.

@jeffwidman
Copy link
Member

jeffwidman commented Apr 26, 2023

Are you using a PAT?

Because otherwise you can't trigger a GitHub action from a GitHub action:
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow

@eric-hu
Copy link

eric-hu commented Apr 26, 2023

Ahh thank you for the link @jeffwidman! This matches my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: ruby:bundler RubyGems via bundler T: feature-request Requests for new features T: new-ecosystem Requests for new ecosystems/languages
Projects
None yet
Development

No branches or pull requests

4 participants