mantra

build-test docker mantra-sync

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:

```

myreqid: Some requirement title

References:

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:

```

myreqid: Some requirement title

A high-level requirement.

myreqid.subreqid: 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:

rust /// This function does something. /// /// [req:req_id] fn my_function() { //... }

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:

Usage

Setup

mantra is available on crates.io, and may be installed using the Rust toolchain:

cargo install mantra

Alternatively, mantra is available as Docker image, and may be run locally with:

docker run manuelhatzl/mantra:main mantra

To use the Docker image inside GitHub workflows, use:

yaml runs-on: ubuntu-latest container: image: manuelhatzl/mantra:main

Note: The image is based on the Alpine image, and may not support all commands available with the Ubuntu image.

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:


mantra check ran successfully for branch: main

Checks:

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:

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