Skip to content

Commit c8901b4

Browse files
committed
Expand setup and repository management chapters
1 parent ad7ee84 commit c8901b4

9 files changed

Lines changed: 563 additions & 40 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![PSL incubating](https://img.shields.io/badge/PSL-incubating-ff69b4.svg)](https://www.PSLmodels.org)
22

33
# <img src="https://raw.githubusercontent.com/PSLmodels/Git-Tutorial/master/book/_static/logo/jb_git_tutorial_logo.png" width=40 /> Git and GitHub Use, Collaboration, and Workflow
4-
This repository houses the source code and content files for the open access, *Git and GitHub Use, Collaboration, and Workflow* book tutorial and training used by many contributors in the [PSLmodels](https://github.com/PSLmodels) community. This project uses [Jupyter Book](https://jupyterbook.org/intro.html) to create the published HTML version of the tutorial. The source lives in this GitHub repository, and the compiled book is available at [https://pslmodels.github.io/Git-Tutorial](https://pslmodels.github.io/Git-Tutorial). This project is maintained by [Richard W. Evans](https://sites.google.com/site/rickecon/) and [Jason DeBacker](https://www.jasondebacker.com/).
4+
This repository houses the source code and content files for the open access, *Git and GitHub Use, Collaboration, and Workflow* book tutorial and training used by many contributors in the [PSLmodels](https://github.com/PSLmodels) community. This project uses [Jupyter Book](https://jupyterbook.org/intro.html) and MyST to create the published HTML version of the tutorial. The source lives in this GitHub repository, and the compiled book is available at [https://pslmodels.github.io/Git-Tutorial](https://pslmodels.github.io/Git-Tutorial). This project is maintained by [Richard W. Evans](https://sites.google.com/site/rickecon/) and [Jason DeBacker](https://www.jasondebacker.com/).
55

66

77
## Contributing to the book
@@ -23,24 +23,25 @@ conda activate jb-git-tutorial
2323

2424
### Building a Jupyter Book
2525

26-
Run the following command in your terminal:
26+
Run the following command in your terminal from the `book` directory:
2727

2828
```bash
29-
jb build ./book
29+
cd book
30+
jupyter book build --all
3031
```
3132

3233
If you would like to work with a clean build, you can empty the build folder by running:
3334

3435
```bash
35-
jb clean ./book
36+
jupyter book clean
3637
```
3738

3839
If jupyter execution is cached, this command will not delete the cached folder.
3940

4041
To remove the build folder (including `cached` executables), you can run:
4142

4243
```bash
43-
jb clean --all ./book
44+
jupyter book clean --all
4445
```
4546

4647
## Notes
Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,97 @@
11
(chap_docum)=
22
# Documentation
33

4-
Code documentation standards, README.md, Jupyter Book, actual books/manual, Sphinx
4+
Good documentation lowers the cost of using, reviewing, and contributing to a repository. In many projects, documentation quality is one of the main factors that determines whether a newcomer becomes a contributor or gives up early.
55

6-
The [Jupyter Book](https://jupyterbook.org/intro.html) documentation has a section in the [MyST Markdown Overview](https://jupyterbook.org/content/myst.html) chapter suggesting that if you are using VS Code to modify markdown files, you should download the [vscode MyST markdown extension](https://marketplace.visualstudio.com/items?itemName=ExecutableBookProject.myst-highlight) that provides highlighting and other features.
6+
## Why documentation matters
7+
8+
Documentation helps different audiences answer different questions.
9+
10+
* Users want to know what the project does and how to run it.
11+
* Contributors want to know how to set up the environment, run tests, and submit changes.
12+
* Maintainers want project knowledge to live in the repository rather than only in their heads.
13+
14+
Documentation is part of the product, not an afterthought.
15+
16+
## The role of the README
17+
18+
For many repositories, `README.md` is the first page a newcomer sees. A good README usually includes:
19+
20+
* what the repository is for
21+
* how to install or set it up
22+
* how to run the project
23+
* how to contribute
24+
* where to find more detailed documentation
25+
26+
If the README grows too large, that is often a sign the project is ready for fuller documentation rather than a sign the README should be abandoned.
27+
28+
## Layered documentation
29+
30+
Healthy projects often use several layers of documentation.
31+
32+
* README for quick orientation
33+
* contributor guide for workflow and setup
34+
* API or developer docs for code-level detail
35+
* tutorials or examples for common tasks
36+
* changelog or release notes for project history
37+
38+
Each layer serves a different purpose.
39+
40+
## Documentation for code and research repositories
41+
42+
In research-oriented open-source work, documentation may need to cover more than software usage. It may also need to explain:
43+
44+
* modeling assumptions
45+
* data inputs
46+
* expected outputs
47+
* limitations and known caveats
48+
* how results should be interpreted
49+
50+
This kind of context is often essential for reproducibility.
51+
52+
## Documentation tooling
53+
54+
Projects use many different documentation tools. Common options include:
55+
56+
* plain Markdown in the repository
57+
* Jupyter Book
58+
* Sphinx
59+
* notebooks and example galleries
60+
61+
The best tool is often the one the team will maintain consistently.
62+
63+
This repository uses Jupyter Book and MyST Markdown. If you are editing MyST files in VS Code, the [MyST extension](https://marketplace.visualstudio.com/items?itemName=ExecutableBookProject.myst-highlight) can make the authoring experience smoother.
64+
65+
## What good contributor documentation should cover
66+
67+
A newcomer should not need tribal knowledge to contribute. At minimum, contributor documentation should explain:
68+
69+
* how to create the project environment
70+
* how to run tests
71+
* how to build docs, if applicable
72+
* how to format or lint code
73+
* the expected pull request workflow
74+
75+
## Treat documentation as part of review
76+
77+
One good maintainer habit is to ask during review: does this change require documentation updates?
78+
79+
Examples include:
80+
81+
* a new feature
82+
* a changed command-line interface
83+
* a new dependency
84+
* a workflow change
85+
* a changed result or interpretation in a research project
86+
87+
If the answer is yes, the docs should usually change in the same pull request.
88+
89+
## Good habits
90+
91+
* Keep examples current.
92+
* Prefer concrete commands over vague prose.
93+
* Write for a reader who does not already know the project.
94+
* Document the supported setup path explicitly.
95+
* Fix stale docs quickly once discovered.
96+
97+
Documentation quality compounds over time. A small improvement today often saves many future contributors from the same confusion.

book/content/repomgt/license.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,80 @@
11
(chap_license)=
22
# Open Source License Options
33

4-
Discuss open source license options as well as private repository options. Benefits and drawbacks of each.
4+
Choosing a license is one of the most important early decisions for an open-source repository. A license tells other people what they are allowed to do with the code and what obligations come with that use.
5+
6+
## Why a license matters
7+
8+
Without a license, a public GitHub repository may be visible, but others usually do not have clear legal permission to reuse, modify, or redistribute the code.
9+
10+
A clear license:
11+
12+
* makes reuse expectations explicit
13+
* reduces uncertainty for contributors and users
14+
* helps organizations decide whether they can adopt the project
15+
* clarifies how improvements can flow back into the community
16+
17+
## Common open-source license families
18+
19+
Open-source licenses often fall into two broad categories.
20+
21+
### Permissive licenses
22+
23+
Permissive licenses such as MIT, BSD, and Apache 2.0 usually allow broad reuse with relatively few obligations beyond preserving notices and, in some cases, including the license text.
24+
25+
These licenses are often chosen when the project wants to maximize downstream adoption.
26+
27+
### Copyleft licenses
28+
29+
Copyleft licenses such as GPL require derivative works to remain under compatible open-source terms when distributed. These licenses are often chosen when maintainers want changes to remain open in downstream redistributions.
30+
31+
## Questions maintainers should ask
32+
33+
Before choosing a license, it helps to ask:
34+
35+
* Do we want the broadest possible reuse?
36+
* Do we want derivative works to remain open?
37+
* Are there funder, employer, or institutional requirements?
38+
* Are we combining code with dependencies that have license compatibility constraints?
39+
40+
## A practical beginner rule
41+
42+
If you are contributing to an existing repository, do not choose a new license on your own. Follow the license already used by the project and ask maintainers before making changes to licensing files.
43+
44+
If you are starting a new repository, choose a standard well-known license rather than inventing custom terms.
45+
46+
## Private repositories
47+
48+
Not every repository is open source. Some projects are private because they contain sensitive data, internal tools, unpublished research, or code that an organization is not ready to release.
49+
50+
A private repository can still benefit from all the workflow practices described in this book:
51+
52+
* branches
53+
* pull requests
54+
* code review
55+
* CI
56+
* issue tracking
57+
58+
The difference is access control, not the basic collaboration model.
59+
60+
## Documentation matters too
61+
62+
Once a project chooses a license, that decision should be easy to find.
63+
64+
Good practice includes:
65+
66+
* a top-level `LICENSE` file
67+
* a short note in the `README.md`
68+
* consistent statements in package metadata when relevant
69+
70+
## The social side of licensing
71+
72+
Licensing is partly legal, but it is also cultural. A project's license signals something about how it wants to participate in the open-source ecosystem.
73+
74+
For collaborative research repositories, it is often worth pairing the code license with clear guidance on:
75+
76+
* attribution expectations
77+
* contribution workflow
78+
* data or documentation licensing, if different from the code
79+
80+
That combination makes the repository easier to understand and safer to contribute to.

book/content/repomgt/testing_CI.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,107 @@
11
(chap_testCI)=
22
# Continuous Integration (CI) and Unit Testing
33

4-
Give a tutorial on how to set up CI and coverage in a repository. Test driven development (TDD), references. Differences among unit testing, regression testing, and CI.
4+
As repositories grow, contributors need more than good intentions to keep the default branch working. They need automatic checks that run consistently for every proposed change. This is the role of {term}`continuous integration`, usually abbreviated as CI.
5+
6+
## What CI does
7+
8+
Continuous integration is the practice of running automated checks whenever code is pushed or a pull request is opened or updated. In GitHub-based projects, these checks are often run with GitHub Actions, but the basic idea is broader than any one platform.
9+
10+
Typical CI jobs include:
11+
12+
* running unit tests
13+
* running style or lint checks
14+
* building documentation
15+
* checking that notebooks or examples execute successfully
16+
* measuring code coverage
17+
18+
The purpose of CI is not to replace human review. It is to catch routine problems quickly and consistently so reviewers can focus on design, correctness, and maintainability.
19+
20+
## Unit testing, regression testing, and CI
21+
22+
These ideas are related, but they are not identical.
23+
24+
### Unit testing
25+
26+
Unit tests check small, individual pieces of the code base. A unit test might verify that one function returns the expected output for a known input.
27+
28+
### Regression testing
29+
30+
Regression tests check that behavior that used to work still works after a change. A regression test may be a unit test, but it can also be a larger end-to-end or integration-style test that guards against reintroducing a known bug.
31+
32+
### Continuous integration
33+
34+
CI is the automation framework that runs tests and other checks whenever the repository changes. CI is the delivery mechanism, not the test itself.
35+
36+
## Why this matters in collaborative repositories
37+
38+
In a shared repository, a broken default branch creates friction for everyone. CI lowers that risk by making sure that each pull request is evaluated under the same rules.
39+
40+
For PSLmodels-style collaboration, CI is especially valuable because repositories often combine code, documentation, examples, and research outputs. A pull request may look harmless in one file while breaking something important elsewhere.
41+
42+
## What a healthy CI setup looks like
43+
44+
A good CI setup is usually:
45+
46+
* fast enough that contributors will actually pay attention to it
47+
* reliable enough that failures usually mean something real
48+
* broad enough to test the most important project behavior
49+
* visible in pull requests so contributors and reviewers can act on results
50+
51+
For a small project, that might mean only a few checks. For a mature project, it might involve several operating systems, multiple Python versions, documentation builds, and separate slow-running jobs.
52+
53+
## A simple CI path for a Python project
54+
55+
Many Python repositories start with something like the following:
56+
57+
1. install project dependencies
58+
2. run the test suite
59+
3. run formatting or linting checks
60+
4. optionally collect coverage
61+
62+
If the project publishes documentation, another good early step is to add a documentation build check so broken examples or malformed Markdown are caught before merge.
63+
64+
## Code coverage
65+
66+
Coverage tools measure how much of your code is exercised by the test suite. Coverage is useful, but it should be interpreted carefully.
67+
68+
Coverage can answer:
69+
70+
* Did our tests execute this function at all?
71+
* Which files have very little test attention?
72+
73+
Coverage cannot answer:
74+
75+
* Are the tests meaningful?
76+
* Do the tests assert the right behavior?
77+
* Are the most important edge cases covered?
78+
79+
High coverage is not the same thing as high quality. Still, coverage reports can be useful for spotting neglected parts of a code base.
80+
81+
## Test-driven development
82+
83+
Test-driven development, or TDD, is the practice of writing a failing test before implementing the code that makes it pass. Some teams use TDD heavily, while others use it selectively.
84+
85+
Even if a project does not follow TDD strictly, it is still a strong habit to add or update tests whenever behavior changes.
86+
87+
## Good contributor habits around CI
88+
89+
* Run relevant tests locally before pushing, when practical.
90+
* Read the CI failure output rather than guessing.
91+
* Keep fixes for a failing check on the same pull request branch.
92+
* Treat flaky tests as real maintenance problems.
93+
* Make sure documentation changes are tested if the repo has docs automation.
94+
95+
## Good maintainer habits around CI
96+
97+
* Keep required checks clear and documented.
98+
* Avoid adding slow or brittle checks without strong benefit.
99+
* Make failure messages readable.
100+
* Update CI when the supported environment changes.
101+
* Keep secrets and deployment credentials out of general-purpose workflows.
102+
103+
## Start simple
104+
105+
Beginners sometimes think a project needs an elaborate CI system before it can benefit from automation. In practice, even a single workflow that installs dependencies and runs tests can dramatically improve collaboration quality.
106+
107+
The best CI setup is usually one that the team understands, trusts, and maintains.

0 commit comments

Comments
 (0)