Skip to content

Commit

Permalink
.github/workflows: add action to update tapioca definitions
Browse files Browse the repository at this point in the history
- Tapioca is a companion gem to Sorbet that generates RBI files for the
  Ruby gems in a project.
- Whenever Dependabot updates a gem, Tapioca has to regenerate that gem's
  RBI files so that Sorbet can accurately assess the state of the typing
  of a codebase.
- We also must regenerate Sorbet's view of
  [things defined at runtime](https://sorbet.org/docs/rbi#the-hidden-definition-rbi):
  this is what it calls `hidden-definitions`.
- Obviously, this got tedious to do manually. So here's an Action that
  runs every three days and raises a PR if there are any changes.

Co-authored-by: Vidushee Amoli <vidushee.amoli@gmail.com>
Co-authored-by: Issy Long <me@issyl0.co.uk>
Co-authored-by: Jonathan Chang <jchang641@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information
4 people committed Aug 15, 2020
1 parent 7d78949 commit d30f615
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/tapioca-update.yml
@@ -0,0 +1,57 @@
name: Tapioca Update
on:
push:
paths:
- .github/workflows/tapioca-update.yml
schedule:
- cron: '0 0 */3 * *' # every three days
env:
HOMEBREW_SORBET: 1
jobs:
update-tapioca:
if: github.repository == 'Homebrew/brew'
runs-on: ubuntu-latest
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Configure Git user
uses: Homebrew/actions/git-user-config@master
with:
username: BrewTestBot

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.3

- name: Update Tapioca Definitions
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
bundle install
bundle exec tapioca sync --exclude json
bundle exec srb rbi hidden-definitions
if ! git diff --exit-code -- sorbet; then
BRANCH="tapioca-update"
if ! git ls-remote --exit-code --heads origin "$BRANCH"; then
git checkout -b "$BRANCH"
git commit -am "sorbet: Update gem RBI files using Tapioca
Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/actions?query=workflow%3A%22Tapioca+Update%22)."
fi
fi
- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: tapioca-update
directory: Library/Homebrew/

- name: Open a PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
hub pull-request -m "$(git log -1 --format='%s')"

0 comments on commit d30f615

Please sign in to comment.