Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec python3 "$(git rev-parse --show-toplevel)/bin/check.py"
exec python3 "$(dirname "$0")/../bin/check.py" --root "$(git rev-parse --show-toplevel)"
2 changes: 1 addition & 1 deletion .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec python3 "$(git rev-parse --show-toplevel)/bin/check.py" --pre-push
exec python3 "$(dirname "$0")/../bin/check.py" --root "$(git rev-parse --show-toplevel)" --pre-push
10 changes: 9 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ on:
push:
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ourPLCC/change-requests
path: change-requests
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand All @@ -22,6 +29,7 @@ jobs:
python3 -m unittest discover -s tests -t .
python3 -m unittest discover -s migrate/tests -t .
- name: Consistency check
run: python3 bin/check.py --pre-push
run: python3 bin/check.py --pre-push --root change-requests
- name: Backlog.md doctor
working-directory: change-requests
run: backlog doctor
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Repo docs link to this guide rather than restating it, even to agree with it.
reports a problem or suggests an idea by opening an issue on the relevant
code repo.
- **Change requests (CRs)** are the work we commit to, tracked centrally in
this repo with [Backlog.md](https://github.com/MrLesk/Backlog.md). A CR is
[ourPLCC/change-requests](https://github.com/ourPLCC/change-requests) with
[Backlog.md](https://github.com/MrLesk/Backlog.md). A CR is
work in exactly one repo with testable acceptance criteria, and has an ID
`CR-N`. Work spanning repos is one CR per repo, linked by dependencies.
- **Drafts** are ideas we have not committed to. Never cite one.
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# ourPLCC developer docs and change requests
# ourPLCC developer docs

How we build ourPLCC, for maintainers, their agents, and new developers:
the developer guide shared by every ourPLCC repository, org-wide specs, agent
rules, and the central change-request tracker for work on plcc-ng,
languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and course-materials-ng.
rules, and the tooling for the change-request tracker. The tracker itself, for
work on plcc-ng, languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and
course-materials-ng, is
[ourPLCC/change-requests](https://github.com/ourPLCC/change-requests).

**Reporting a problem or suggesting an idea?** Open a GitHub issue on the
relevant code repository instead. GitHub Issues are where humans talk to us;
this repository is where maintainers track the resulting work.
the tracker is where maintainers track the resulting work.

**Start with [CONTRIBUTING.md](CONTRIBUTING.md)**, the developer guide.

Expand Down
9 changes: 6 additions & 3 deletions bin/check.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""Consistency checks for the ourPLCC change-request tracker.

Standard library only: this runs on maintainers' hosts (pre-push hook) as
well as in containers, without Node or Backlog.md.
Standard library only: this runs from the hooks and in CI without Node or
Backlog.md. --root names the tracker repo (ourPLCC/change-requests).
"""
import argparse
import re
Expand Down Expand Up @@ -71,6 +71,8 @@ def _as_list(value):
def check(root, pre_push=False):
root = Path(root)
backlog = root / "backlog"
if not (backlog / "config.yml").is_file():
return [f"{root}: no backlog/config.yml; --root must name the tracker repo"]
config = load_config(backlog / "config.yml")
projects = _as_list(config.get("projects"))
types = _as_list(config.get("types"))
Expand Down Expand Up @@ -132,7 +134,8 @@ def rel(path):

def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--root", default=str(Path(__file__).resolve().parent.parent))
parser.add_argument("--root", required=True,
help="root of the tracker repo, which holds backlog/")
parser.add_argument("--pre-push", action="store_true",
help="also fail on uncommitted changes under backlog/")
args = parser.parse_args(argv)
Expand Down
18 changes: 11 additions & 7 deletions dev-docs/tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The central tracker for work on the ourPLCC code repositories: plcc-ng,
languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and course-materials-ng. It
is managed with [Backlog.md](https://github.com/MrLesk/Backlog.md). This is
is managed with [Backlog.md](https://github.com/MrLesk/Backlog.md). Its data
lives in [ourPLCC/change-requests](https://github.com/ourPLCC/change-requests);
its checks and tooling live here, in `dev`. This is
the full guide to using it; the [developer guide](../CONTRIBUTING.md) gives
the short version and the workflow around it.

Expand Down Expand Up @@ -59,7 +61,8 @@ this guide wins.
decision that binds more than one repo); update the CR's acceptance
criteria to match and add the spec as a reference:
`backlog task edit CR-N --add-ref ../../../plcc-ng/dev-docs/specs/<file>.md`
(for this repo: `../../dev-docs/specs/<file>.md`). Specs do not cite CRs.
(for this repo: `../../../dev/dev-docs/specs/<file>.md`). Specs do not cite
CRs.
2. **Plan and execute:** the plan lives in `.plans/` inside the worktree
(gitignored) and is deleted with it. Plans are not kept. During automated
execution, record discovered work in the CR's notes —
Expand Down Expand Up @@ -102,7 +105,7 @@ dependency as satisfied, so review the CRs that depended on it.
- **Demote** (`backlog task demote CR-N`) only when nothing cites the CR:

```bash
grep -rn 'CR-N\b' /workspaces/dev/backlog /workspaces/<repo> --include='*.md'
grep -rn 'CR-N\b' /workspaces/change-requests/backlog /workspaces/<repo> --include='*.md'
git -C /workspaces/<repo> log --all --oneline -i --grep 'cr-N\b'
```

Expand All @@ -124,7 +127,8 @@ version impact; its branch may carry other commit types too.

Every CR has exactly one `project`: `plcc-ng`, `languages-ng`, `plcc-ng-demo`,
`plcc-ng-devcontainer`, `course-materials-ng`, or `dev` (this repo: the org
docs and specs, the tracker's config, checks, CI, and migration tooling). Work spanning repos is one
docs and specs, and the tracker's checks, CI, and migration tooling; the
config is `change-requests`' `backlog/config.yml`). Work spanning repos is one
CR per repo linked with `--dep` (no umbrella CRs); `backlog task list --ready`
hides a CR until its dependencies are done.

Expand Down Expand Up @@ -172,7 +176,7 @@ to renumber the unpushed CR, commit, and push. CI runs the same check plus

## Checks (`bin/check.py`)

Fails on: duplicate IDs (drafts included) or a filename that does not match its `id`; a
`bin/check.py --root <tracker>` fails on: duplicate IDs (drafts included) or a filename that does not match its `id`; a
`DRAFT-N` cited outside its own file; a CR without exactly one configured
`project` or `type`; an unconfigured label; anything in `archive/`; and, with
`--pre-push`, uncommitted changes under `backlog/`. `CR-999` is exempt from
Expand Down Expand Up @@ -222,8 +226,8 @@ checks run on hosts as well as in containers. Run what CI runs
```bash
python3 -m unittest discover -s tests -t .
python3 -m unittest discover -s migrate/tests -t .
python3 bin/check.py --pre-push
backlog doctor
python3 bin/check.py --pre-push --root /workspaces/change-requests
(cd /workspaces/change-requests && backlog doctor)
```

A new rule in `bin/check.py` gets a test in `tests/test_check.py` and a line
Expand Down
41 changes: 41 additions & 0 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,47 @@ def test_cli_exit_code_on_error(self):
self.assertEqual(result.returncode, 1)
self.assertIn("check: ", result.stderr)

def test_cli_requires_root(self):
result = subprocess.run(
[sys.executable, str(ROOT / "bin" / "check.py")],
capture_output=True, text=True)
self.assertEqual(result.returncode, 2)
self.assertIn("--root", result.stderr)
self.assertNotIn("Traceback", result.stderr)

def test_root_without_tracker_is_a_clear_error(self):
empty = self.root / "not-a-tracker"
empty.mkdir()
result = subprocess.run(
[sys.executable, str(ROOT / "bin" / "check.py"), "--root", str(empty)],
capture_output=True, text=True)
self.assertEqual(result.returncode, 1)
self.assertIn("no backlog/config.yml", result.stderr)
self.assertNotIn("Traceback", result.stderr)

def hook(self, name):
git = ["git", "-c", "user.name=t", "-c", "user.email=t@t", "-C", str(self.root)]
subprocess.run(git + ["init", "-q"], check=True)
subprocess.run(git + ["add", "-A"], check=True)
subprocess.run(git + ["commit", "-q", "-m", "x"], check=True)
return subprocess.run(["sh", str(ROOT / ".githooks" / name)],
cwd=self.root, capture_output=True, text=True)

def test_pre_commit_hook_checks_the_repo_that_runs_it(self):
self.add("tasks", "cr-1000 - A.md", record("CR-1000", project="nope"))
result = self.hook("pre-commit")
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
self.assertIn("project", result.stderr)

def test_pre_push_hook_checks_the_repo_that_runs_it(self):
result = self.hook("pre-push")
self.assertEqual(result.returncode, 0, result.stderr)
self.add("tasks", "cr-1000 - A.md", record("CR-1000"))
result = subprocess.run(["sh", str(ROOT / ".githooks" / "pre-push")],
cwd=self.root, capture_output=True, text=True)
self.assertEqual(result.returncode, 1)
self.assertIn("uncommitted change under backlog/", result.stderr)


if __name__ == "__main__":
unittest.main()
Loading