Skip to main content

Trunk

You can use Trunk to integrate sqlfmt into VSCode, GitHub Actions, and your local development workflow.

Installation

curl https://get.trunk.io -fsSL | bash
trunk init
trunk check enable sqlfmt

VSCode

You can install the VSCode extension here, which will not only flag formatting issues for you

Screenshot of Trunk showing a sqlfmt issue in VSCode

but also allow you to use Trunk to format-on-save SQL files with sqlfmt:

.vscode/settings.json
{
"editor.defaultFormatter": "trunk.io"
"editor.formatOnSave": true,
}

GitHub Actions

Trunk provides a GitHub Action that will highlight lint and formatting issues for you, including sqlfmt issues.

Screenshot of Trunk showing a sqlfmt issue in GitHub

Here's an example workflow that you can use:

.github/workflows/pr.yaml
name: Pull Request
on: [pull_request, workflow_dispatch]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
trunk_check:
name: Trunk Check Runner
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Trunk Check
uses: trunk-io/trunk-action@v1

Learn more

More information can be found in Trunk's documentation.