Skip to content

Commit

Permalink
workflow fixes, fix category name stan check, run-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
santikka committed Feb 25, 2025
1 parent e7d27bb commit 7afeb5d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ jobs:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
needs: check
with:
cache-version: 2
extra-packages: |
rcmdcheck
any::rcmdcheck
local::.
BH
RcppParallel
RcppEigen
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -21,7 +23,7 @@ jobs:
DYNAMITE_SCALING_TESTS: ${{contains(github.event.head_commit.message, 'run-scaling')}}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -32,6 +34,7 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: 1
needs: coverage
extra-packages: |
covr
BH
Expand All @@ -50,23 +53,33 @@ jobs:

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion R/prepare_stan_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ prepare_stan_input <- function(dformula, data, group_var, time_var,
data[, .SD, .SDcols = resp],
function(x) {
cl <- class(x)
attr(cl, "levels") <- stan_name(levels(x))
attr(cl, "levels") <- stan_name(levels(x), check_first = FALSE)
cl
}
)
Expand Down
4 changes: 2 additions & 2 deletions R/stan_utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ stan_reserved_keywords <- c(
#'
#' @param x A `character` vector.
#' @noRd
stan_name <- function(x) {
stan_name <- function(x, check_first = TRUE) {
x <- gsub("\\s+", "_", x)
x <- gsub("[^a-zA-Z0-9_]", "", x)
x <- gsub("_{2,}$", "", x)
for (i in seq_along(x)) {
if (!grepl("^[a-zA-Z]", x[i])) {
if (check_first && !grepl("^[a-zA-Z]", x[i])) {
x[i] <- paste0("v_", x[i])
}
if (tolower(x[i]) %in% stan_reserved_keywords) {
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-extended.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ test_that("time-invariant cumulative fit and predict work", {

expect_error(
fit <- dynamite(
dformula =
obs(y ~ x, family = "cumulative", link = "logit"),
dformula = obs(y ~ x, family = "cumulative", link = "logit"),
data = d,
time = "time",
group = "id"
Expand Down

0 comments on commit 7afeb5d

Please sign in to comment.