From 7b35a5152508a44101a580e25344343952739356 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" Date: Wed, 9 Dec 2020 10:09:19 +0000 Subject: [PATCH] Use GitHub actions for CI (#56) --- .github/workflows/R-CMD-check.yml | 87 +++++++++++++++++++++++++++ .github/workflows/pkgdown.yml | 48 +++++++++++++++ NEWS.md | 1 + codemeta.json | 6 +- tests/testthat/test-QuartetDistance.R | 7 +-- 5 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/R-CMD-check.yml create mode 100644 .github/workflows/pkgdown.yml diff --git a/.github/workflows/R-CMD-check.yml b/.github/workflows/R-CMD-check.yml new file mode 100644 index 00000000..abed2633 --- /dev/null +++ b/.github/workflows/R-CMD-check.yml @@ -0,0 +1,87 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: '3.4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: 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") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + 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- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + remotes::install_cran("tinytex") + tinytex::install_tinytex() + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yml new file mode 100644 index 00000000..96b8f893 --- /dev/null +++ b/.github/workflows/pkgdown.yml @@ -0,0 +1,48 @@ +on: + push: + branches: + - main + - master + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: 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") + 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- + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown", type = "binary") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' \ No newline at end of file diff --git a/NEWS.md b/NEWS.md index ae8f0acb..cb8d0ff7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,5 @@ # Quartet v1.2.1 + - Package 'vdiffr' now used conditionally. # Quartet v1.2.0 diff --git a/codemeta.json b/codemeta.json index e514cf84..4053a59a 100644 --- a/codemeta.json +++ b/codemeta.json @@ -10,13 +10,13 @@ "codeRepository": "https://github.com/ms609/Quartet/", "issueTracker": "https://github.com/ms609/Quartet/issues/", "license": "https://spdx.org/licenses/GPL-2.0", - "version": "1.2.0", + "version": "1.2.1", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.0.2 (2020-06-22)", + "runtimePlatform": "R version 4.0.3 (2020-10-10)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -339,5 +339,5 @@ "https://ms609.github.io/Quartet", "https://ms609.github.io/Quartet/" ], - "fileSize": "1343.465KB" + "fileSize": "1344.28KB" } diff --git a/tests/testthat/test-QuartetDistance.R b/tests/testthat/test-QuartetDistance.R index 7070faf4..b66ffc78 100644 --- a/tests/testthat/test-QuartetDistance.R +++ b/tests/testthat/test-QuartetDistance.R @@ -28,17 +28,16 @@ test_that("Splits are compared", { test_that("PlotQuartet() works", { skip_if_not_installed('vdiffr') - library('vdiffr') - expect_doppelganger('PlotQuartet', function() { + vdiffr::expect_doppelganger('PlotQuartet', function() { data('sq_trees') par(mfrow = c(3, 2), mar = rep(0.5, 4), cex = 1.1) PlotQuartet(sq_trees[c(1, 9, 13:16)], c(2, 5, 3, 8), overwritePar = FALSE) }) - expect_doppelganger('PlotQuartet-one-star', function() { + vdiffr::expect_doppelganger('PlotQuartet-one-star', function() { PlotQuartet(StarTree(4), 1:4, caption = FALSE) }) - expect_doppelganger('PlotQuartet-gain', function() { + vdiffr::expect_doppelganger('PlotQuartet-gain', function() { par(mfrow = c(3, 2), mar = rep(0.5, 4), cex = 1.1) PlotQuartet(c(StarTree(4), BalancedTree(4)), 1:4, overwritePar = TRUE) })