check-formatting.yml
Fail when any R file in the caller would be rewritten by Air, Posit’s R formatter. The check is air format --check -- <path> after posit-dev/setup-air installs a pinned Air release. Air is a Rust binary, so there is no R session to start.
It complements lint-changed-lines.yml: Air settles layout; lintr decides the rest of R style. It never rewrites the caller’s branch.
As of Air 0.11.0 the CLI still formats .R/.r only – not .Rmd or .qmd (include set from 0.9.0, posit-dev/air#476; still current as of 0.11.0, checked 2026-08-26). Generated files such as cpp11.R and folders such as renv/ are excluded by Air’s own defaults.
Adopting this in a repo that is not already Air-formatted is a large first-pass diff. Commit an air.toml at the project root first (empty is enough): Air’s configuration page recommends that so editors and CI share settings rather than picking up IDE tab-width or a user-level ~/.config/air/air.toml (user-level fallback added in Air 0.11.0, posit-dev/air#309; checked 2026-08-26). Run air format and commit that rewrite on its own, then enable the check, so the rewrite is reviewable separately from the CI change.
Derived from IndrajeetPatil/workflows check-formatting.yaml (MIT). That workflow’s README describes the job as “check and suggest”, but the job only checks – there is no --fix and no review-suggestion posting. This capability matches that check-only behavior.
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
version |
string | '0.11.0' |
Air release to install via posit-dev/setup-air. Pin a release rather than latest. Default is the version IndrajeetPatil/workflows locked on 2026-08-26 (0.11.0; gha#333 cited 0.9.0, which that workflow has since bumped). |
path |
string | '.' |
Path to format, relative to the repository root. Passed after -- to air format --check -- <path>. |
Permissions
Only contents: read (the default), so no permissions: block is needed.
Example
name: Check Formatting
on:
push: { branches: [main] }
pull_request:
workflow_dispatch:
jobs:
check:
uses: Morrison-Lab/gha/.github/workflows/check-formatting.yml@v2
# with:
# version: '0.10.0'
# path: 'R'See check-formatting.yml in examples/ for the full caller stub. (Linked to the directory rather than the file, for the reason check-secrets.qmd records: a blob/main/... link to a capability’s own example 404s on the pull request that introduces it, and check-links rightly fails it.)