Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 11 additions & 4 deletions .github/workflows/r.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-latest, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-latest, r: 'devel', valgrind: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.posit.co/cran/__linux__/noble/latest"}
- {os: ubuntu-latest, r: 'devel', rspm: "https://packagemanager.posit.co/cran/__linux__/noble/latest"}
- {os: ubuntu-latest, r: 'devel', valgrind: true, rspm: "https://packagemanager.posit.co/cran/__linux__/noble/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down Expand Up @@ -60,10 +60,17 @@ jobs:
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libssl-dev \
libcurl4-openssl-dev \
libglpk-dev \
libgmp3-dev \
libxml2-dev
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "24.04"))')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit overkill.

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
Expand Down
89 changes: 89 additions & 0 deletions scripts/check-github-actions-local.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! But we need to ensure that scripts is in the .Rbuildignore. Can you check that?

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
#
# check-github-actions-local.sh - Simulate GitHub Actions checks locally
#
# This script replicates the GitHub Actions workflow locally using Docker
# to test changes before pushing to GitHub.
#
# Usage:
# ./scripts/check-github-actions-local.sh [ubuntu|macos|windows|all]
#
# Requirements:
# - Docker installed and running
# - Run from repository root

set -e
set -u

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# Configuration
PLATFORM="${1:-ubuntu}"
PACKAGE_NAME=$(awk '/^Package:/ {print $2}' DESCRIPTION)
PACKAGE_VERSION=$(awk '/^Version:/ {print $2}' DESCRIPTION)

echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}GitHub Actions Local Check${NC}"
echo -e "${GREEN}========================================${NC}"
echo "Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
echo "Platform: ${PLATFORM}"
echo ""

case "$PLATFORM" in
ubuntu|linux)
echo -e "${YELLOW}[1/3] Testing Ubuntu (r-release)...${NC}"

# Use R-hub Ubuntu container (simulates ubuntu-latest with R release)
docker run --rm \
-v "$(pwd):/workspace" \
-w /workspace \
ghcr.io/r-hub/containers/ubuntu-release:latest \
bash -c "
set -e
echo '>>> Installing system dependencies...'
apt-get update > /dev/null 2>&1
apt-get install -y libssl-dev libcurl4-openssl-dev libglpk-dev libgmp3-dev libxml2-dev > /dev/null 2>&1

echo '>>> Installing R package dependencies...'
Rscript -e \"install.packages(c('Rcpp', 'RcppArmadillo', 'sna', 'network', 'networkDynamic', 'Matrix', 'MASS', 'MatchIt', 'SparseM', 'boot', 'igraph', 'viridisLite', 'rcmdcheck', 'remotes', 'knitr'), repos='https://packagemanager.posit.co/cran/__linux__/noble/latest', quiet=TRUE)\"

echo '>>> Running R CMD check...'
Rscript -e \"rcmdcheck::rcmdcheck(args = c('--no-manual', '--as-cran'), error_on = 'warning', check_dir = 'check')\"
" && echo -e "${GREEN}✓ Ubuntu check passed${NC}" || echo -e "${RED}✗ Ubuntu check failed${NC}"
;;

macos|mac)
echo -e "${YELLOW}macOS checks require macOS host - skipped${NC}"
echo "To test on macOS, run: R CMD build . && R CMD check --as-cran *.tar.gz"
;;

windows|win)
echo -e "${YELLOW}Windows checks require Windows host - skipped${NC}"
echo "To test on Windows, use rhub or GitHub Actions"
;;

all)
echo -e "${BLUE}Running all available checks...${NC}"
$0 ubuntu
;;

*)
echo -e "${RED}Unknown platform: $PLATFORM${NC}"
echo "Usage: $0 [ubuntu|macos|windows|all]"
exit 1
;;
esac

echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Local check completed!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Note: This simulates GitHub Actions but may have minor differences."
echo "For exact GitHub Actions behavior, push to a branch and create a PR."
echo ""
5 changes: 3 additions & 2 deletions src/infection.cpp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copilot was fixing this in #60. Just closed that in favor of this.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <cmath>
using namespace Rcpp;

// [[Rcpp::export]]
Expand Down Expand Up @@ -55,7 +56,7 @@ NumericVector infection_cpp(
Rcpp::checkUserInterrupt();

// If NA (aka nan in Armadillo), then NA.
if (!arma::is_finite(times(i))) {
if (!std::isfinite(times(i))) {
infect.at(i) = NA_REAL;
continue;
}
Expand Down Expand Up @@ -159,7 +160,7 @@ NumericVector susceptibility_cpp(
Rcpp::checkUserInterrupt();

// If NA (aka nan in Armadillo), then NA.
if (!arma::is_finite(times(i))) {
if (!std::isfinite(times(i))) {
suscep.at(i) = NA_REAL;
continue;
}
Expand Down
Loading