This repo is designed to run regression tests of proposed bookdown changes. It builds several bookdown books with two bookdown versions (typically tip of main and the branch under test) and compares the results within a github action.
This compares results of two versions of bookdown. The in-bookdown-main and in-bookdown-test specify these versions. In main of this repo (bookdown-heavy-testing), both of these point to the same version of bookdown, so any differences are the result of non-determinism.
All submodules except in-bookdown-test contain books that are compiled by this test. So in-bookdown-main serves a dual purpose: providing the basely code to compare in-bookdown-test to and providing one of the books to compile.
These instructions assume you are already familiar with the workflow to fork, push to branch, make a PR, but may not be terribly familliar with git submodules.
- Make your change in bookdown and push to a fork of the bookdown repo.
- Clone/pull latest for this (
bookdown-heavy-testing) repo. Since it has submodules, in addition togit cloneorgit pullyou will likely also need to rungit submodule update --init --recursivefrom inside the repo. - Create a fork and a new branch from
bookdown-heavy-testingrepo as you normally would if you planned to contribute to the repo. - Update the
in-bookdown-testsubmodule to point to thebookdownrepo branch that you want to test. Switch the url of this submodule to your fork:
git submodule set-url in-bookdown-test [email protected]:YOUR_GITHUB_USERNAME/bookdown.git
Checkout the branch you want to test:
git -C ./in-bookdown-test/ fetch
git -C ./in-bookdown-test/ checkout YOUR_BOOKDOWN_BRANCH_NAME
Git status should now look like this:
On branch YOUR_BOOKDOWN_HEAVY_TESTING_BRANCH
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitmodules
modified: in-bookdown-test (new commits)
- Commit and push submodule changes to your
bookdown-heavy-testingfork. - Make a PR and wait for CI. (Good idea to mark it as a draft, since it is not intended to be merged.)
- Examine the diff. Within the github action "Results" has which files and lines changed and "Full Results" has the actual changes.
Your bookdown-heay-testing branch will not automatically update when you update your bookdown branch. You will need to fol
- Make sure you have pushed your changes to your bookdown fork.
- Inside
bookdown-heavy-testing, with yourbookdown-heavy-testingbranch checked out Run:
git submodule update --remote in-bookdown-test
git status should now show this:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: in-bookdown-test (new commits)
- Commit and push these changes.
- Update your
bookdownbranch (merge in main or rebase and push). - Update your
bookdown-heavy-testingbranch to reflect the change to yourbookdownbranch as described above. - Update the
in-bookdown-mainlink: from yourbookdown-heavy-testingbranch, run
git submodule update --remote in-bookdown-main
Commit and push these changes. It doesn't really matter that you generating a different commit history from the main branch of bookdown-heavy-testing because the point of your branch/PR is just to test a branch of a different repo (bookdown), not to merge.
If you are switching between branches of bookdown-heavy-tesing that where the submodules are pointing to different places, in addition to git checkout, you will need to run git submodule update when changing branches. This will get you back to the version of the
- Add the book as a submodule in the format
in-bookname. - Add the book to
books-to-test.ymlin the formatbookname: path/to/book. - Add any Linux dependencies to the dockerfile.
- Add any R dependencies to env-base (e.g.
renv::record(YOUR_R_PKG, project='env-base'))). - Add known non-deterministic sections to exceptions. The easiest way to do this is to first run [run_test.R]. (You can edit [books-to-test.yml] to include only the new book to speed things up). Then, source
parse-diff.R, thenwrite_diffs(dir_diff('out-main/', 'out-test/', 'newexceptions.yml')). Examine the generated files:results.txt,full_results.txt, andnewexceptions.ymlto make sure they represent changes you would expect to see from run to run. If everything looks good, add the contents ofnew_exceptions.ymltoexceptions.yml.