@@ -173,6 +173,78 @@ give you comments to improve the code. You can make additional changes
173173and push them to the same feature branch and they will be automatically
174174added to the pull request.
175175
176+ Running Tests
177+ ~~~~~~~~~~~~~
178+
179+ We run many tests and checks automatically on GitHub (collectively called "CI")
180+ for a variety of build configurations. See :ref: `sec-runtestsuite ` for how to
181+ run them locally. Running the full test suite can take some time, but it's a
182+ good idea to run at least the unit tests locally when you're making changes:
183+
184+ .. code-block :: console
185+
186+ cmake --build build --target check-unit-tests
187+
188+ Along with the automated tests, we also run things like formatters and static
189+ analysis in CI, which may provide further feedback (see :ref: `sec-coding-style `
190+ for more details). If your PR fails the format check on CI, please install the
191+ formatters and run them according to the next section. Usually this is just:
192+
193+ .. code-block :: console
194+
195+ git clang-format next
196+
197+ which will format just the parts of C++ files that have changed since ``next ``.
198+
199+ Formatting and Linters
200+ ~~~~~~~~~~~~~~~~~~~~~~
201+
202+ For frequent developers, we strongly recommend installing the formatting and
203+ linting tools locally and building them into your regular workflow. You can
204+ install the majority of our developer tools at once using `uv
205+ <https://docs.astral.sh/uv/> `_ from the top of your BOUT++ directory:
206+
207+ .. code-block :: console
208+
209+ uv sync --only-dev --inexact
210+
211+ This will install all the developer tools into a virtual environment (creating
212+ one if necessary, typically under ``.venv ``). You can then activate the virtual
213+ environment and use the tools manually, or via integrations in your editor.
214+
215+ We *strongly * recommend using ``uv `` to install the developer tools, as this
216+ will ensure that you get the *exact * versions used in CI and by other
217+ developers, but you could also use ``pip install --group dev `` if you wish.
218+
219+ The quickest way to run all the formatters on a PR at once is typically:
220+
221+ .. code-block :: console
222+
223+ uv tool run prek run --from-ref next
224+
225+ This will run all our formatters on files that have changed since ``next ``.
226+
227+ Install Pre-Commit Hooks (Optional but recommended)
228+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229+
230+ We also have a `prek <https://prek.j178.dev >`_ config that can run some of
231+ these automatically using pre-commit hooks -- that is, when you run ``git
232+ commit ``, these tools will run and abort the commit if they change any
233+ files. You then just have to stage the new changes and try again.
234+
235+ Install our developer tools with ``uv `` as above, and then install the
236+ pre-commit hook:
237+
238+ .. code-block :: console
239+
240+ prek install
241+
242+ That's it! ``prek `` will install the tools into their own separate virtual
243+ environment so they won't interfere with any you may have, and ``git `` will take
244+ care of running them automatically.
245+
246+ .. _sec-coding-style :
247+
176248Coding Style
177249------------
178250
@@ -189,6 +261,25 @@ These guidelines are intended to make code easier to read and therefore
189261easier to understand. Being consistent in coding style also helps
190262comprehension by reducing cognitive load.
191263
264+ We use various tools to enforce code style and quality:
265+
266+ - `clang-format <https://clang.llvm.org/docs/ClangFormat.html >`_ for formatting
267+ of C++ code
268+ - `clang-tidy <https://clang.llvm.org/extra/clang-tidy/index.html >`_ for linting
269+ and static analysis of C++ code
270+ - `ruff <https://astral.sh/ruff >`_ for formatting and linting of Python code
271+ - `cmake-format <https://github.com/cheshirekow/cmake_format >`_ for formatting
272+ CMake files
273+ - `sphinx-lint <https://github.com/sphinx-contrib/sphinx-lint >`_ for linting
274+ documentation pages
275+
276+ You can install all of these tools using:
277+
278+ .. code-block :: console
279+
280+ pip install -r requirements_dev.txt
281+
282+
192283 Comments
193284~~~~~~~~
194285
0 commit comments