Skip to content

Commit 7c1628c

Browse files
committed
Work on pre-commit #34
1 parent dbf03ed commit 7c1628c

9 files changed

Lines changed: 92 additions & 101 deletions

File tree

.github/workflows/format-check.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/format-suggest.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/jarl-check.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
exclude: |
2+
(?x)^(
3+
extern/
4+
| RcppTskit/inst/include/tskit/
5+
| RcppTskit/src/tskit/
6+
| RcppTskit/R/RcppExports\.R
7+
| RcppTskit/src/RcppExports\.cpp
8+
)
9+
10+
repos:
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v6.0.0
13+
hooks:
14+
- id: trailing-whitespace
15+
- id: end-of-file-fixer
16+
- id: mixed-line-ending
17+
- id: check-yaml
18+
- id: check-added-large-files
19+
- id: check-merge-conflict
20+
- repo: https://github.com/benjeffery/pre-commit-clang-format
21+
rev: "1.0"
22+
hooks:
23+
- id: clang-format
24+
verbose: true
25+
- repo: local
26+
hooks:
27+
- id: air-format
28+
name: air format
29+
entry: air format .
30+
language: system
31+
pass_filenames: false
32+
files: '\.(R|Rmd|rmd|qmd|Qmd)$'
33+
34+
- id: jarl-lint
35+
name: jarl lint
36+
entry: jarl check .
37+
language: system
38+
pass_filenames: false
39+
files: '\.(R|Rmd|rmd|qmd|Qmd)$'

README.md

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,62 @@ remotes::install_github("HighlanderLab/RcppTskit/RcppTskit")
8080

8181
## Development
8282

83+
### Clone
84+
8385
First clone the repository:
8486

8587
```
8688
git clone https://github.com/HighlanderLab/RcppTskit.git
8789
```
8890

91+
### Pre-commit install
92+
93+
We use [pre-commit](https://pre-commit.com) hooks to ensure code quality. Specifically, we use:
94+
* [air](https://github.com/posit-dev/air) to format R code,
95+
* [jarl](https://github.com/etiennebacher/jarl) to lint R code, and
96+
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to format C/C++ code.
97+
98+
To install the hooks, run:
99+
100+
```
101+
pre-commit install
102+
```
103+
104+
### tskit
105+
89106
If you plan to update `tskit`, follow instructions in `extern/README.md`.
90107

91-
Then open `RcppTskit` package directory in your favourite R IDE (Positron, RStudio, text-editor-of-your-choice, etc.), implement your changes and run (in R):
108+
### RcppTskit
109+
110+
Then open `RcppTskit` package directory in your favourite R IDE (Positron, RStudio, text-editor-of-your-choice, etc.) and implement your changes.
111+
112+
You should routinely check the status of the package (in R):
92113

93114
```
94115
# Note that the RcppTskit R package is in the RcppTskit sub-directory
95116
setwd("path/to/RcppTskit/RcppTskit")
96117
97-
# Run checks of your changes, documentation, etc.
118+
# Run checks of your changes, documentation, tests, etc.
98119
devtools::check()
99120
100121
# Install the package
101122
devtools::install()
123+
124+
# Run just tests
125+
devtools::test()
126+
127+
# Check code test coverage
128+
cov <- covr::package_coverage(clean = TRUE)
129+
covr::report(cov)
102130
```
103131

104-
Alternatively you can check and install from command line:
132+
Alternatively you can check from the command line:
105133

106134
```
107135
# Note that the RcppTskit package is in the RcppTskit sub-directory
108-
cd path/to/RcppTskit
136+
cd path/to/RcppTskit/RcppTskit
109137
110-
# Run checks of your changes, documentation, etc.
138+
# Run checks of your changes, documentation, tests, etc.
111139
R CMD build RcppTskit
112140
R CMD check RcppTskit_*.tar.gz
113141
@@ -116,3 +144,19 @@ R CMD INSTALL RcppTskit_*.tar.gz
116144
```
117145

118146
On Windows, replace `tar.gz` with `zip`.
147+
148+
### Pre-commit run
149+
150+
Before committing your changes, run the pre-commit hooks to ensure code quality:
151+
152+
```
153+
# pre-commit autoupdate # to update the hooks
154+
pre-commit run --all-files
155+
# pre-commit run <hook_id>
156+
```
157+
158+
### Continuous integration
159+
160+
We use Github Actions to run continuous integration (CI) checks on each push and pull request. Specifically, we run:
161+
* [R CMD check](.github/workflows/R-CMD-check.yaml) on Linux, macOS, and Windows and
162+
* [covr test coverage](.github/workflows/covr.yaml).

RcppTskit/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
YEAR: 2025
2-
COPYRIGHT HOLDER: Gregor Gorjanc
2+
COPYRIGHT HOLDER: Gregor Gorjanc

RcppTskit/cleanup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
rm -f src/Makevars
55

66
# Removing compilation files
7-
rm -f src/*.o src/tskit/*.o src/*.so
7+
rm -f src/*.o src/tskit/*.o src/*.so

RcppTskit/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/sh
2-
"${R_HOME}/bin/Rscript" tools/configure.R
2+
"${R_HOME}/bin/Rscript" tools/configure.R

RcppTskit/inst/COPYRIGHTS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ License: MIT
55
Files: inst/include/tskit
66
src/tskit
77
Copyright: 2018-2019 Tskit Developers
8-
License: MIT
8+
License: MIT

0 commit comments

Comments
 (0)