Skip to content

Commit

Permalink
Use the pak based actions for tidy github actions (r-lib#1346)
Browse files Browse the repository at this point in the history
* Use the pak based actions for tidy github actions

* Update usethis workflows

* Re-arrange username and user-email

* Set the R-devel CI user agent to R 4.0

Because we want RSPM to serve the R 4.0 binaries for R-devel.

* Whitespace

Co-authored-by: Jenny Bryan <[email protected]>
  • Loading branch information
jimhester and jennybc authored Feb 9, 2021
1 parent d1aec93 commit 66fb1d0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 41 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ jobs:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: '3.6'}
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -57,19 +56,22 @@ jobs:
- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps_tree("local::.", dependencies = TRUE), ".github/r-depends.rds")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-2-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-2-
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install linux system dependencies
- name: Install system dependencies
if: runner.os == 'Linux'
run: Rscript -e 'pak::local_system_requirements(execute = TRUE)'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}

- name: Install macOS system dependencies
if: runner.os == 'macOS'
Expand Down Expand Up @@ -99,7 +101,9 @@ jobs:
env:
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_FORCE_SUGGESTS_: ${{ matrix.config.r != '3.3' }}
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,49 @@ name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
runs-on: ubuntu-18.04
env:
RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
- name: Install pak and query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install macOS system dependencies
if: runner.os == 'macOS'
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
brew install libgit2
brew install imagemagick@6
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("pkgdown", execute = TRUE)
shell: Rscript {0}

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("pkgdown")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
- name: Build and deploy pkgdown site
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,41 @@ name: test-coverage

jobs:
test-coverage:
runs-on: macOS-latest
runs-on: ubuntu-18.04
env:
RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
- name: Install pak and query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install macOS system dependencies
if: runner.os == 'macOS'
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
brew install libgit2
brew install imagemagick@6
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("covr", execute = TRUE)
shell: Rscript {0}

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("covr")
shell: Rscript {0}

- name: Configure Git user
Expand Down
6 changes: 3 additions & 3 deletions R/github-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ use_tidy_github_actions <- function() {

full_status <- use_github_action_check_full(repo_spec = repo_spec)
pr_status <- use_github_action_pr_commands()
pkgdown_status <- use_github_action("pkgdown")
test_coverage_status <- use_github_action("test-coverage")
pkgdown_status <- use_github_action("pkgdown-pak", save_as = "pkgdown.yaml")
test_coverage_status <- use_github_action("test-coverage-pak", save_as = "test-coverage.yaml")

old_configs <- proj_path(c(".travis.yml", "appveyor.yml"))
has_appveyor_travis <- file_exists(old_configs)
Expand Down Expand Up @@ -227,7 +227,7 @@ use_github_action_check_full <- function(save_as = "R-CMD-check.yaml",
# this must have `repo_spec` as an argument because it is called as part of
# use_tidy_github_actions()
use_github_action(
"check-full.yaml",
"check-pak.yaml",
save_as = save_as,
ignore = ignore,
open = open
Expand Down

0 comments on commit 66fb1d0

Please sign in to comment.