|
| 1 | +# Triggered on push and pull request events |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | +# Name of the workflow => usethis::use_github_actions_badge("CI-CD") |
| 8 | +name: CI-CD |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: macos-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + r-version: ['devel'] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + - name: Set up R ${{ matrix.r-version }} |
| 20 | + uses: r-lib/actions/setup-r@v1 |
| 21 | + with: |
| 22 | + r-version: ${{ matrix.r-version }} |
| 23 | + |
| 24 | + - name: "Install curl" |
| 25 | + if: runner.os == 'Linux' |
| 26 | + run: | |
| 27 | + sudo apt install libcurl4-openssl-dev |
| 28 | + sudo apt-get install pandoc |
| 29 | + - name: Query dependencies |
| 30 | + run: | |
| 31 | + install.packages('remotes') |
| 32 | + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
| 33 | + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 34 | + shell: Rscript {0} |
| 35 | + |
| 36 | + - name: Cache R packages |
| 37 | + uses: actions/cache@v2 |
| 38 | + with: |
| 39 | + path: ${{ env.R_LIBS_USER }} |
| 40 | + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
| 41 | + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
| 42 | + |
| 43 | + - name: Install dependencies |
| 44 | + run: | |
| 45 | + remotes::install_deps(dependencies = TRUE) |
| 46 | + remotes::install_cran("rcmdcheck") |
| 47 | + shell: Rscript {0} |
| 48 | + |
| 49 | + - name: Check package |
| 50 | + shell: Rscript {0} |
| 51 | + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check") |
| 52 | + |
| 53 | + - name: Unit test workflow |
| 54 | + run: | |
| 55 | + install.packages('devtools') |
| 56 | + devtools::test() |
| 57 | + shell: Rscript {0} |
0 commit comments