From 5ceee8c83b4c22c635c6ef5e3a2a77e636edb315 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 22 Aug 2022 09:14:29 -0400 Subject: [PATCH 01/11] Bump Ubuntu version from 18.04 to 20.04 --- .github/workflows/R-CMD-check.yaml | 16 ++++++++-------- .github/workflows/format.yaml | 2 +- .github/workflows/test-coverage.yaml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0ef4cc24..081c6ae9 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,14 +29,14 @@ jobs: - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} - {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} - - {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" } - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'no-cpp11test'} - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'gcc 4.8'} - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'no-cpp11test'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'gcc 4.8'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-20.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-20.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-20.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-20.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} env: RSPM: ${{ matrix.config.rspm }} diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index db1af2b4..80ad7bda 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -9,7 +9,7 @@ name: format_check jobs: format_check: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 25288970..5add6440 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -12,7 +12,7 @@ name: test-coverage jobs: test-coverage: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 env: RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -35,8 +35,8 @@ jobs: path: | ${{ env.R_LIBS_USER }}/* !${{ env.R_LIBS_USER }}/pak - key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1- + key: ubuntu-20.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} + restore-keys: ubuntu-20.04-${{ steps.install-r.outputs.installed-r-version }}-1- - name: Install system dependencies if: runner.os == 'Linux' From a4fb06c801b23f5418628859e2d2038a6ebe4c6d Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 22 Aug 2022 15:00:52 -0400 Subject: [PATCH 02/11] Fully update GitHub Actions workflows --- .github/workflows/R-CMD-check.yaml | 120 ++++++++------------------- .github/workflows/pkgdown.yaml | 35 +++++--- .github/workflows/pr-commands.yaml | 62 +++++++++----- .github/workflows/test-coverage.yaml | 53 ++++-------- README.md | 2 +- 5 files changed, 118 insertions(+), 154 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 081c6ae9..da5a5e32 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,18 +1,14 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help # -# 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 +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: R-CMD-check @@ -27,53 +23,35 @@ jobs: matrix: config: - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'no-cpp11test'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", custom: 'gcc 4.8'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-20.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-20.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-20.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-20.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + # Use 3.6 to trigger usage of RTools35 + - {os: windows-latest, r: '3.6'} + + # Use older ubuntu to maximise backward compatibility + - {os: ubuntu-20.04, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-20.04, r: 'release'} + - {os: ubuntu-20.04, r: 'release', custom: 'no-cpp11test'} + - {os: ubuntu-20.04, r: 'release', custom: 'gcc 4.8'} + - {os: ubuntu-20.04, r: 'oldrel-1'} + - {os: ubuntu-20.04, r: 'oldrel-2'} + - {os: ubuntu-20.04, r: 'oldrel-3'} + - {os: ubuntu-20.04, r: 'oldrel-4'} env: - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@v1 - id: install-r + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} - - - name: Restore R package cache - uses: actions/cache@v2 - with: - path: | - ${{ env.R_LIBS_USER }}/* - !${{ env.R_LIBS_USER }}/pak - key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("rcmdcheck", execute = TRUE) - shell: Rscript {0} + use-public-rspm: true - name : Install compiler version if: matrix.config.custom == 'gcc 4.8' @@ -82,37 +60,26 @@ jobs: mkdir ~/.R/ echo $'CXX1X=g++-4.8\nCXX11=g++-4.8' >> ~/.R/Makevars - - name: install macOS system dependecies + - name: Install macOS system dependencies if: runner.os == 'macOS' run: brew install --cask xquartz - - name: Install dependencies - run: | - pak::local_install_dev_deps(upgrade = TRUE) - pak::pkg_install("rcmdcheck") - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check - - name: Install cpp11 and cpp11test + - name: Install cpp11test if: matrix.config.custom != 'no-cpp11test' run: | options(warn = 2) - install.packages(".", repos = NULL, type = "source") - pak::local_install_dev_deps("cpp11test") + pak::local_install_dev_deps("cpp11test", dependencies = TRUE) install.packages("cpp11test", repos = NULL, INSTALL_opts = "--install-tests", type = "source") shell: Rscript {0} - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true - name: Run cpp11test tests if: matrix.config.custom != 'no-cpp11test' @@ -122,20 +89,3 @@ jobs: library(cpp11test) test_check("cpp11test", reporter = "progress") shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results - path: check - - - name: Don't use tar from old Rtools to store the cache - if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} - shell: bash - run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index a8b96558..89114c25 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,35 +1,48 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: branches: [main, master] - tags: ['*'] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown jobs: pkgdown: runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: local::. local::cpp11test pkgdown + extra-packages: any::pkgdown, local::., local::cpp11test needs: website - - name: Deploy package + - name: Build site env: CPP11_EVAL: true - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index e5edf9f7..97271eb2 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -1,55 +1,79 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: issue_comment: types: [created] + name: Commands + jobs: document: - if: startsWith(github.event.comment.body, '/document') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@v1 + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 - - name: Install dependencies - run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + - name: Document - run: Rscript -e 'roxygen2::roxygenise()' + run: roxygen2::roxygenise() + shell: Rscript {0} + - name: commit run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add man/\* NAMESPACE git commit -m 'Document' - - uses: r-lib/actions/pr-push@v1 + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + style: - if: startsWith(github.event.comment.body, '/style') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@v1 + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-r@v2 + - name: Install dependencies - run: Rscript -e 'install.packages("styler")' + run: install.packages("styler") + shell: Rscript {0} + - name: Style - run: Rscript -e 'styler::style_pkg()' + run: styler::style_pkg() + shell: Rscript {0} + - name: commit run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add \*.R git commit -m 'Style' - - uses: r-lib/actions/pr-push@v1 + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 5add6440..880e59ce 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,61 +1,38 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: test-coverage jobs: test-coverage: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: - RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@v1 - id: install-r - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} - - - name: Restore R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: | - ${{ env.R_LIBS_USER }}/* - !${{ env.R_LIBS_USER }}/pak - key: ubuntu-20.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ubuntu-20.04-${{ steps.install-r.outputs.installed-r-version }}-1- + use-public-rspm: true - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("covr", execute = TRUE) - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage - - name: Install dependencies + - name: Install cpp11test run: | - pak::local_install(dependencies = FALSE) + options(warn = 2) pak::local_install_dev_deps("cpp11test", dependencies = TRUE) - install.packages("cpp11test", repos = NULL, INSTALL_opts = "--install-tests") - pak::local_install(dependencies = TRUE) - pak::pkg_install("covr") + install.packages("cpp11test", repos = NULL, INSTALL_opts = "--install-tests", type = "source") shell: Rscript {0} - name: Test coverage - run: | - source("R/coverage.R") - covr::codecov(coverage = cpp11_coverage()) + run: covr::codecov(quiet = FALSE) shell: Rscript {0} diff --git a/README.md b/README.md index 3f090a4e..e9fa0c5b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # cpp11 -[![R-CMD-check](https://github.com/r-lib/cpp11/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/cpp11/actions) +[![R-CMD-check](https://github.com/r-lib/cpp11/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/cpp11/actions/workflows/R-CMD-check.yaml) [![codecov](https://app.codecov.io/gh/r-lib/cpp11/branch/main/graph/badge.svg?token=EEWYoCYxQ2)](https://app.codecov.io/gh/r-lib/cpp11) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![CRAN status](https://www.r-pkg.org/badges/version/cpp11)](https://CRAN.R-project.org/package=cpp11) From 29cc8339811fe1eb91f2d7a4886111d9f881dd33 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 22 Aug 2022 15:51:28 -0400 Subject: [PATCH 03/11] Avoid `R_compact_intrange()` in favor of `:` Closes #280 --- cpp11test/src/test-doubles.cpp | 20 +++++++++++++++++--- cpp11test/src/test-integers.cpp | 6 +++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cpp11test/src/test-doubles.cpp b/cpp11test/src/test-doubles.cpp index bea555d0..703cd8a4 100644 --- a/cpp11test/src/test-doubles.cpp +++ b/cpp11test/src/test-doubles.cpp @@ -1,5 +1,6 @@ #include #include "cpp11/doubles.hpp" +#include "cpp11/function.hpp" #include "cpp11/integers.hpp" #include "cpp11/sexp.hpp" #include "cpp11/strings.hpp" @@ -184,7 +185,12 @@ context("doubles-C++") { #if defined(__APPLE__) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) test_that("writable::doubles(ALTREP_SEXP)") { - SEXP x = PROTECT(Rf_coerceVector(R_compact_intrange(1, 5), REALSXP)); + // ALTREP compact-seq + auto seq = cpp11::package("base")[":"]; + cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); + + SEXP x = PROTECT(Rf_coerceVector(range, REALSXP)); + expect_true(ALTREP(x)); // Need to find (or create) an altrep class that implements duplicate. cpp11::writable::doubles y(x); @@ -218,7 +224,11 @@ context("doubles-C++") { expect_true(y.data() != x.data()); expect_true(y.is_altrep() == x.is_altrep()); - cpp11::writable::doubles z(Rf_coerceVector(R_compact_intrange(1, 5), REALSXP)); + // ALTREP compact-seq + auto seq = cpp11::package("base")[":"]; + cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); + + cpp11::writable::doubles z(Rf_coerceVector(range, REALSXP)); cpp11::writable::doubles w({0.}); w = z; expect_true(w.size() == 5); @@ -236,7 +246,11 @@ context("doubles-C++") { expect_true(y.data() == x_data); expect_true(y.is_altrep() == false); - cpp11::writable::doubles z(Rf_coerceVector(R_compact_intrange(1, 5), REALSXP)); + // ALTREP compact-seq + auto seq = cpp11::package("base")[":"]; + cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); + + cpp11::writable::doubles z(Rf_coerceVector(range, REALSXP)); cpp11::writable::doubles w({0.}); expect_true(z.is_altrep() == true); diff --git a/cpp11test/src/test-integers.cpp b/cpp11test/src/test-integers.cpp index 568e67eb..7a70ab4a 100644 --- a/cpp11test/src/test-integers.cpp +++ b/cpp11test/src/test-integers.cpp @@ -1,5 +1,6 @@ #include "Rversion.h" #include "cpp11/doubles.hpp" +#include "cpp11/function.hpp" #include "cpp11/integers.hpp" #include "cpp11/strings.hpp" @@ -164,7 +165,10 @@ context("integers-C++") { #if defined(__APPLE__) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) test_that("writable::integers(ALTREP_SEXP)") { - SEXP x = PROTECT(R_compact_intrange(1, 5)); + // ALTREP compact-seq + auto seq = cpp11::package("base")[":"]; + SEXP x = PROTECT(seq(cpp11::as_sexp(1), cpp11::as_sexp(5))); + expect_true(ALTREP(x)); // Need to find (or create) an altrep class that implements duplicate. cpp11::writable::integers y(x); From 0fbdcb1ddb35146385689a89ade4bc061ede5f75 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 22 Aug 2022 21:03:41 -0400 Subject: [PATCH 04/11] Avoid unused variable warning on Windows about `cpp11::preserved` --- cpp11test/src/test-protect.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cpp11test/src/test-protect.cpp b/cpp11test/src/test-protect.cpp index a0fd18ac..2bd2dadf 100644 --- a/cpp11test/src/test-protect.cpp +++ b/cpp11test/src/test-protect.cpp @@ -1,3 +1,16 @@ +// Avoid unused variable warnings regarding `cpp11::preserved` +// clang-format off +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-variable" +#endif + +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif +// clang-format on + #define CPP11_USE_FMT #include "cpp11/protect.hpp" #include "testthat.h" From d15902a74c4e54e947926f6d6e2af6a97ea910eb Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Tue, 23 Aug 2022 16:56:02 -0400 Subject: [PATCH 05/11] Add a remote on r-lib/testthat#1673 --- DESCRIPTION | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 11118f83..8f3bbc54 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,3 +60,5 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 SystemRequirements: C++11 +Remotes: + r-lib/testthat#1673 From 6a2994ad966ae1372b815a4be19af7f80e9ce692 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Tue, 23 Aug 2022 18:23:48 -0400 Subject: [PATCH 06/11] Add old archives to be able to install gcc 4.8 --- .github/workflows/R-CMD-check.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index da5a5e32..84e72d34 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -54,8 +54,19 @@ jobs: use-public-rspm: true - name : Install compiler version + # We check on this old compiler specifically to support CentOS 7, + # which uses this gcc version. RStudio products support CentOS 7 through + # June 2024. + # https://github.com/r-lib/cpp11/pull/78 + # https://www.rstudio.com/about/platform-support/ + # Ubuntu 20.04 technically dropped support for gcc 4.8, so we have to + # add old archives back in manually to install it + # https://github.com/r-lib/cpp11/pull/279 if: matrix.config.custom == 'gcc 4.8' run: | + echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list + echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" | sudo tee -a /etc/apt/sources.list + sudo apt update sudo apt-get install -y g++-4.8 mkdir ~/.R/ echo $'CXX1X=g++-4.8\nCXX11=g++-4.8' >> ~/.R/Makevars From 7a479d84317fed184e8ee24c74cfbeaa4c5b356c Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Tue, 23 Aug 2022 20:20:22 -0400 Subject: [PATCH 07/11] Depend only on dev testthat now that the PR has been merged --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8f3bbc54..aa9732d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -61,4 +61,4 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 SystemRequirements: C++11 Remotes: - r-lib/testthat#1673 + r-lib/testthat From f59c83342f4fc9898990e01c332011f16bf3b392 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Tue, 23 Aug 2022 22:07:17 -0400 Subject: [PATCH 08/11] Set `CC` as well for `pkgbuild:::has_compiler_colored_diagnostics()` Otherwise this will incorrectly return `TRUE` because it compiles a C program rather than a C++ one to check if color support is available, which adds the `-fdiagnostics-color=always` flag, but g++ 4.8 doesn't actually support that, so the compilation of the C++ code in the vignettes would fail --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 84e72d34..8505e245 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -69,7 +69,7 @@ jobs: sudo apt update sudo apt-get install -y g++-4.8 mkdir ~/.R/ - echo $'CXX1X=g++-4.8\nCXX11=g++-4.8' >> ~/.R/Makevars + echo $'CXX1X=g++-4.8\nCXX11=g++-4.8\nCC=gcc-4.8' >> ~/.R/Makevars - name: Install macOS system dependencies if: runner.os == 'macOS' From be8e39c2984679f15ab04ece37c1eff83bd7b96b Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Wed, 24 Aug 2022 11:04:59 -0400 Subject: [PATCH 09/11] NEWS bullet --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index e4c4281e..2ad5492d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # cpp11 (development version) +* Modernized the GitHub Actions workflows and updated some internal tests to + better align with changes in those workflows and the latest version of R + (#279). + * `cpp_source()` errors on non-existent file (#261). # cpp11 0.4.2 From 3572e7c296bb190a5362f9f4b23b77b814253d37 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Thu, 25 Aug 2022 09:19:37 -0400 Subject: [PATCH 10/11] Pin to a specific testthat SHA --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa9732d9..15fdb8d6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -61,4 +61,4 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 SystemRequirements: C++11 Remotes: - r-lib/testthat + r-lib/testthat@ad8b726d1734c59ed08ec7d11df4a3d76d8e69df From 5ad4dbaa7aa36df17f1e7c6f5e4ff2e7328f84b3 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Thu, 25 Aug 2022 09:22:09 -0400 Subject: [PATCH 11/11] Use `seq()` rather than `:` to generate the ALTREP compact-seq vector --- cpp11test/src/test-doubles.cpp | 6 +++--- cpp11test/src/test-integers.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp11test/src/test-doubles.cpp b/cpp11test/src/test-doubles.cpp index 703cd8a4..58023cd0 100644 --- a/cpp11test/src/test-doubles.cpp +++ b/cpp11test/src/test-doubles.cpp @@ -186,7 +186,7 @@ context("doubles-C++") { #if defined(__APPLE__) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) test_that("writable::doubles(ALTREP_SEXP)") { // ALTREP compact-seq - auto seq = cpp11::package("base")[":"]; + auto seq = cpp11::package("base")["seq"]; cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); SEXP x = PROTECT(Rf_coerceVector(range, REALSXP)); @@ -225,7 +225,7 @@ context("doubles-C++") { expect_true(y.is_altrep() == x.is_altrep()); // ALTREP compact-seq - auto seq = cpp11::package("base")[":"]; + auto seq = cpp11::package("base")["seq"]; cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); cpp11::writable::doubles z(Rf_coerceVector(range, REALSXP)); @@ -247,7 +247,7 @@ context("doubles-C++") { expect_true(y.is_altrep() == false); // ALTREP compact-seq - auto seq = cpp11::package("base")[":"]; + auto seq = cpp11::package("base")["seq"]; cpp11::sexp range = seq(cpp11::as_sexp(1), cpp11::as_sexp(5)); cpp11::writable::doubles z(Rf_coerceVector(range, REALSXP)); diff --git a/cpp11test/src/test-integers.cpp b/cpp11test/src/test-integers.cpp index 7a70ab4a..83d2cccf 100644 --- a/cpp11test/src/test-integers.cpp +++ b/cpp11test/src/test-integers.cpp @@ -166,7 +166,7 @@ context("integers-C++") { #if defined(__APPLE__) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) test_that("writable::integers(ALTREP_SEXP)") { // ALTREP compact-seq - auto seq = cpp11::package("base")[":"]; + auto seq = cpp11::package("base")["seq"]; SEXP x = PROTECT(seq(cpp11::as_sexp(1), cpp11::as_sexp(5))); expect_true(ALTREP(x)); // Need to find (or create) an altrep class that implements duplicate.