Skip to content

Commit 33f5a80

Browse files
authored
Merge pull request #208 from animint/coverage
Implementing code coverage
2 parents 06a384b + 1065d7f commit 33f5a80

File tree

15 files changed

+501
-124
lines changed

15 files changed

+501
-124
lines changed

.Rbuildignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ test-compiler-gist.R
1919
^docs$
2020
^pkgdown$
2121
^\.github$
22+
^package\.json$
23+
^package-lock\.json$
24+
^node_modules/
25+
^v8-to-istanbul\.js$

.github/workflows/tests.yaml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
TEST_SUITE: ${{ matrix.test-suite }}
2020
GITHUB_PAT: ${{ secrets.PAT_GITHUB }}
2121
GH_ACTION: "ENABLED"
22+
COLLECT_COVERAGE: "TRUE"
23+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2224
steps:
2325
- uses: actions/checkout@v3
2426
- name: install and update texlive
@@ -35,6 +37,49 @@ jobs:
3537

3638
- name: git config user.email
3739
run: git config --global user.email [email protected]
40+
41+
- name: Setup Node.js
42+
if: matrix.test-suite == 'renderer'
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: '18'
46+
47+
- name: Install Node.js dependencies
48+
if: matrix.test-suite == 'renderer'
49+
run: |
50+
npm install v8-to-istanbul
51+
echo "Node modules installed"
3852
3953
- name: run tests
40-
run: if [ "$TEST_SUITE" == "CRAN" ];then bash build.sh;else Rscript -e "source('tests/testthat.R', chdir = TRUE)";fi
54+
run: |
55+
if [ "$TEST_SUITE" == "CRAN" ]; then
56+
bash build.sh
57+
elif [ "$TEST_SUITE" == "compiler" ]; then
58+
Rscript -e "source('tests/testthat.R', chdir = TRUE)"
59+
Rscript -e 'covr::codecov(quiet = TRUE)'
60+
else
61+
Rscript -e "source('tests/testthat.R', chdir = TRUE)"
62+
fi
63+
64+
- name: Convert JS coverage to Istanbul format
65+
if: matrix.test-suite == 'renderer'
66+
run: |
67+
if [ -f "tests/testthat/js-coverage.json" ]; then
68+
echo "Converting JS coverage to LCOV format..."
69+
node v8-to-istanbul.js
70+
else
71+
echo "No JS coverage file found"
72+
exit 1
73+
fi
74+
75+
- name: Upload JS coverage to Codecov
76+
if: matrix.test-suite == 'renderer'
77+
run: |
78+
if [ -f "coverage-istanbul.json" ]; then
79+
curl -Os https://uploader.codecov.io/latest/linux/codecov
80+
chmod +x codecov
81+
./codecov -f coverage-istanbul.json -t ${{ secrets.CODECOV_TOKEN }} --flags javascript
82+
else
83+
echo "No coverage file found"
84+
exit 1
85+
fi

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
*ANIMINT_TEST_FOO
1111
*pids.txt
1212
*~
13-
.vscode/settings.json
13+
.vscode/settings.jsonnode_modules/
14+
node_modules/

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: animint2
22
Title: Animated Interactive Grammar of Graphics
3-
Version: 2025.6.28
3+
Version: 2025.7.10
44
URL: https://animint.github.io/animint2/
55
BugReports: https://github.com/animint/animint2/issues
66
Authors@R: c(
@@ -89,6 +89,7 @@ Suggests:
8989
sp,
9090
gistr (>= 0.2),
9191
shiny,
92+
covr,
9293
RColorBrewer,
9394
htmltools,
9495
rmarkdown,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Changes in version 2025.7.10 (PR#208)
2+
3+
- Added Codecov integration for both R and JavaScript tests; coverage reports now available at https://app.codecov.io/github/animint/animint2
4+
15
# Changes in version 2025.6.28 (PR#204)
26

37
- The geom_raster implementation has been removed.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Play around with [this interactive data visualization of data from the World Ban
2222

2323
To learn how to generate your own interactive data visualizations, go to the official [Animint2 Manual](https://rcdata.nau.edu/genomic-ml/animint2-manual/Ch00-preface.html). If you encounter problems, please see the [animint2 wiki](https://github.com/animint/animint2/wiki) or [report them](https://github.com/animint/animint2/issues).
2424

25+
[![codecov](https://codecov.io/gh/animint/animint2/branch/main/graph/badge.svg)](https://codecov.io/gh/animint/animint2)
26+
2527
## Installation
2628

2729
``` r

build.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -o errexit
3+
set -o pipefail
34
R -e 'devtools::document()'
45
cd ..
56
rm -rf animint2-release
@@ -30,4 +31,18 @@ EOF
3031
PKG_TGZ=$(R CMD build animint2-release|grep building|sed "s/.*\(animint2.*.tar.gz\).*/\1/")
3132
echo built $PKG_TGZ so now we INSTALL
3233
R CMD INSTALL $PKG_TGZ
33-
R CMD check --as-cran $PKG_TGZ
34+
echo "Running R CMD check --as-cran $PKG_TGZ"
35+
check_output=$(R CMD check --as-cran $PKG_TGZ 2>&1)
36+
check_status=$?
37+
echo "$check_output"
38+
# Check for WARNINGs or NOTEs in the output
39+
if echo "$check_output" | grep -q -E "WARNING|NOTE"; then
40+
echo "CRAN check generated WARNINGs or NOTEs:"
41+
exit 1
42+
fi
43+
# Exit with original status if no WARNINGs/NOTEs but check failed
44+
if [ $check_status -ne 0 ]; then
45+
echo "R CMD check failed with status $check_status"
46+
exit $check_status
47+
fi
48+
echo "CRAN check completed successfully"

inst/htmljs/animint.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,15 @@ var animint = function (to_select, json_file) {
17171717
}
17181718
return selected_values;
17191719
};
1720+
1721+
// DEAD CODE FOR COVERAGE TESTING
1722+
function deadCodeForCoverage() {
1723+
// This function is never called and should show as uncovered in coverage reports.
1724+
var unused = 42;
1725+
if (unused === 43) {
1726+
console.log("This should never be printed.");
1727+
}
1728+
}
17201729

17211730
// update scales for the plots that have update_axes option in
17221731
// theme_animint

package-lock.json

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

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "animint2",
3+
"version": "1.0.0",
4+
"description": "<a href=\"https://github.com/tdhock/animint2/actions/workflows/tests.yaml\"> \t<img src=\"https://github.com/tdhock/animint2/actions/workflows/tests.yaml/badge.svg\" \t alt=\"A badge verifying if this package has passed all its tests.\"> </a> <!-- Feel free to change the HTML block above this comment into Markdown. It's just in HTML cuz I couldn't be arsed to figure out how to correctly combine an image and a link in Github-flavored Markdown. -->",
5+
"main": "index.js",
6+
"directories": {
7+
"doc": "docs",
8+
"man": "man",
9+
"test": "tests"
10+
},
11+
"scripts": {
12+
"test": "echo \"Error: no test specified\" && exit 1"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/animint/animint2.git"
17+
},
18+
"keywords": [],
19+
"author": "",
20+
"license": "ISC",
21+
"bugs": {
22+
"url": "https://github.com/animint/animint2/issues"
23+
},
24+
"homepage": "https://github.com/animint/animint2#readme",
25+
"dependencies": {
26+
"v8-to-istanbul": "^9.3.0"
27+
}
28+
}

0 commit comments

Comments
 (0)