Skip to content

feat: Format R code with air#43

Merged
gadenbuie merged 5 commits intomainfrom
feat/format-r-code
Jan 17, 2025
Merged

feat: Format R code with air#43
gadenbuie merged 5 commits intomainfrom
feat/format-r-code

Conversation

@gadenbuie
Copy link
Copy Markdown
Member

@gadenbuie gadenbuie commented Jan 15, 2025

Adds a composite workflow rstudio/shiny-workflows/format-r-code that is included into the routine workflow to format R code with air.

This composite workflow can be used anywhere with

- name: Format R code
  uses: rstudio/shiny-workflows/format-r-code@v1

In the routine workflow, I've put the formatting step behind inputs.format-r-code, which is false by default. To turn it on:

  routine:
    uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@feat/format-r-code # @v1
    with:
      format-r-code: true

That lets us opt-in slowly initially or eventually we can change the default value and start formatting everything.

The composite workflow has additional inputs:

  • version (default: latest) - which version of air to use so that we could pin to a specific version.
  • check (default: false) - when "true" calls air format --check, which exits with a non-zero status if any files change, no changes are committed
  • path (default: .) - paths passed to air format ..., can be files or directories, e.g. R inst to format R files in R/ and inst/ only. The current default formats all R files in the repo (aggressive but useful).

I've used this workflow in bslib as a demo: rstudio/bslib#1167

@gadenbuie gadenbuie requested a review from schloerke January 16, 2025 22:11
@gadenbuie
Copy link
Copy Markdown
Member Author

I'm going to merge this, but feel free to leave comments here and I'll follow up.

@gadenbuie gadenbuie merged commit 7efb26e into main Jan 17, 2025
@gadenbuie gadenbuie deleted the feat/format-r-code branch January 17, 2025 16:43
Copy link
Copy Markdown
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making it opt-in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants