Integrations

Pre-Commit

pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. It runs checks on your code before each commit to ensure quality and consistency.

Create a .pre-commit-config.yaml file in your repository root:

repos:
  - repo: https://github.com/jolars/panache
    rev: v2.17.0
    hooks:
      - id: panache-format
      - id: panache-lint

Then install the hooks:

pre-commit install

panache provides two hook IDs:

panache-format
Automatically formats files according to panache’s formatting rules
panache-lint
Lints files and automatically applies fixes where possible

Pass additional arguments to panache:

repos:
  - repo: https://github.com/jolars/panache
    rev: v2.17.0
    hooks:
      - id: panache-format
        args: [--config, custom-config.toml]

File Patterns

By default, hooks run on .qmd, .md, .markdown, and .Rmd files. Override with files:

repos:
  - repo: https://github.com/jolars/panache
    rev: v2.17.0
    hooks:
      - id: panache-format
         files: '\.(qmd|Rmd)$' # Only .qmd and .Rmd

GitHub Actions

Integrate panache into your CI pipeline using GitHub Actions:

name: panache
on:
  pull_request:
  push:
    branches: [main]
jobs:
  format-and-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-panache-${{ hashFiles('**/Cargo.lock') }}
      - name: Install panache
        run: cargo install panache --locked
      - name: Check formatting
        run: panache format --check .
      - name: Run linter
        run: panache lint --check .

This workflow:

  1. Installs Rust and panache
  2. Caches the cargo installation for faster subsequent runs
  3. Checks that all files are formatted (--check mode)
  4. Runs the linter in CI mode (--check mode)

Both steps will fail (exit code 1) if issues are found, preventing the PR from merging.