Metadata-Version: 2.5
Name: mathema-ci
Version: 0.1.0
Summary: mathema in CI: run the tests, measure implementation, intent and clarity, and keep the triangle in your README, from one command.
Project-URL: Homepage, https://mathema.tetrionlabs.com
Project-URL: Documentation, https://mathema.tetrionlabs.com
Project-URL: Repository, https://github.com/tetrionlabs/mathema-ci
Project-URL: Issues, https://github.com/tetrionlabs/mathema-ci/issues
Project-URL: Changelog, https://github.com/tetrionlabs/mathema-ci/blob/main/CHANGELOG.md
Author-email: Tetrion Ltd <contact@tetrion.co>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: claim-driven-development,code-coverage,continuous-integration,github-actions,gitlab-ci,mathema,pytest-plugin,software-verification
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: coverage>=7.13
Requires-Dist: mathema<0.7,>=0.6.6.1
Requires-Dist: pytest>=8
Requires-Dist: pyyaml>=6
Provides-Extra: test
Requires-Dist: hypothesis>=6; extra == 'test'
Requires-Dist: pytest-cov>=5; extra == 'test'
Requires-Dist: pytest-xdist>=3; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# mathema-ci

mathema in CI: measure a project's implementation, intent and clarity,
keep the triangle in its README, and gate each change on the debt it
adds. The measurement is [mathema](https://github.com/tetrionlabs/mathema)'s;
this package runs it and renders it.

`pip install mathema-ci` installs it with mathema 0.6.6.1 or a later 0.6.

## measure

Runs the tests under coverage, records the claims with `mathema verify`,
scores the project, prints what it found, keeps the triangle in a block
between `<!-- mathema:badges:start -->` and `<!-- mathema:badges:end -->`
in the README, and exits as the tests did.

```
mathema-ci measure --out
```

`--out` writes the badge files to `.mathema/badges/`, `--target MODULE`
scores the functions defined in MODULE, `--stage` keeps the claims read
from the tests that hold, and everything after `--` goes to pytest. The
overall is the area spanned by all three scores. More in [docs/measure.md](https://github.com/tetrionlabs/mathema-ci/blob/main/docs/measure.md).

## init

Writes a pull or merge request template and the CI workflow that runs
`mathema verify`, only where a file is missing.

```
mathema-ci init [--provider github|gitlab|both] [--dry-run]
```

More in [docs/init.md](https://github.com/tetrionlabs/mathema-ci/blob/main/docs/init.md).

## gate

Fails a change that makes a claim falsified or unknown, opens a
regression on it, or lowers clarity, on a function it touches. It runs no tests, so it runs
after `mathema verify` or `measure`.

```
mathema-ci gate [--base REF] [--base-snapshot REF:PATH | --remeasure]
                [--remeasure-budget SECONDS] [--format text|json]
```

How it finds the base and what blocks: [docs/gate.md](https://github.com/tetrionlabs/mathema-ci/blob/main/docs/gate.md).

## In CI

GitHub Actions:

```yaml
- uses: actions/checkout@v4
  with:
    fetch-depth: 2
- run: pip install -e . mathema-ci
- run: mathema-ci measure --out
- run: mathema-ci gate
  if: github.event_name == 'pull_request'
```

GitLab CI:

```yaml
mathema:
  image: python:3.12
  script:
    - pip install -e . mathema-ci
    - mathema-ci measure --out
    - if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then mathema-ci gate; fi
```

The pytest plugin that writes the test ledger is described in
[docs/test-ledger.md](https://github.com/tetrionlabs/mathema-ci/blob/main/docs/test-ledger.md).

## Licence

Apache License 2.0, as mathema-language. The measurement this package
runs is mathema's, under mathema's own licence. See `LICENSE` and
`NOTICE`. The mathema name and the triangle mark are trademarks of
Tetrion Ltd and are not licensed under the Apache License (its section 6
grants no trademark rights).
