-
Notifications
You must be signed in to change notification settings - Fork 8
135 lines (115 loc) · 4.97 KB
/
R-CMD-check.yml
File metadata and controls
135 lines (115 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: false
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck, any::covr, any::devtools, any::mockery, any::testthat, any::remotes
needs: check
cache-version: 2
- name: Install GitHub dependencies
run: |
if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")
# Install FITfileR from GitHub (in Suggests, so won't fail if install fails)
tryCatch({
remotes::install_github("grimbough/FITfileR", quiet = TRUE)
}, error = function(e) {
message("Note: FITfileR installation skipped (optional dependency)")
})
shell: Rscript {0}
- name: Get package name and version
id: pkg_info
run: |
PKG=$(awk -F': ' '/^Package:/{print $2}' DESCRIPTION | tr -d '\r')
VERSION=$(awk -F': ' '/^Version:/{print $2}' DESCRIPTION | tr -d '\r')
echo "Package: $PKG"
echo "Version: $VERSION"
echo "PKG=$PKG" >> "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
shell: bash
- name: Clean workspace and build fresh package
run: |
# Remove any existing tarballs to ensure we test the fresh build
rm -f *.tar.gz || true
# Build the package from current source (skip vignettes to avoid pandoc issues)
R CMD build . --no-build-vignettes
# Verify the expected tarball was created
EXPECTED_TARBALL="${{ steps.pkg_info.outputs.PKG }}_${{ steps.pkg_info.outputs.VERSION }}.tar.gz"
if [ ! -f "$EXPECTED_TARBALL" ]; then
echo "Error: Expected tarball $EXPECTED_TARBALL was not created"
ls -la *.tar.gz || echo "No .tar.gz files found"
exit 1
fi
echo "Successfully built: $EXPECTED_TARBALL"
echo "TARBALL_NAME=$EXPECTED_TARBALL" >> "$GITHUB_OUTPUT"
id: build_package
shell: bash
- name: Run R CMD check on tarball (CRAN-like check)
run: |
R CMD check ${{ steps.build_package.outputs.TARBALL_NAME }} --no-manual --no-build-vignettes --no-examples
shell: bash
env:
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_TESTS_NLINES_: 0
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
- name: Generate and Upload Coverage Report to Codecov
if: success() && matrix.config.os == 'ubuntu-latest' # Only run coverage on Ubuntu
shell: Rscript {0}
run: |
pkg <- "${{ steps.pkg_info.outputs.PKG }}"
tarball <- "${{ steps.build_package.outputs.TARBALL_NAME }}"
# Install required packages
if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")
if (!requireNamespace("covr", quietly = TRUE)) install.packages("covr")
if (!requireNamespace("testthat", quietly = TRUE)) install.packages("testthat")
if (!requireNamespace("mockery", quietly = TRUE)) install.packages("mockery")
message(sprintf("Installing package from tarball for coverage testing: %s", tarball))
devtools::install_local(tarball, force = TRUE, quiet = TRUE, dependencies = TRUE)
message(sprintf("Loading package: %s", pkg))
library(pkg, character.only = TRUE)
# Run coverage with error handling
tryCatch({
message("Executing run_coverage.R to generate and upload coverage...")
source("run_coverage.R")
}, error = function(e) {
message(paste("Coverage failed:", e$message))
message("Attempting alternative coverage method...")
cov <- covr::package_coverage()
if (!is.null(cov)) {
covr::codecov(coverage = cov)
}
})
- name: Upload check results
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
path: ${{ steps.pkg_info.outputs.PKG }}.Rcheck