From 755e7215b42623ae0a90e4a557708b617a06a342 Mon Sep 17 00:00:00 2001 From: Roy Francis Date: Sun, 27 Dec 2020 23:09:40 +0100 Subject: [PATCH] Updated actions --- .github/workflows/main.yml | 93 +++++++++----------------------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 50e2d8b..399d4a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,24 @@ + +## GITHUB ACTION FOR R PACKAGE +## Build, check, test, code coverage +## Required secrets +## CODECOV_TOKEN +## TOKEN + name: build on: + pull_request: push: branches: - master jobs: linux: name: ubuntu - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - r: [3.5] + r: [3.5.3,3.6.3,4.0.0] steps: - uses: actions/checkout@v1 - uses: r-lib/actions/setup-r@master @@ -21,20 +29,20 @@ jobs: - name: Install linux dependencies run: | sudo apt-get update - sudo apt-get install -y libfreetype6-dev libcurl4-openssl-dev libssl-dev libxml2-dev + sudo apt-get install -y libfreetype6-dev libcurl4-openssl-dev libssl-dev libxml2-dev libnlopt-dev - name: Check R installation run: Rscript -e "print('R installation works!')" - name: Cache R packages - id: cache-rp - uses: actions/cache@v1 + id: cache-r-packages + uses: actions/cache@v2 with: path: "/home/runner/work/_temp/Library" - key: ${{ runner.os }}-cache-rp-$(ls /home/runner/work/_temp/Library/ | sha256sum) + key: ${{runner.os}}-${{matrix.r}}-$(ls /home/runner/work/_temp/Library/ | sha256sum) - name: Install R dependencies - if: steps.cache-rp.outputs.cache-hit != 'true' + if: steps.cache-r-packages.outputs.cache-hit != 'true' run: | Rscript -e "install.packages(c('remotes','covr','rcmdcheck'))" Rscript -e "remotes::install_deps(pkgdir='.',dependencies=TRUE,repos='https://cran.rstudio.com/')" @@ -44,6 +52,7 @@ jobs: R CMD INSTALL . - name: Code coverage + if: matrix.r == '4.0.0' run: Rscript -e 'covr::codecov(token="${{ secrets.CODECOV_TOKEN }}",quiet=FALSE)' windows: @@ -51,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - r: [3.5,3.6] + r: [3.5.3,3.6.3,4.0.0] steps: - uses: actions/checkout@v1 - uses: r-lib/actions/setup-r@master @@ -59,14 +68,14 @@ jobs: r-version: ${{matrix.r}} - name: Cache R packages - id: cache-rp - uses: actions/cache@v1 + id: cache-r-packages + uses: actions/cache@v2 with: path: "C:/R/library" - key: ${{ runner.os }}-cache-rp + key: ${{runner.os}}-${{matrix.r}} - name: Install R dependencies - if: steps.cache-rp.outputs.cache-hit != 'true' + if: steps.cache-r-packages.outputs.cache-hit != 'true' run: | Rscript -e "install.packages(c('remotes','rcmdcheck','stringi'),lib='C:/R/library')" Rscript -e "remotes::install_deps(pkgdir='.',dependencies=TRUE,repos='https://cran.rstudio.com/',lib='C:/R/library')" @@ -74,63 +83,3 @@ jobs: - name: RMD check and install package run: | Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')" - R CMD INSTALL . - pkgdown: - needs: [mac, linux, windows] - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v1 - - uses: r-lib/actions/setup-r@master - with: - r-version: 3.6.2 - - uses: r-lib/actions/setup-pandoc@master - - - name: Install linux dependencies - run: | - sudo apt-get update - sudo apt-get install -y libfreetype6-dev libcurl4-openssl-dev libssl-dev libxml2-dev - - - name: Check R installation - run: Rscript -e "print('R installation works!')" - - - name: Cache R packages - id: cache-rp - uses: actions/cache@v1 - with: - path: "/home/runner/work/_temp/Library" - key: ${{ runner.os }}-cache-rp-$(ls /home/runner/work/_temp/Library/ | sha256sum) - - - name: Install R dependencies - if: steps.cache-rp.outputs.cache-hit != 'true' - run: | - Rscript -e "install.packages(c('remotes','rcmdcheck','pkgdown'))" - Rscript -e "remotes::install_deps(pkgdir='.',dependencies=TRUE,repos='https://cran.rstudio.com/')" - - - name: RMD check and install package - run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')" - R CMD INSTALL . - - - name: Render site, pull repo, copy folder, push repo - run: | - # Add git info - git config --global user.email "do_not_email@example.com" - git config --global user.name "gh_action" - - # Render website - Rscript -e "pkgdown::build_site()" - - # Clone gh-pages branch - git clone --single-branch --branch gh-pages "https://${{ secrets.TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" tmprepo - cd tmprepo - rm -rf * - git add . - git commit -m "Old contents deleted." - cp -r ../docs/* . - echo "Folder contents at $(pwd):" - ls -lh - - # Push changes back - git add . - git commit -m "Updated contents at $(date +%Y%m%d-%H%M%S)" - git push origin