Skip to content

Commit

Permalink
Merge pull request #1 from krlmlr/f-gha-dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Jun 26, 2024
2 parents ccabf55 + bd2d399 commit 9fdda9d
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 368 deletions.
116 changes: 45 additions & 71 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,91 +117,65 @@ jobs:
- uses: ./.github/workflows/pkgdown-deploy
if: github.event_name == 'push'

# Windows checks can be run in parallel and independently
# when they alone take as long as the smoke and full tests combined.
# To achieve this, remove the "needs:" element below.
rcc-windows:
# Begin custom: early run
needs: rcc-smoke
# End custom: early run

runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }}) ${{ matrix.config.desc }}

# Begin custom: services
# End custom: services
versions-matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
name: Collect versions

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.rcc-smoke.outputs.sha }}

- uses: ./.github/workflows/custom/before-install
if: hashFiles('.github/workflows/custom/before-install/action.yml') != ''
fetch-depth: 0

- uses: ./.github/workflows/install
- uses: ./.github/workflows/rate-limit
with:
r-version: ${{ matrix.config.r }}
cache-version: rcc-windows-1
token: ${{ secrets.GITHUB_TOKEN }}
needs: check

- uses: ./.github/workflows/custom/after-install
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''

- uses: ./.github/workflows/update-snapshots
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

- uses: ./.github/workflows/check
- uses: r-lib/actions/setup-r@v2
with:
results: ${{ runner.os }}-r${{ matrix.config.r }}
install-r: false
use-public-rspm: true

rcc-full:
needs: rcc-smoke
- id: set-matrix
uses: ./.github/workflows/versions-matrix

runs-on: ${{ matrix.config.os }}
check-versions-matrix:
runs-on: ubuntu-22.04
needs: versions-matrix

name: ${{ matrix.config.os }} (${{ matrix.config.r }}) ${{ matrix.config.desc }}
name: Check versions deps

# Begin custom: services
# End custom: services
if: ${{ needs.versions-matrix.outputs.matrix != '' }}

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- {os: ubuntu-20.04, r: 'release'}
- name: Check matrix definition
run: |
matrix='${{ needs.versions-matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-22.04, r: 'release', covr: true, desc: 'with covr'}
- {os: ubuntu-22.04, r: 'oldrel-1'}
rcc-full:
needs:
- rcc-smoke
- versions-matrix

# Begin custom: R 3.6
- {os: ubuntu-22.04, r: 'oldrel-2'}
# End custom: R 3.6
runs-on: ${{ matrix.os }}

# Begin custom: R 3.5
- {os: ubuntu-22.04, r: 'oldrel-3'}
# End custom: R 3.5
name: ${{ matrix.os }} (${{ matrix.r }}) ${{ matrix.desc }}

# Begin custom: R 3.4
- {os: ubuntu-22.04, r: 'oldrel-4'}
# End custom: R 3.4
# Begin custom: services
# End custom: services

# Begin custom: matrix elements
# End custom: matrix elements
strategy:
fail-fast: false
matrix: ${{fromJson(needs.versions-matrix.outputs.matrix)}}

steps:
- uses: actions/checkout@v4
Expand All @@ -213,7 +187,7 @@ jobs:

- uses: ./.github/workflows/install
with:
r-version: ${{ matrix.config.r }}
r-version: ${{ matrix.r }}
cache-version: rcc-full-1
token: ${{ secrets.GITHUB_TOKEN }}
needs: check
Expand All @@ -226,7 +200,7 @@ jobs:

- uses: ./.github/workflows/check
with:
results: ${{ runner.os }}-r${{ matrix.config.r }}
results: ${{ runner.os }}-r${{ matrix.r }}

suggests-matrix:
runs-on: ubuntu-22.04
Expand All @@ -252,13 +226,13 @@ jobs:
- id: set-matrix
uses: ./.github/workflows/dep-matrix-suggests

check-matrix:
check-suggests-matrix:
runs-on: ubuntu-22.04
needs: suggests-matrix

name: Check deps
name: Check suggests deps

if: ${{ needs.matrix.outputs.matrix != '' }}
if: ${{ needs.suggests-matrix.outputs.matrix != '' }}

steps:
- name: Install json2yaml
Expand All @@ -267,15 +241,15 @@ jobs:
- name: Check matrix definition
run: |
matrix='${{ needs.matrix.outputs.matrix }}'
matrix='${{ needs.suggests-matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
rcc-suggests:
needs:
- suggests-matrix
- rcc-smoke
- suggests-matrix

runs-on: ubuntu-22.04

Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/versions-matrix/action.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# - {os: macos-latest, r: 'release'}
#
# - {os: ubuntu-20.04, r: 'release'}
#
# # Use older ubuntu to maximise backward compatibility
# - {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
# - {os: ubuntu-22.04, r: 'release', covr: true, desc: 'with covr'}
# - {os: ubuntu-22.04, r: 'oldrel-1'}
#
# # Begin custom: R 3.6
# - {os: ubuntu-22.04, r: 'oldrel-2'}
# # End custom: R 3.6
#
# # Begin custom: R 3.5
# - {os: ubuntu-22.04, r: 'oldrel-3'}
# # End custom: R 3.5
#
# # Begin custom: R 3.4
# - {os: ubuntu-22.04, r: 'oldrel-4'}
# # End custom: R 3.4

# FIXME: Dynamic lookup by parsing https://svn.r-project.org/R/tags/
r_versions <- c("devel", paste0("4.", 4:0))
macos <- data.frame(os = "macos-latest", r = r_versions[2:3])
windows <- data.frame(os = "windows-latest", r = r_versions[1:3])
linux_devel <- data.frame(os = "ubuntu-22.04", r = r_versions[1], `http-user-agent` = "release", check.names = FALSE)
linux <- data.frame(os = "ubuntu-22.04", r = r_versions[-1])
covr <- data.frame(os = "ubuntu-22.04", r = r_versions[2], covr = "true", desc = "with covr")

include_list <- list(macos, windows, linux_devel, linux, covr)
print(include_list)

filter <- read.dcf("DESCRIPTION")[1,]["Config/gha/filter"]
if (!is.na(filter)) {
filter_expr <- parse(text = filter)[[1]]
subset_fun_expr <- bquote(function(x) subset(x, .(filter_expr)))
subset_fun <- eval(subset_fun_expr)
include_list <- lapply(include_list, subset_fun)
print(include_list)
}

to_json <- function(x) {
if (nrow(x) == 0) return(character())
parallel <- vector("list", length(x))
for (i in seq_along(x)) {
parallel[[i]] <- paste0('"', names(x)[[i]], '":"', x[[i]], '"')
}
paste0("{", do.call(paste, c(parallel, sep = ",")), "}")
}

configs <- unlist(lapply(include_list, to_json))
json <- paste0('{"include":[', paste(configs, collapse = ","), ']}')

if (Sys.getenv("GITHUB_OUTPUT") != "") {
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
}
writeLines(json)
13 changes: 13 additions & 0 deletions .github/workflows/versions-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Actions to compute a matrix with all R and OS versions"
outputs:
matrix:
description: "Generated matrix"
value: ${{ steps.set-matrix.outputs.matrix }}

runs:
using: "composite"
steps:
- id: set-matrix
run: |
Rscript ./.github/workflows/versions-matrix/action.R
shell: bash
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Config/gha/filter: os != "windows-latest"
8 changes: 4 additions & 4 deletions src/value_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PointerWrapper {

static SEXP Wrap( void* ptr) {
// TODO cache this string?
auto ptr_sexp = R_MakeExternalPtr(ptr, Rf_ScalarString(mkChar(NAME.value)), R_NilValue);
auto ptr_sexp = R_MakeExternalPtr(ptr, Rf_ScalarString(Rf_mkChar(NAME.value)), R_NilValue);
R_RegisterCFinalizerEx(ptr_sexp, Finalize, Rboolean::FALSE);
return ptr_sexp;
}
Expand All @@ -51,7 +51,7 @@ namespace ValueConversion {

template <>
SEXP ToR(const char* val) {
return Rf_ScalarString(mkChar(val));
return Rf_ScalarString(Rf_mkChar(val));
}

template <>
Expand Down Expand Up @@ -100,12 +100,12 @@ namespace ValueConversion {

template <>
SEXP ToR(duckdb_state val) {
return ScalarInteger(val);
return Rf_ScalarInteger(val);
}

template <>
SEXP ToR(duckdb_type val) {
return ScalarInteger(val);
return Rf_ScalarInteger(val);
}


Expand Down
Loading

0 comments on commit 9fdda9d

Please sign in to comment.