Keep rules in a shared repository
This guide moves rules into a repository of their own, so one set serves several repositories.
-
Create the rules repository. Put the rules under a folder such as
lore/, with a.loreconfigthat makes it a Lore root:# team-rules/lore/.loreconfigroot: true -
Map a folder onto each governed repository. Add a folder per repository, with a
repokey naming it:# team-rules/lore/shop/.loreconfigrepo: github.com/acme/shopBelow
shop/, directories mirror the shop repository. A.lore/folder directly undershop/resolves its globs from the shop's root. -
Commit the rules. Only files git tracks in the rules repository are read.
-
Run with the folder given. From a clone of the shop, with the rules repository checked out beside it:
npx @mattstack/lore check --given ../team-rules/loreThe tool matches
repo: github.com/acme/shopagainst the shop's git remotes and collects the rules belowshop/. -
Check out the rules in CI. CI has no sibling folder, so check the rules repository out inside the workspace, for example with
actions/checkoutandpath: team-rules. The CI commands below give it as--given team-rules/lore. -
Name the remote in CI if needed. If CI clones from a mirror whose URL does not match, pass the remote yourself:
npx @mattstack/lore check --base origin/main --given team-rules/lore --remote github.com/acme/shop -
Judge by the target branch's own rules.
--rules-refreads the governed repo's own Lore files at a git ref, so a change cannot loosen one of them in the same commit that breaks it:npx @mattstack/lore check --base origin/main --rules-ref origin/main --given team-rules/loreIt does not apply to the given folder, which is read from its own checkout. The next step pins that.
-
Pin the rules version. Check out the rules repository at a tag or commit in CI, so a change to the shared rules reaches each repository when its team chooses.
Next steps
- Shared rule repositories: how matching, loose folders and ids work.
--given,--remoteand--rules-ref: the options in full.- External folders in the specification.