Skip to content

Commit f6cdb55

Browse files
Update docs with how to run tests & add new tests (#598)
* add pytest instructions to contributing guide * Update contributing guidelines to link to setup instructions for building Gambit from source * simplify docs editing process * increase subheader levels * add note on adding new tests * add section to recognize contributions and guide on using All Contributors
1 parent d96f877 commit f6cdb55

File tree

3 files changed

+57
-25
lines changed

3 files changed

+57
-25
lines changed

doc/developer.build.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ Building the Python extension
181181

182182
The :ref:`pygambit Python package <pygambit>` is in ``src/pygambit``
183183
in the Gambit source tree. We recommend to install `pygambit`
184-
as part of a virtual environment rather than in the system's Python.
185-
Use `pip` to install from the **root directory of the source tree**, optionally including the `-e` flag for an editable install:
184+
as part of a virtual environment rather than in the system's Python (for example using `venv`).
185+
Use `pip` to install from the **root directory of the source tree**:
186186

187187
.. code-block:: bash
188188
189+
python -m venv venv
190+
source venv/bin/activate
189191
python -m pip install .
190192
191-
There is a set of test cases in `src/pygambit/tests`, which can be run
192-
using `pytest`.
193193
194194
Once installed, simply ``import pygambit`` in your Python shell or
195195
script to get started.

doc/developer.contributing.rst

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,50 +45,81 @@ version.
4545
git clone https://github.com/gambitproject/gambit.git # or your fork URL
4646
cd gambit
4747

48-
3. Create a new branch for your changes ::
48+
3. Follow the instructions in the :ref:`building-from-source` page to set up your development environment and build Gambit from source. If you only plan to make changes to the PyGambit Python code, you can skip to :ref:`build-python`.
49+
50+
4. Create a new branch for your changes ::
4951

5052
git checkout -b feature/your-feature-name
5153

52-
4. Make your changes. Commit each change with a clear commit message ::
54+
5. Make your changes. Commit each change with a clear commit message ::
5355

5456
git add .
5557
git commit -m "Add feature X or fix bug Y"
5658

57-
5. Push your changes to your fork or branch ::
59+
6. Push your changes to your fork or branch ::
5860

5961
git push origin feature/your-feature-name
6062

61-
6. Open a pull request on GitHub to the master branch of the upstream repository, describing your changes and linking to any relevant issues.
62-
7. Core developers will review your changes, provide feedback, and merge them into the master branch if they meet the project's standards.
63+
7. Open a pull request on GitHub to the master branch of the upstream repository, describing your changes and linking to any relevant issues.
64+
8. Core developers will review your changes, provide feedback, and merge them into the master branch if they meet the project's standards.
65+
66+
Testing your changes
67+
--------------------
68+
69+
Be sure to familiarise yourself with :ref:`contributing-code` before reading this section.
70+
71+
By default, pull requests on GitHub will trigger the running of Gambit's test suite using GitHub Actions.
72+
You can also run the tests locally before submitting your pull request, using `pytest`.
73+
74+
1. Install the test dependencies (into the virtual environment where you installed PyGambit): ::
75+
76+
pip install -r tests/requirements.txt
77+
78+
2. Navigate to the Gambit repository and run the tests: ::
79+
80+
pytest
81+
82+
Adding to the test suite
83+
^^^^^^^^^^^^^^^^^^^^^^^^
84+
85+
Tests can be added to the test suite by creating new test files in the ``tests`` directory.
86+
Tests should be written using the `pytest` framework.
87+
Refer to existing test files for examples of how to write tests or see the `pytest documentation <https://docs.pytest.org/en/stable/>`_ for more information.
88+
6389

6490
Editing this documentation
65-
--------------------------
91+
---------------------------
6692

67-
1. If you haven't already, clone the Gambit repository from GitHub: ::
93+
Be sure to familiarise yourself with :ref:`contributing-code` before reading this section.
6894

69-
git clone https://github.com/gambitproject/gambit.git
70-
cd gambit
95+
You can make changes to the documentation by editing the `.rst` files in the ``doc`` directory.
96+
Creating a pull request with your changes will automatically trigger a build of the documentation via the ReadTheDocs service, which can be viewed online.
97+
You can also build the documentation locally to preview your changes before submitting a pull request.
7198

72-
2. Either install the docs requirements into your existing PyGambit development environment, or create a new virtual environment and install both the requirements and PyGambit there. For example, you can use `venv` to create a new environment: ::
99+
1. Install the docs dependencies (into the virtual environment where you installed PyGambit): ::
73100

74-
python -m venv docenv
75-
source docenv/bin/activate
101+
pip install -r doc/requirements.txt
76102

77-
3. Install the requirements and make the docs: ::
103+
2. Navigate to the Gambit repo and build the docs: ::
78104

79-
pip install .
80105
cd doc
81-
pip install -r requirements.txt
82106
make html # or make livehtml for live server with auto-rebuild
83107

84-
4. Open ``doc/_build/html/index.html`` in your browser to view the documentation.
85-
86-
5. Make any changes you want to the `.rst` files in the ``doc`` directory and rebuld the documentation to check your changes.
108+
3. Open ``doc/_build/html/index.html`` in your browser to view the documentation.
87109

88-
6. Follow the usual GitHub workflow to commit your changes and push them to the repository.
89-
90-
7. Core developers will review your changes and merge to the master branch, which automatically deploys the documentation via the ReadTheDocs service.
91110

92111
.. TODO: Add instructions for the GitHub workflow during contributor docs refactoring.
93112
See https://github.com/gambitproject/gambit/issues/541
94113
114+
Recognising contributions
115+
-------------------------
116+
117+
Gambit is set up with `All Contributors <https://allcontributors.org/>`__ to recognise all types of contributions, including code, documentation, bug reports, and more.
118+
119+
You can see the list of contributors on the README page of the `Gambit GitHub repo <https://github.com/gambitproject/gambit>`__.
120+
121+
To add a contributor, comment on a GitHub Issue or Pull Request, asking @all-contributors to add a contributor:
122+
123+
@all-contributors please add @<username> for <contributions>
124+
125+
Refer to the `emoji key <https://allcontributors.org/docs/en/emoji-key>`__ for a list of contribution types.

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest==9.0.0

0 commit comments

Comments
 (0)