Contributing to hovercraft
Source:.github/CONTRIBUTING.md
Thank you for helping with hovercraft. To report a bug or suggest an idea, open an issue with one of the issue forms. To change something yourself, read the workflow below and open a pull request.
Setup
-
R: the current release is recommended. The minimum version is in
DESCRIPTION. -
Development packages: from the package root, run
pak::local_install_dev_deps(). -
Air, the formatter for R code: https://posit-dev.github.io/air/. The settings are in
air.toml. -
Biome, the formatter and linter for JavaScript and CSS in
inst/and for the test bench’s scripts and styles (tests/testthat/apps/testbench/www): https://biomejs.dev. The settings are inbiome.json. The bench’s files are checked withbiome ci .; the quality gate and CI check onlyinst/until launchR’s Biome step is widened. - Google Chrome or Chromium, for the browser tests.
- If you use renv, set up your own library; the repository does not ship one.
The checks you run on your computer are described under “Before you open a pull request” below.
Workflow
- Start with an issue, using an issue form. State the goal and a “done when” checklist. One issue per piece of work; ask first if the change is large. Every issue sits under an epic (a sub-issue of it); only the root issue has no parent, and if no epic fits, ask which to use. Keep the description current when scope or decisions change. Tick the items a pull request delivers, and say what stays open.
-
Make a branch from
mainfor that issue. -
Commit with Conventional Commits, short:
feat:,fix:,docs:,chore:,test:,ci:,refactor:. - Open one pull request for the issue, using the template. Its body starts with “In brief”: one plain sentence on what changes and why, then a few bullets for a reader with no context, and “Closes #n”. Keep the sections that apply, put repeatable checks in its table and one-off observations in Notes.
-
Suggest a label in the pull request: one of
feature,enhancement,bug,documentationorchore. The maintainer applies it; the release notes are built from it. -
The maintainer merges once CI is green. Pull requests are squash-merged, so the pull request title becomes the commit message on
main: keep it a Conventional Commit.
Update every text that describes what you changed, in the same pull request: help pages (through roxygen2), articles, the README, NEWS.md and the examples; workflow comments and the instruction files if the repository has them (AGENTS.md, CLAUDE.md); and any other page or file that describes the behaviour, including ones added later. It works both ways: if you edit an article or an example, check that the help page still agrees. Search the repository for the old wording and list the search terms in the pull request.
Changes reach main through pull requests. Never force-push, push to main, or skip checks with --no-verify. CI on a pull request from a fork waits for a maintainer to approve the run. Leave “Allow edits by maintainers” on, so a maintainer can fix a small thing, such as a typo or a failing format check, on your branch.
Stacked pull requests are fine. Base the second one on the branch below it, and say so in its description.
Before you open a pull request
From the package root:
devtools::document() # help pages and NAMESPACE, from the roxygen2 comments
devtools::test() # the tests
devtools::check() # the same R CMD check that CI runs, with the same pass mark- Commit the files
devtools::document()changes together with the source. - An unknown word fails the spelling check: list it in your pull request, and the maintainer adds agreed words to
inst/WORDLIST. - The spelling check reads
Language: en-GBinDESCRIPTION, so it expects British spelling. For American spelling (color, license), change it toen-US. - To run the same checks CI runs, including style, docs in sync and spelling, use launchR’s quality gate (https://launch-r.web.app/SKILL.md), from the package root: mode
lintbefore a commit,fastbefore a push,testswhen you touchedR/ortests/, andfullbefore the pull request. Send its output to a file and read the PASS, FAIL and SKIP lines. - A failing check on a pull request is read from its log in the Checks tab. Fix the first failure and push again.
Code in short
-
Style: the tidyverse style guide, formatted by Air (
air.toml) and linted by lintr (.lintr). Names are snake_case, lines at most 120 characters. - Write help and offline examples with roxygen2. Every exported function documents its return value.
- Call other packages as
pkg::fn()and add them toDESCRIPTIONfirst. - Check arguments at the top of exported functions, and give messages that say what to do next.
- Keep JavaScript and CSS in
inst/plain and readable. Bundle what the package needs; do not load anything from a CDN. - Accessibility: meaning never rests on colour alone. Honour
prefers-reduced-motion.
Tests
Tests use testthat 3rd edition, one test file per R file. Add a test for every new behaviour and every fixed bug, and keep example data made up. Browser and snapshot tests that CRAN skips live in their own files and run in CI.
The book
hovercraft book (inst/book/, opened by hovercraft_book()) shows every feature of the package on one page: six parts, each with numbered sections, one feature per section. Every export and every argument is in the book. A pull request that adds, removes or changes an export or an argument (its name, values, default or behaviour) updates the book in the same pull request, and a test fails until it does.
-
Files.
app.Rstarts the app. Shiny loads every file inR/first: the shared helpers inR/shared-*.R(code as text, running it, the section frame and its margin, the test steps and their proofs, the inputs log, the tables), one file per section inR/plate-<id>.R, the contents inR/contents.R, the made-up data inR/data.R, and the page inR/page.R.www/shared.cssandwww/shared.jsgo with the shared helpers;www/book.cssandwww/book.jsare the page’s own look, its index and search, its phone layout and the checklist. -
The contents are in one file,
R/contents.R: the parts, their sections in order, and what each section shows (covers, aslist(fn = c("arg", ...)), withcharacter()for a function shown without arguments;proseonly forhovercraft_book()’s own arguments, which a section shows in its words). Numbers come from the order; the ids stay, since links andhovercraft_book(section =)use them.hovercraft_book()reads the ids from this file. -
A section also has its own file,
R/plate-<id>.R, withplate_<id>_ui(),plate_<id>_server()and<id>_steps()(3 to 5 test steps). The page and its server find them by the id. Every section sends the code it shows throughplate_code(). -
Coverage is tested.
test-book.Rreads every export and argument from the help pages, with its stable or experimental badge, and fails while one is in no section’scovers. It then sets every combination of each section’s choices and checks that the code the section shows really calls each function and argument it lists (an argument given by position counts). To add a feature: add it to a section’s code and to itscoversincontents.R, or add a section. The margin’s “What this section shows” lists them with their badges. -
One source of truth. Each section builds its R code as text from its choices (
<id>_code()); the margin shows that text and the figure is the same text, run with only the package’s exports in reach. A section’s server code (Live output’s observers and render, Disabled’s update, From the server’s observers) is run from its shown text the same way. Code that would fail in a reader’s app fails in the book too. The one exception is the page’s look in section 4.1: a dependency loads once per page, so the book writes the attribute and variable thatuse_hovercraft(style = )writes, with the names from the engine’stip.json. -
Test steps tick from real inputs. A step is
step(text, bug, target, proof); a proof names the Shiny input that shows the step was done (on_hint(),on_pin(),on_copy()). By default a proof counts only the reader’s own actions (by = "reader"), so a tip the page closes and pins again never ticks a step. A step without a proof is ticked by hand; a step with one is ticked only by its proof. The checklist (the key C, or?checklist=1) shows one step at a time. -
The index lists the parts and opens only the part being read; a click on a part’s title goes to its first section. Its search box matches each section’s number, title, part and the functions and arguments it shows (its
coversincontents.R), written into the page by the server, and opens every part with a match. -
App code calls other packages as
pkg::fn(), and nothing in it writes an attribute or class name of the tip engine: they come from the engine’stip.json. -
Tests:
tests/testthat/test-book.R(the launcher, the page, every export and argument covered, every section’s figure for every combination of its choices, the proofs) andtest-book-browser.R(the app in Chrome).
The test bench
The test bench (tests/testthat/apps/testbench/) is one Shiny app with the Shiny-practice checks, a tab of JavaScript-driven UI and a spot for every behaviour scenario (HC-001 to HC-077). A person runs it by hand for a walkthrough, and the browser tests start it with start_bench() (tests/testthat/helper-bench.R). Its README.md says how to run it and which settings its address takes.
-
Files.
R/contents.Rlists the tabs; each tab<id>istab_<id>_ui()andtab_<id>_server()inR/tab-<id>.R.scenarios.csvlists the scenarios and the tab of each;spot()inR/shared-spot.Rdraws one. - Ids in a tab start with the tab’s id, so all tabs can share a page. The practice tab keeps the ids its test uses.
-
Page-wide settings of
use_hovercraft()(keys, pins, labels, style) go in the address, never in a tab: the page reads them once. -
The log (
www/bench-log.js) keeps every tip event, input and custom message inwindow.benchLog. A test reads it withpage$log_has(), which waits, and checks console errors withpage$problems(). -
Tests:
test-bench.R(the list and the spots match, every tab draws and starts its server),test-bench-browser.R(every tab in Chrome),test-bench-js-browser.R,test-practice-browser.R,test-practice-table-browser.Randtest-leak-browser.R(the last two use the bench’s tabsupdatesandleaks, which have no scenarios); and onetest-bench-<tab>-browser.Rper scenario tab, each scenario’s test ending withexpect_bench_clean()(helper-bench-scenarios.R). A scenario’stestscolumn inscenarios.csvnames the file that covers it.
NEWS.md
Add one bullet for each user-facing change (a new or changed function, argument or message), in the same pull request. Write it for users, in the present tense, start with the function or feature, and end with the issue number:
Release headings and versions belong to the maintainer.
Licence of contributions
Contributions use the package’s licence (see LICENSE). Before adding third-party files, check that their licence allows it, and say where they came from.
Conduct and data
Everyone taking part follows the code of conduct. Be kind and patient, and give feedback on the work, not the person. For a security problem, do not open an issue; follow the security policy. For questions, use Discussions rather than an issue.
Use made-up data in examples and screenshots. Leave out private data, credentials and machine paths.