mantra
Manuels ANforderungs-TRAcing
mantra is a tool for easier tracing between requirements, implementation, and tests.
Checkout the requirements section in mantra's wiki to see how requirement tracing with mantra looks.
Core Concepts
To use mantra, a system/project must document requirements in a way that allows automatic edits at a textual level. Wikis are a good way to achieve this, and most project management tools offer at least a lightweight wiki. mantra is primarily built to work together with the structure of the wiki-repo-template for GitHub wikis, but it should be relatively simple to adapt other wikis to use mantra.
Human-readable IDs are used to identify requirements, and reference them in the implementation and/or tests. These requirement IDs must be set manually on the implementation and test side. mantra then adds the number of references a requirement has on the implementation and test side to the wiki. Since systems/projects may have different branches, these numbers are linked to the branch mantra is run against.
Example:
# my_req_id: Some requirement title
**References:**
- in branch main: 3
- in branch stable: 1
Requirement Structure
Every requirement must have a heading starting with a unique requirement ID followed by : and a title.
A requirement hierarchy may be used to create a structure of high and low-level requirements.
Example:
# my_req_id: Some requirement title
A high-level requirement.
## my_req_id.sub_req_id: Some sub-requirement title
A low-level requirement of `my_req_id`.
Referencing
Requirement IDs may be referenced in the implementation and/or tests of your system/project using the syntax [req:req_id].
This syntax should be independent enough in most programming languages that mantra can distinguish an expression from a requirement reference.
Example:
/// This function does something.
///
/// [req:req_id]
Multiple repositories
A system/project may have multiple repositories, but only one wiki to manage requirements. Therefore, mantra offers options to set the name of a repository in addition to the branch name. The repository name is then added to the entry in the references list.
Note: It is not possible to reference multiple wikis, because requirements should be kept in one place.
Example:
**References:**
- in repo frontend_repo in branch main: 3
- in repo backend_repo in branch main: 1
Usage
Commands
mantra is primarily a command line tool that offers various commands.
Use mantra <command> --help to see all available options per command.
mantra currently offers the following commands:
-
check... Used to check if the wiki structure is valid, and all references refer to requirements in the wikimantra check ./requirements_folder ./project_folderPossible output:
-------------------------------------------------------------------- `mantra check` ran successfully for branch: main **Checks:** - --- **Increased direct references for 1 requirement:** - Took: 87msNote: This command outputs all found errors before the summary shown above.
-
release... Used to create release reports to list all active requirementsmantra release --release-tag=v0.2.10 ./requirements_folderPossible output:
***Active* requirements in release v0.2.10:** - --- - - - - - - - -- - -- -- -- - -- -- - - - - - Took: 40msNote: The option
--checklistmay be set to create a checklist for all requirements that require manual verification. -
status... Shows the current state of the wikimantra status --detail-ready ./requirements_folderPossible output:
**Wiki status for branch `main`:** - --- ***Ready* requirements:** - Took: 34msNote: The
--detail-<phase>options may be used to list requirement IDs that are in this phaseCompare branches:
It is possible to compare two branches using the
statuscommand.mantra status --branch=main --cmp-branch=stable ./requirements_folderPossible output:
**Wiki differences between `main` and `stable`:** -
sync... Used to synchronize reference counter between wiki and projectmantra sync ./requirements_folder ./project_folderNote: This command stops at the first encountered error. You may want to use
mantra checkto get all errors at once.
CI/CD
For better automation, some commands may be used in CI/CD pipelines.
A docker image is available at manuelhatzl/mantra for easier integration.
The image exposes mantra without any predefined command, so it may be used like an installed command line tool.
This repository itself uses mantra in the following GitHub workflows:
- mantra_pr.yml ... Uses
checkto create a comment in PR conversations - mantra.yml ... Uses
syncto synchronize references between wiki and project - release-please.yml ... Uses
releaseto add a release report to a created release
Skip content for the reference search
Files and folders may be ignored for the references search, by adding them to .gitignore or .mantraignore files.
These files and folders are then skipped when searching references in the project.
It is also possible to ignore only the next reference inside a file, by setting [mantra:ignore_next] directly before the reference.
Example:
[mantra:ignore_next]
[req:ignored_req]
License
MIT Licensed