Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Format R code with air #43

Merged
merged 5 commits into from
Jan 17, 2025
Merged

feat: Format R code with air #43

merged 5 commits into from
Jan 17, 2025

Conversation

gadenbuie
Copy link
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
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
1 check passed
@gadenbuie gadenbuie deleted the feat/format-r-code branch January 17, 2025 16:43
Copy link
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