Metadata-Version: 2.4
Name: cici-tools
Version: 0.22.0
Summary: Continuous Integration Catalog Interface
Author-email: Digital Safety Research Institute <contact@dsri.org>
License: Apache-2.0
Project-URL: Home, https://gitlab.com/saferatday0/cici
Project-URL: Issues, https://gitlab.com/saferatday0/cici/-/issues
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: appdirs
Requires-Dist: jinja2
Requires-Dist: jsonschema
Requires-Dist: markdown
Requires-Dist: msgspec
Requires-Dist: python-decouple
Requires-Dist: ruamel.yaml
Requires-Dist: termcolor
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Provides-Extra: docs
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: livereload; extra == "docs"
Provides-Extra: keywords
Requires-Dist: ci; extra == "keywords"
Requires-Dist: pipeline; extra == "keywords"
Requires-Dist: python; extra == "keywords"
Dynamic: license-file

# saferatday0 cici

<!-- BADGIE TIME -->

[![pipeline status](https://gitlab.com/saferatday0/cici/badges/main/pipeline.svg)](https://gitlab.com/saferatday0/cici/-/commits/main)
[![coverage report](https://gitlab.com/saferatday0/cici/badges/main/coverage.svg)](https://gitlab.com/saferatday0/cici/-/commits/main)
[![latest release](https://gitlab.com/saferatday0/cici/-/badges/release.svg)](https://gitlab.com/saferatday0/cici/-/releases)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![code style: black](https://img.shields.io/badge/code_style-black-000000.svg)](https://github.com/psf/black)
[![imports: isort](https://img.shields.io/badge/imports-isort-1674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

<!-- END BADGIE TIME -->

**cici** (Continuous Integration Catalog Interface) is a **pipeline component
packaging tool**. Author one CI configuration enriched with metadata, and cici:

- **Bundles** into individual, self-contained job files for distribution

- **Pins** pipeline dependencies to their latest releases

- **Documents** pipelines automatically

cici helps teams maintain reusable CI templates that are versioned, documented,
and distributed as artifacts.

cici is a foundational component of [saferatday0](https://saferatday0.dev) and
powers the [saferatday0 library](https://gitlab.com/saferatday0/library).

## How It Works

cici introduces a **project-level configuration** that manages actual CI
pipeline files. This config declares:

- **Targets** — named pipeline jobs with metadata (descriptions, groups, tags,
  container images)

- **Variables** — input variables with descriptions, defaults, and examples

- **Groups** — logical groupings of targets

- **Metadata** — project name, repo URL, descriptions

The tool then uses this higher-level config alongside provider-specific CI/CD
files (currently only `.gitlab-ci.yml`) to bundle, document, and manage pipeline
components.

## Installation

```sh
pip install cici-tools
```

## Usage

### `cici bundle`

Splits a multi-job CI file into standalone, per-job YAML files — each job gets
its own distributable `.yml` with all dependencies resolved (`extends` expanded,
variables merged, containers injected).

```bash
cici bundle
```

Use `-o`/`--output` to select an output format (defaults to `gitlab:include`).
Pass `-o` multiple times to generate several formats in one invocation:

```bash
cici bundle -o gitlab:include
```

The output format can also be controlled via the `CICI_OUTPUTS` environment
variable (comma-separated for multiple formats):

```bash
CICI_OUTPUTS=gitlab:include cici bundle
```

```console
$ cici bundle
⚡ update gitlab:include python-autoflake.yml
⚡ update gitlab:include python-black.yml
⚡ update gitlab:include python-build-sdist.yml
⚡ update gitlab:include python-build-wheel.yml
⚡ update gitlab:include python-import-linter.yml
⚡ update gitlab:include python-isort.yml
⚡ update gitlab:include python-mypy.yml
⚡ update gitlab:include python-pyroma.yml
⚡ update gitlab:include python-pytest.yml
⚡ update gitlab:include python-setuptools-bdist-wheel.yml
⚡ update gitlab:include python-setuptools-sdist.yml
⚡ update gitlab:include python-twine-upload.yml
⚡ update gitlab:include python-vulture.yml
```

### `cici update`

Pins GitLab CI `include:` references to the latest release tag of the included
project. This is fetched from the GitLab API, and results are cached for 12
hours:

```bash
cici update
```

```console
$ cici update
⚡ update gitlab:include saferatday0/library/python 0.1.0 → 0.5.1
⚡ update gitlab:include saferatday0/library/gitlab 0.1.0 → 0.2.2
```

You can ignore the cache and always pull the latest with `-f`:

```bash
cici update -f
```

### `cici readme`

Auto-generates a `README.md` from your `.cici/config.yaml` using Jinja2
templates:

```bash
cici readme
```

To customize the output, place a `README.md.j2` in your project's `.cici/` directory:

```j2
# {{ name }} pipeline

{%- include "brief.md.j2" %}
{%- include "description.md.j2" %}

{%- include "groups.md.j2" %}

{%- include "targets.md.j2" %}

{%- include "variables.md.j2" %}
```

### `cici schema`

Emits a JSON Schema for the `.cici/config.yaml` format, which can be used
for editor validation and autocompletion:

```bash
cici schema
cici schema --format yaml -o schema.yaml
```

## Configuration

### Project Config (`.cici/config.yaml`)

Defines pipeline component metadata, targets, and variables:

```yaml
name: my-pipeline
brief: A reusable CI/CD pipeline component.

targets:
  - name: lint
    brief: Run linters.
    container:
      image: python:3.12

  - name: test
    brief: Run tests.
    container:
      image: python:3.12

variables:
  PYTHON_VERSION:
    brief: Python version to use.
    default: "3.12"
```

Targets can also live in separate files under `.cici/targets/*.yaml`.

### User Config (`~/.config/cici-tools/config.ini`)

Controls GitLab connection and caching:

```ini
# ~/.config/cici-tools/config.ini
CICI_GITLAB_URL=https://gitlab.com
CICI_GITLAB_PRIVATE_TOKEN=glpat-...
CICI_CACHE_TIMEOUT=43200
```

## License

Copyright 2024-2026 UL Research Institutes.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

<http://www.apache.org/licenses/LICENSE-2.0>

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
