Skip to content

planningcenter/balto-syntax_tree

Repository files navigation

🐺 Balto SyntaxTree

Balto SyntaxTree is Smart and Fast:

  • Installs your version of SyntaxTree
  • Only runs on files that have changed

Balto SyntaxTree comprises a few different actions:

  • The core functionality is found at planningcenter/balto-syntax_tree, which runs stree write on files that have changed. On its own this doesn't result in any action, but it can be combined with other actions for a variety of uses.
  • For a "batteries included" setup, planningcenter/balto-syntax_tree/autofix will run the core action, commit anything that changed as a result, and optionally add that commit to .git-blame-ignore-revs.
  • For a "suggest, don't auto-fix" setup, planningcenter/balto-syntax_tree/suggestfix will run the core action, and if any files need formatting, it will leave a PR comment with a suggested rebase command that applies stree write at the right point in your commit history. The comment is automatically minimized (resolved) when all violations are fixed, and unminimized if they reappear.
  • There's also a planningcenter/balto-syntax_tree/append-to-file action that is really here for internal use. If you're brave, you can use it on its own, but there are no guarantees that it won't change without notice.

Example Usage

Autofix

Automatically commits formatting fixes to the PR branch:

name: Balto

on: [pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: ruby/setup-ruby@v1
      - uses: planningcenter/balto-syntax_tree/autofix@v1

Suggestfix

Comments with a suggested rebase command instead of auto-committing. The check fails until all files are formatted. The comment is resolved automatically when violations are fixed.

name: Balto

on: [pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: ruby/setup-ruby@v1
      - uses: planningcenter/balto-syntax_tree/suggestfix@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Other Languages

While SyntaxTree does support languages other than Ruby, this action does not support those at this time. Everything is very focused on Ruby files. If you need additional language support, feel free to open an issue to discuss or suggest a change with a pull request.

Inputs

Name Description Required Default
smartGemInstall Whether to try and install the fewest gems required to run SyntaxTree. When "false" it will run a full bundle install. no "true"
rootDirectory The directory containing your Ruby project (relative to repository root). Useful for monorepos, AWS Lambdas, etc. no "."
update-git-blame-ignore-revs Whether to append the formatting commit to .git-blame-ignore-revs and commit the change. When "false", the autofix action will still commit formatting changes but skip the blame-ignore-revs bookkeeping. Only applies to the autofix action. no "true"
useDevbox Whether to wrap the suggested rebase command in devbox run. Only applies to the suggestfix action. no "false"

About

🐺 Auto-formatter for SyntaxTree using GitHub Actions

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors