Skip to content

Merge pull request #110 from RConsortium/59_report-tlf #50

Merge pull request #110 from RConsortium/59_report-tlf

Merge pull request #110 from RConsortium/59_report-tlf #50

Workflow file for this run

---
name: Check Code Style
on:
workflow_dispatch:
workflow_call:
inputs:
r-version:
description: 'The version of R to use'
default: '4.2'
required: false
type: string
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel
concurrency:
group: style-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
roxygen:
name: Style
runs-on: ubuntu-20.04
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
if: >
!contains(github.event.commits[0].message, '[skip spellcheck]')
steps:
##################### BEGIN boilerplate steps #####################
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v5.4
- name: Checkout repo (PR) 🛎
uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Checkout repository
uses: actions/checkout@v3
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
- name: Normalize inputs
id: normalizer
run: |
R_VERSION="${{ inputs.r-version }}"
if [ "$R_VERSION" == "" ]
then {
R_VERSION="4.2"
}
fi
echo "::set-output name=R_VERSION::$R_VERSION"
shell: bash
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ steps.normalizer.outputs.R_VERSION }}
- name: Restore cache
uses: actions/cache@v3
with:
path: |
~/.local/share/renv
~/.staged.dependencies
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: ${{ runner.os }}-renv-
- name: Install Dependencies
run: |
if (!requireNamespace("styler", quietly = TRUE)) {
install.packages("styler")
}
shell: Rscript {0}
- name: Run styler 🖼️
run: |
detect <- styler::style_pkg(dry = "on")
if (TRUE %in% detect$changed) {
problems <- subset(detect$file, detect$changed == T)
cat(paste("Styling errors found in", length(problems), "files\n"))
cat("Please run `styler::style_pkg()` to fix the style\n")
quit(status = 1)
}
shell: Rscript {0}