Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
push:
branches: [main, devel]
pull_request:

name: pre-commit.yaml

permissions: read-all

jobs:
pre-commit:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install Rcpp
run: Rscript -e 'install.packages("Rcpp")'

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install --yes clang-format clang-tidy

- name: Install Air
uses: posit-dev/setup-air@v1

- name: Install Jarl
run: |
curl --proto '=https' --tlsv1.2 -LsSf \
https://github.com/etiennebacher/jarl/releases/latest/download/jarl-installer.sh | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --show-diff-on-failure
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ on each push and pull request.
Specifically, we run:
* [R CMD check](.github/workflows/R-CMD-check.yaml) on multiple platforms
(see curent status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/R-CMD-check.yaml)),
* [covr test coverage](.github/workflows/covr.yaml)
(see current status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/test-coverage.yaml)), and
* [Roxygen documentation generation](.github/workflows/document.yaml)
(see current status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/document.yaml)).
* [documentation generation](.github/workflows/document.yaml)
(see current status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/document.yaml)),
* [pre-commit hooks](.github/workflows/pre-commit.yaml)
(see current status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/pre-commit.yaml)), and
* [test coverage](.github/workflows/test-coverage.yaml)
(see current status [here](https://github.com/HighlanderLab/RcppTskit/actions/workflows/test-coverage.yaml)).

[R universe for RcppTskit](https://highlanderlab.r-universe.dev/RcppTskit)
also provides another set of checks - see [here](https://highlanderlab.r-universe.dev/RcppTskit#checktable).
These are provided once the code is merged into this repository.
These are provided after new code is pushed or merged into this repository.
3 changes: 3 additions & 0 deletions RcppTskit/tests/testthat/test_TableCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ test_that("TableCollection and TreeSequence round-trip works", {

tc <- ts$dump_tables()
expect_true(is(tc, "TableCollection"))
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- tc$print())
expect_equal(
p,
Expand Down Expand Up @@ -177,7 +178,9 @@ test_that("TableCollection and TreeSequence round-trip works", {

ts2 <- tc$tree_sequence()
expect_true(is(ts2, "TreeSequence"))
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(ts_print <- ts$print())
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(ts2_print <- ts2$print())
expect_equal(ts_print, ts2_print)

Expand Down
6 changes: 6 additions & 0 deletions RcppTskit/tests/testthat/test_load_summary_and_dump.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
)
expect_no_error(tc_load(ts_file, skip_tables = TRUE))
check_empty_tables <- function(ts) {
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- ts$print())
expect_true(all(p$tables$number == 0))
}
Expand Down Expand Up @@ -50,6 +51,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
)
expect_no_error(tc_load(ts_file, skip_tables = TRUE))
check_empty_tables <- function(tc) {
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- tc$print())
expect_true(all(p$tables$number == 0))
}
Expand Down Expand Up @@ -225,6 +227,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
regexp = "ts must be an object of externalptr class!"
)
p_ptr <- ts_ptr_print(ts_ptr)
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- ts$print())
expect_equal(
p,
Expand Down Expand Up @@ -276,6 +279,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
regexp = "tc must be an object of externalptr class!"
)
p_ptr <- tc_ptr_print(tc_ptr)
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- tc$print())
expect_equal(
p,
Expand Down Expand Up @@ -549,6 +553,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
expect_equal(m_ptr, m)

p_ptr <- ts_ptr_print(ts_ptr)
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- ts$print())
expect_equal(
p_ptr,
Expand Down Expand Up @@ -630,6 +635,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
expect_equal(m_ptr_tc, m_ptr_ts)

p_ptr <- tc_ptr_print(tc_ptr)
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(p <- tc$print())
expect_equal(
p_ptr,
Expand Down
5 changes: 5 additions & 0 deletions RcppTskit/tests/testthat/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ test_that("tskit_version() works", {
})

test_that("tsk_bug_assert() works", {
# jarl-ignore internal_function: it's just a test
expect_error(RcppTskit:::test_tsk_bug_assert_c())
# jarl-ignore internal_function: it's just a test
expect_error(RcppTskit:::test_tsk_bug_assert_cpp())
})

test_that("tsk_trace_error() works", {
t <- "You have to compile with -DTSK_TRACE_ERRORS to run these tests. See src/Makevars.in."
# jarl-ignore internal_function: it's just a test
skip_if_not(RcppTskit:::tsk_trace_errors_defined(), t)
# jarl-ignore internal_function: it's just a test
expect_warning(RcppTskit:::test_tsk_trace_error_c())
# jarl-ignore internal_function: it's just a test
expect_warning(RcppTskit:::test_tsk_trace_error_cpp())
})
4 changes: 4 additions & 0 deletions RcppTskit/tests/testthat/test_r_to_py_and_py_to_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ test_that("ts_r_to_py() and ts_py_to_r() work", {
expect_equal(length(ts2_py$tables$mutations$metadata), m2$mutations)

expect_true(is(ts2_r, "TreeSequence"))
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(ts2_r_print <- ts2_r$print())
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(ts_ptr2_r_print <- ts_ptr_print(ts_ptr2_r))
expect_equal(ts2_r_print, ts_ptr2_r_print)
})
Expand Down Expand Up @@ -264,7 +266,9 @@ test_that("tc_r_to_py() and tc_py_to_r() work", {
expect_equal(length(tc2_py$mutations$metadata), m2$mutations)

expect_true(is(tc2_r, "TableCollection"))
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(tc2_r_print <- tc2_r$print())
# jarl-ignore implicit_assignment: it's just a test
tmp <- capture.output(tc_ptr2_r <- tc_ptr_print(tc_ptr2_r))
expect_equal(tc2_r_print, tc_ptr2_r)
})
Loading