|
| 1 | +# NOTE: This workflow is overkill for most R packages |
| 2 | +# check-standard.yaml is likely a better choice |
| 3 | +# usethis::use_github_action("check-standard") will install it. |
| 4 | +# |
| 5 | +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. |
| 6 | +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - release |
| 12 | + - develop |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + - release |
| 17 | + - develop |
| 18 | + paths-ignore: |
| 19 | + - 'docs/**' |
| 20 | + |
| 21 | +name: R-CMD-check |
| 22 | + |
| 23 | +jobs: |
| 24 | + R-CMD-check: |
| 25 | + runs-on: ${{ matrix.config.os }} |
| 26 | + |
| 27 | + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) |
| 28 | + |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + config: |
| 33 | + - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} |
| 34 | + - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} |
| 35 | + - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} |
| 36 | + |
| 37 | + env: |
| 38 | + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true |
| 39 | + RSPM: ${{ matrix.config.rspm }} |
| 40 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + |
| 45 | + - uses: r-lib/actions/setup-r@v1 |
| 46 | + with: |
| 47 | + r-version: ${{ matrix.config.r }} |
| 48 | + http-user-agent: ${{ matrix.config.http-user-agent }} |
| 49 | + |
| 50 | + - uses: r-lib/actions/setup-pandoc@v1 |
| 51 | + |
| 52 | + - name: Query dependencies |
| 53 | + run: | |
| 54 | + install.packages('remotes') |
| 55 | + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
| 56 | + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 57 | + shell: Rscript {0} |
| 58 | + |
| 59 | + - name: Cache R packages |
| 60 | + if: runner.os != 'Windows' |
| 61 | + uses: actions/cache@v2 |
| 62 | + with: |
| 63 | + path: ${{ env.R_LIBS_USER }} |
| 64 | + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
| 65 | + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
| 66 | + |
| 67 | + - name: Install system dependencies |
| 68 | + if: runner.os == 'Linux' |
| 69 | + run: | |
| 70 | + while read -r cmd |
| 71 | + do |
| 72 | + eval sudo $cmd |
| 73 | + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))') |
| 74 | +
|
| 75 | + - name: Install dependencies |
| 76 | + run: | |
| 77 | + remotes::install_deps(dependencies = TRUE) |
| 78 | + remotes::install_cran("rcmdcheck") |
| 79 | + shell: Rscript {0} |
| 80 | + |
| 81 | + - name: Session info |
| 82 | + run: | |
| 83 | + options(width = 100) |
| 84 | + pkgs <- installed.packages()[, "Package"] |
| 85 | + sessioninfo::session_info(pkgs, include_base = TRUE) |
| 86 | + shell: Rscript {0} |
| 87 | + |
| 88 | + - name: Check |
| 89 | + env: |
| 90 | + _R_CHECK_CRAN_INCOMING_: false |
| 91 | + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") |
| 92 | + shell: Rscript {0} |
| 93 | + |
| 94 | + - name: Show testthat output |
| 95 | + if: always() |
| 96 | + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 97 | + shell: bash |
| 98 | + |
| 99 | + - name: Upload check results |
| 100 | + if: failure() |
| 101 | + uses: actions/upload-artifact@main |
| 102 | + with: |
| 103 | + name: ${{ runner.os }}-r${{ matrix.config.r }}-results |
| 104 | + path: check |
0 commit comments