| 
 | 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 | +      - master  | 
 | 12 | +  pull_request:  | 
 | 13 | +    branches:  | 
 | 14 | +      - main  | 
 | 15 | +      - master  | 
 | 16 | + | 
 | 17 | +name: R-CMD-check  | 
 | 18 | + | 
 | 19 | +jobs:  | 
 | 20 | +  R-CMD-check:  | 
 | 21 | +    runs-on: ${{ matrix.config.os }}  | 
 | 22 | + | 
 | 23 | +    name: ${{ matrix.config.os }} (${{ matrix.config.r }})  | 
 | 24 | + | 
 | 25 | +    strategy:  | 
 | 26 | +      fail-fast: false  | 
 | 27 | +      matrix:  | 
 | 28 | +        config:  | 
 | 29 | +          - {os: macOS-latest,   r: 'release', visual_tests: true, node: "14.x", shinytest: true}  | 
 | 30 | +          - {os: windows-latest, r: 'release'}  | 
 | 31 | +          - {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"}  | 
 | 32 | +          - {os: ubuntu-18.04,   r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-18.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }  | 
 | 33 | +          # vdiffr & shinytest only runs on linux r-release since the results aren't cross-platform  | 
 | 34 | +          - {os: ubuntu-18.04,   r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}  | 
 | 35 | +          - {os: ubuntu-18.04,   r: 'oldrel',  rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}  | 
 | 36 | +          - {os: ubuntu-18.04,   r: '3.6',     rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}  | 
 | 37 | +          - {os: ubuntu-18.04,   r: '3.5',     rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}  | 
 | 38 | +          - {os: ubuntu-18.04,   r: '3.4',     rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}  | 
 | 39 | + | 
 | 40 | +    env:  | 
 | 41 | +      RSPM: ${{ matrix.config.rspm }}  | 
 | 42 | +      VISUAL_TESTS: ${{ matrix.config.visual_tests }}  | 
 | 43 | +      SHINYTEST: ${{ matrix.config.shinytest }}  | 
 | 44 | +      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}  | 
 | 45 | +      MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}  | 
 | 46 | +      plotly_username: ${{ secrets.PLOTLY_USERNAME }}  | 
 | 47 | +      plotly_api_key: ${{ secrets.PLOTLY_API_KEY }}  | 
 | 48 | + | 
 | 49 | +    steps:  | 
 | 50 | +      - uses: actions/checkout@v2  | 
 | 51 | + | 
 | 52 | +      - uses: r-lib/actions/setup-r@v1  | 
 | 53 | +        id: install-r  | 
 | 54 | +        with:  | 
 | 55 | +          r-version: ${{ matrix.config.r }}  | 
 | 56 | +          http-user-agent: ${{ matrix.config.http-user-agent }}  | 
 | 57 | + | 
 | 58 | +      - uses: r-lib/actions/setup-pandoc@v1  | 
 | 59 | + | 
 | 60 | +      - name: Install pak and query dependencies  | 
 | 61 | +        run: |  | 
 | 62 | +          install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")  | 
 | 63 | +          saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")  | 
 | 64 | +        shell: Rscript {0}  | 
 | 65 | + | 
 | 66 | +      - name: Restore R package cache  | 
 | 67 | +        uses: actions/cache@v2  | 
 | 68 | +        with:  | 
 | 69 | +          path: |  | 
 | 70 | +            ${{ env.R_LIBS_USER }}/*  | 
 | 71 | +            !${{ env.R_LIBS_USER }}/pak  | 
 | 72 | +          key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}  | 
 | 73 | +          restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-  | 
 | 74 | + | 
 | 75 | +      - name: Install system dependencies  | 
 | 76 | +        if: runner.os == 'Linux'  | 
 | 77 | +        run: |  | 
 | 78 | +          pak::local_system_requirements(execute = TRUE)  | 
 | 79 | +          pak::pkg_system_requirements("rcmdcheck", execute = TRUE)  | 
 | 80 | +        shell: Rscript {0}  | 
 | 81 | +        | 
 | 82 | +      - uses: actions/setup-node@v1  | 
 | 83 | +        with:  | 
 | 84 | +          node-version: ${{ matrix.config.node }}  | 
 | 85 | +        | 
 | 86 | +      - name: Install orca  | 
 | 87 | +        if: matrix.config.visual_tests == true  | 
 | 88 | +        run: npm install -g electron@6.1.4 orca  | 
 | 89 | +        shell: bash  | 
 | 90 | +            | 
 | 91 | +      - name: Install phantomjs  | 
 | 92 | +        if: matrix.config.shinytest == true  | 
 | 93 | +        run: |  | 
 | 94 | +          pak::pak("shinytest")  | 
 | 95 | +          shinytest::installDependencies()  | 
 | 96 | +          pak::pak()  | 
 | 97 | +        shell: Rscript {0}  | 
 | 98 | + | 
 | 99 | +      - name: Install dependencies  | 
 | 100 | +        run: |  | 
 | 101 | +          pak::local_install_dev_deps(upgrade = TRUE)  | 
 | 102 | +          pak::pkg_install("rcmdcheck")  | 
 | 103 | +        shell: Rscript {0}  | 
 | 104 | + | 
 | 105 | +      - name: Session info  | 
 | 106 | +        run: |  | 
 | 107 | +          options(width = 100)  | 
 | 108 | +          pkgs <- installed.packages()[, "Package"]  | 
 | 109 | +          sessioninfo::session_info(pkgs, include_base = TRUE)  | 
 | 110 | +        shell: Rscript {0}  | 
 | 111 | +          | 
 | 112 | +        # Run test() before R CMD check since, for some reason, rcmdcheck::rcmdcheck() skips vdiffr tests  | 
 | 113 | +      - name: Run Tests  | 
 | 114 | +        run: |  | 
 | 115 | +          options(crayon.enabled = TRUE)  | 
 | 116 | +          if (!require(devtools)) pak::pak("devtools")  | 
 | 117 | +          if (!require(reshape2)) pak::pak("reshape2")  | 
 | 118 | +          res <- devtools::test()  | 
 | 119 | +          df <- as.data.frame(res)  | 
 | 120 | +          if (sum(df$failed) > 0 || any(df$error)) stop("GHA CI tests failed")  | 
 | 121 | +        shell: Rscript {0}  | 
 | 122 | +          | 
 | 123 | +      # Upload the whole pkg since tests where run with devtools::test()  | 
 | 124 | +      - name: Upload check results  | 
 | 125 | +        if: always()  | 
 | 126 | +        uses: actions/upload-artifact@master  | 
 | 127 | +        with:  | 
 | 128 | +          name: ${{ runner.os }}-r${{ matrix.config.r }}-results  | 
 | 129 | +          path: ./  | 
 | 130 | + | 
 | 131 | +      # Run check with --no-tests since we ran them abve  | 
 | 132 | +      - name: Check  | 
 | 133 | +        run: |  | 
 | 134 | +          options(crayon.enabled = TRUE)  | 
 | 135 | +          rcmdcheck::rcmdcheck(args = c("--no-tests", "--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")  | 
 | 136 | +        shell: Rscript {0}  | 
 | 137 | + | 
 | 138 | +      #- name: Show testthat output  | 
 | 139 | +      #  if: always()  | 
 | 140 | +      #  run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true  | 
 | 141 | +      #  shell: bash  | 
 | 142 | + | 
 | 143 | +      - name: Don't use tar from old Rtools to store the cache  | 
 | 144 | +        if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }}  | 
 | 145 | +        shell: bash  | 
 | 146 | +        run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH  | 
0 commit comments