From 21744cc90b0254687e9f8667bb11baf1be2ab877 Mon Sep 17 00:00:00 2001 From: Sebastian Gatscha Date: Sun, 1 Sep 2024 23:29:11 +0200 Subject: [PATCH] GHA style, rename GHA --- .github/workflows/Check-NoSugests.yaml | 2 +- .github/workflows/pkgdown.yaml | 2 + .github/workflows/style.yaml | 77 ++++++++++++++++++++++++++ inst/examples/antpath_app.R | 5 +- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/style.yaml diff --git a/.github/workflows/Check-NoSugests.yaml b/.github/workflows/Check-NoSugests.yaml index 27340b00..2dcfb6ad 100644 --- a/.github/workflows/Check-NoSugests.yaml +++ b/.github/workflows/Check-NoSugests.yaml @@ -12,7 +12,7 @@ on: pull_request: branches: [main, master] -name: check-no-suggests.yaml +name: R-CMD-check(NoSuggests) permissions: read-all diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 01f99b27..c5a25af2 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -11,6 +11,8 @@ on: permissions: read-all +name: pkgdown + jobs: pkgdown: runs-on: ubuntu-latest diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml new file mode 100644 index 00000000..a8600065 --- /dev/null +++ b/.github/workflows/style.yaml @@ -0,0 +1,77 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"] + +name: style.yaml + +permissions: read-all + +jobs: + style: + runs-on: ubuntu-latest + permissions: + contents: write + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::styler, any::roxygen2 + needs: styler + + - name: Enable styler cache + run: styler::cache_activate() + shell: Rscript {0} + + - name: Determine cache location + id: styler-location + run: | + cat( + "location=", + styler::cache_info(format = "tabular")$location, + "\n", + file = Sys.getenv("GITHUB_OUTPUT"), + append = TRUE, + sep = "" + ) + shell: Rscript {0} + + - name: Cache styler + uses: actions/cache@v4 + with: + path: ${{ steps.styler-location.outputs.location }} + key: ${{ runner.os }}-styler-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-styler- + ${{ runner.os }}- + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: Commit and push changes + run: | + if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \ + | egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$')) + then + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)" + git pull --ff-only + git push origin + else + echo "No changes to commit." + fi diff --git a/inst/examples/antpath_app.R b/inst/examples/antpath_app.R index 4bec7e4a..19779b5f 100644 --- a/inst/examples/antpath_app.R +++ b/inst/examples/antpath_app.R @@ -19,8 +19,9 @@ ui <- fluidPage( server <- function(input, output, session) { output$map <- renderLeaflet({ - leaflet() %>% - addTiles() %>% addMapPane("my-pane", 420) %>% + leaflet() %>% + addTiles() %>% + addMapPane("my-pane", 420) %>% addAntpath(data = coords, layerId = ~FGN, label = ~sprintf("Ant-Colony of %s", district),