Skip to content

Commit 22c13a9

Browse files
committed
Using RcppTskit + GitHub actions
1 parent 56e68ef commit 22c13a9

15 files changed

Lines changed: 265 additions & 97 deletions

.github/workflows/R-CMD-check.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches: [main, master]
5+
branches: [main, master, devel]
66
pull_request:
7-
branches: [main, master]
7+
branches: [main, master, devel]
88

99
name: R-CMD-check
1010

@@ -18,11 +18,11 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
config:
21-
- {os: macOS-latest, r: 'release'}
22-
- {os: windows-latest, r: 'release'}
23-
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
24-
- {os: ubuntu-latest, r: 'release'}
25-
- {os: ubuntu-latest, r: 'oldrel-1'}
21+
- { os: macOS-latest, r: "release" }
22+
- { os: windows-latest, r: "release" }
23+
- { os: ubuntu-latest, r: "devel", http-user-agent: "release" }
24+
- { os: ubuntu-latest, r: "release" }
25+
- { os: ubuntu-latest, r: "oldrel-1" }
2626

2727
env:
2828
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@v2
3333

3434
- uses: r-lib/actions/setup-pandoc@v2
35-
35+
3636
- uses: r-lib/actions/setup-tinytex@v2
3737

3838
- uses: r-lib/actions/setup-r@v2

.github/workflows/document.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
paths: ["R/**"]
6+
7+
name: document.yaml
8+
9+
permissions: read-all
10+
11+
jobs:
12+
document:
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup R
25+
uses: r-lib/actions/setup-r@v2
26+
with:
27+
use-public-rspm: true
28+
29+
- name: Install dependencies
30+
uses: r-lib/actions/setup-r-dependencies@v2
31+
with:
32+
extra-packages: any::roxygen2
33+
needs: roxygen2
34+
35+
- name: Document
36+
run: roxygen2::roxygenise()
37+
shell: Rscript {0}
38+
39+
- name: Commit and push changes
40+
run: |
41+
git config --local user.name "$GITHUB_ACTOR"
42+
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
43+
git add man/\* NAMESPACE DESCRIPTION
44+
git commit -m "Update documentation" || echo "No changes to commit"
45+
git pull --ff-only
46+
git push origin
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master, devel]
6+
pull_request:
7+
8+
name: test-coverage.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
test-coverage:
14+
runs-on: ${{ matrix.config.os }}
15+
16+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
config:
22+
- { os: ubuntu-latest, r: "release" }
23+
# - { os: macos-latest, r: "release" }
24+
25+
env:
26+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: r-lib/actions/setup-r@v2
32+
with:
33+
r-version: ${{ matrix.config.r }}
34+
http-user-agent: ${{ matrix.config.http-user-agent }}
35+
use-public-rspm: true
36+
37+
- uses: r-lib/actions/setup-r-dependencies@v2
38+
with:
39+
extra-packages: any::covr, any::xml2
40+
needs: coverage
41+
42+
- name: Test coverage
43+
run: |
44+
cov <- covr::package_coverage(
45+
quiet = FALSE,
46+
clean = FALSE,
47+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
48+
)
49+
print(cov)
50+
covr::to_cobertura(cov)
51+
shell: Rscript {0}
52+
53+
- uses: codecov/codecov-action@v5
54+
with:
55+
# Fail if error if not on PR, or if on PR and token is given
56+
# fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
57+
fail_ci_if_error: false
58+
config: codecov.yaml
59+
files: cobertura.xml
60+
plugins: noop
61+
disable_search: true
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
64+
- name: Show testthat output
65+
if: always()
66+
run: |
67+
## --------------------------------------------------------------------
68+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
69+
shell: bash
70+
71+
- name: Upload test results
72+
if: failure()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: coverage-test-failures
76+
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ URL: https://github.com/gaynorr/AlphaSimR,
4040
https://www.edx.org/learn/animal-breeding/the-university-of-edinburgh-breeding-programme-modelling-with-alphasimr
4141
Encoding: UTF-8
4242
Depends: R (>= 4.0.0)
43-
Imports: Rcpp (>= 0.12.7), Rdpack, methods, R6, tskitr
43+
Imports: Rcpp (>= 0.12.7), Rdpack, methods, R6, RcppTskit (>= 0.2.0)
4444
RdMacros: Rdpack
45-
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH, tskitr
45+
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH, RcppTskit (>= 0.2.0)
4646
RoxygenNote: 7.3.3
4747
Suggests: knitr, rmarkdown, testthat
4848
VignetteBuilder: knitr

NAMESPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export(solveRRBLUP_EM)
105105
export(solveRRBLUP_EM2)
106106
export(solveRRBLUP_EM3)
107107
export(solveUVM)
108-
export(ts_num_individuals2)
108+
export(tc_ptr_summary2)
109109
export(usefulness)
110110
export(varA)
111111
export(varAA)
@@ -135,6 +135,8 @@ exportClasses(TraitAEG)
135135
exportClasses(TraitAG)
136136
import(Rcpp)
137137
importFrom(R6,R6Class)
138+
importFrom(RcppTskit,TableCollection)
139+
importFrom(RcppTskit,TreeSequence)
138140
importFrom(Rdpack,reprompt)
139141
importFrom(methods,.hasSlot)
140142
importFrom(methods,classLabel)
@@ -157,8 +159,6 @@ importFrom(stats,rbinom)
157159
importFrom(stats,rnorm)
158160
importFrom(stats,runif)
159161
importFrom(stats,var)
160-
importFrom(tskitr,ts_load)
161-
importFrom(tskitr,ts_num_individuals)
162162
importFrom(utils,combn)
163163
importFrom(utils,packageDescription)
164164
importFrom(utils,read.table)

R/AlphaSimR.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @importFrom utils combn read.table write.table packageDescription
1111
#' @importFrom R6 R6Class
1212
#' @importFrom Rdpack reprompt
13-
#' @importFrom tskitr ts_load ts_num_individuals
13+
#' @importFrom RcppTskit TableCollection TreeSequence
1414

1515
#' @description
1616
#' The successor to the 'AlphaSim' software for breeding program

R/RcppExports.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,19 @@ MaCS <- function(args, maxSites, inbred, ploidy, nThreads, seed) {
373373
.Call(`_AlphaSimR_MaCS`, args, maxSites, inbred, ploidy, nThreads, seed)
374374
}
375375

376-
#' @title Get number of individuals in tree sequence
377-
#' @description Get number of individuals in tree sequence
378-
#' @param ts an external pointer to a \code{tsk_treeseq_t} object.
379-
#' @return integer number of individuals
376+
#' @title Summarise `tskit` table collection
377+
#' @param tc an external pointer to a \code{tsk_table_collection_t} object.
378+
#' @return A list.
380379
#' @examples
381-
#' ts_file <- system.file("examples", "test.trees", package = "tskitr")
382-
#' ts <- tskitr::ts_load(ts_file) # slendr also has ts_load()!
383-
#' tskitr::ts_num_individuals(ts)
384-
#' AlphaSimR::ts_num_individuals2(ts)
380+
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
381+
#' tc <- RcppTskit:::tc_ptr_load(ts_file)
382+
#' RcppTskit:::tc_ptr_summary(tc)
383+
#' AlphaSimR:::tc_ptr_summary2(tc) # a bit simpler at this stage ...
384+
#' tc <- RcppTskit::TableCollection$new(ts_file)
385+
#' RcppTskit:::tc_ptr_summary(tc$pointer)
386+
#' AlphaSimR:::tc_ptr_summary2(tc$pointer) # a bit simpler at this stage ...
385387
#' @export
386-
ts_num_individuals2 <- function(ts) {
387-
.Call(`_AlphaSimR_ts_num_individuals2`, ts)
388+
tc_ptr_summary2 <- function(tc) {
389+
.Call(`_AlphaSimR_tc_ptr_summary2`, tc)
388390
}
389391

configure.win

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
#!/bin/sh
2-
"${R_HOME}/bin/Rscript" tools/configure.R
3-
# TODO: The R Extensions manual suggest using "${R_HOME}/bin${R_ARCH_BIN}/Rscript" on Windows
4-
# https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Configure-and-cleanup
2+
"${R_HOME}/bin${R_ARCH_BIN}/Rscript" tools/configure.R

man/tc_ptr_summary2.Rd

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ts_num_individuals2.Rd

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)